2014-10-27 08:07:25 +01:00
|
|
|
#!/bin/sh
|
2016-09-20 09:56:14 +02:00
|
|
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2016-06-20 14:33:26 +02:00
|
|
|
INPUT=$(cat /dev/stdin)
|
2014-10-27 08:07:25 +01:00
|
|
|
VALID=false
|
2015-10-23 11:05:42 +02:00
|
|
|
REVSIG=false
|
2016-06-20 14:33:26 +02:00
|
|
|
IFS='
|
|
|
|
'
|
2017-03-06 17:19:15 +01:00
|
|
|
if [ "$BITCOIN_VERIFY_COMMITS_ALLOW_SHA1" = 1 ]; then
|
|
|
|
GPG_RES="$(echo "$INPUT" | gpg --trust-model always "$@" 2>/dev/null)"
|
|
|
|
else
|
|
|
|
# Note how we've disabled SHA1 with the --weak-digest option, disabling
|
|
|
|
# signatures - including selfsigs - that use SHA1. While you might think that
|
|
|
|
# collision attacks shouldn't be an issue as they'd be an attack on yourself,
|
|
|
|
# in fact because what's being signed is a commit object that's
|
|
|
|
# semi-deterministically generated by untrusted input (the pull-req) in theory
|
|
|
|
# an attacker could construct a pull-req that results in a commit object that
|
|
|
|
# they've created a collision for. Not the most likely attack, but preventing
|
|
|
|
# it is pretty easy so we do so as a "belt-and-suspenders" measure.
|
|
|
|
|
|
|
|
GPG_RES="$(echo "$INPUT" | gpg --trust-model always --weak-digest sha1 "$@" 2>/dev/null)"
|
|
|
|
fi
|
|
|
|
for LINE in $(echo "$GPG_RES"); do
|
2015-10-23 11:05:42 +02:00
|
|
|
case "$LINE" in
|
|
|
|
"[GNUPG:] VALIDSIG "*)
|
2014-10-27 08:07:25 +01:00
|
|
|
while read KEY; do
|
2017-03-06 17:19:15 +01:00
|
|
|
[ "${LINE#?GNUPG:? VALIDSIG * * * * * * * * * }" = "$KEY" ] && VALID=true
|
2014-10-27 08:07:25 +01:00
|
|
|
done < ./contrib/verify-commits/trusted-keys
|
2015-10-23 11:05:42 +02:00
|
|
|
;;
|
|
|
|
"[GNUPG:] REVKEYSIG "*)
|
|
|
|
[ "$BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG" != 1 ] && exit 1
|
2017-03-06 17:19:15 +01:00
|
|
|
REVSIG=true
|
|
|
|
GOODREVSIG="[GNUPG:] GOODSIG ${LINE#* * *}"
|
2015-10-23 11:05:42 +02:00
|
|
|
;;
|
2014-10-27 08:07:25 +01:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
if ! $VALID; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-10-23 11:05:42 +02:00
|
|
|
if $VALID && $REVSIG; then
|
2018-06-18 18:08:27 +02:00
|
|
|
echo "$INPUT" | gpg --trust-model always "$@" | grep "^\[GNUPG:\] \(NEWSIG\|SIG_ID\|VALIDSIG\)" 2>/dev/null
|
2015-10-23 11:05:42 +02:00
|
|
|
echo "$GOODREVSIG"
|
|
|
|
else
|
|
|
|
echo "$INPUT" | gpg --trust-model always "$@" 2>/dev/null
|
|
|
|
fi
|