2 # Copyright (c) 2014-2016 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 INPUT
=$
(cat /dev
/stdin
)
11 if [ "$BITCOIN_VERIFY_COMMITS_ALLOW_SHA1" = 1 ]; then
12 GPG_RES
="$(echo "$INPUT" | gpg --trust-model always "$@
" 2>/dev/null)"
14 # Note how we've disabled SHA1 with the --weak-digest option, disabling
15 # signatures - including selfsigs - that use SHA1. While you might think that
16 # collision attacks shouldn't be an issue as they'd be an attack on yourself,
17 # in fact because what's being signed is a commit object that's
18 # semi-deterministically generated by untrusted input (the pull-req) in theory
19 # an attacker could construct a pull-req that results in a commit object that
20 # they've created a collision for. Not the most likely attack, but preventing
21 # it is pretty easy so we do so as a "belt-and-suspenders" measure.
23 for LINE
in "$(gpg --version)"; do
25 "gpg (GnuPG) 1.4.1"*|
"gpg (GnuPG) 2.0."*)
26 echo "Please upgrade to at least gpg 2.1.10 to check for weak signatures" > /dev
/stderr
27 GPG_RES
="$(echo "$INPUT" | gpg --trust-model always "$@
" 2>/dev/null)"
29 # We assume if you're running 2.1+, you're probably running 2.1.10+
30 # gpg will fail otherwise
31 # We assume if you're running 1.X, it is either 1.4.1X or 1.4.20+
32 # gpg will fail otherwise
35 [ "$GPG_RES" = "" ] && GPG_RES
="$(echo "$INPUT" | gpg --trust-model always --weak-digest sha1 "$@
" 2>/dev/null)"
37 for LINE
in $
(echo "$GPG_RES"); do
39 "[GNUPG:] VALIDSIG "*)
41 [ "${LINE#?GNUPG:? VALIDSIG * * * * * * * * * }" = "$KEY" ] && VALID
=true
42 done < .
/contrib
/verify-commits
/trusted-keys
44 "[GNUPG:] REVKEYSIG "*)
45 [ "$BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG" != 1 ] && exit 1
47 GOODREVSIG
="[GNUPG:] GOODSIG ${LINE#* * *}"
49 "[GNUPG:] EXPKEYSIG "*)
50 [ "$BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG" != 1 ] && exit 1
52 GOODREVSIG
="[GNUPG:] GOODSIG ${LINE#* * *}"
59 if $VALID && $REVSIG; then
60 echo "$INPUT" | gpg
--trust-model always
"$@" 2>/dev
/null |
grep "\[GNUPG:\] \(NEWSIG\|SIG_ID\|VALIDSIG\)"
63 echo "$INPUT" | gpg
--trust-model always
"$@" 2>/dev
/null