2014-10-27 08:07:25 +01:00
|
|
|
#!/bin/sh
|
2019-12-30 10:39:22 +01:00
|
|
|
# Copyright (c) 2014-2019 The Bitcoin Core developers
|
2016-09-11 21:36:22 +02:00
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2018-06-13 16:50:48 +02:00
|
|
|
export LC_ALL=C
|
2016-05-21 03:29:15 +02:00
|
|
|
INPUT=$(cat /dev/stdin)
|
2017-02-27 20:13:39 +01:00
|
|
|
if [ "$BITCOIN_VERIFY_COMMITS_ALLOW_SHA1" = 1 ]; then
|
2023-02-07 18:27:32 +01:00
|
|
|
printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null
|
|
|
|
exit $?
|
2017-02-27 20:13:39 +01:00
|
|
|
else
|
2017-03-01 16:58:14 +01:00
|
|
|
# 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.
|
2019-07-02 18:48:08 +02:00
|
|
|
for LINE in $(gpg --version); do
|
2017-03-06 22:13:40 +01:00
|
|
|
case "$LINE" in
|
|
|
|
"gpg (GnuPG) 1.4.1"*|"gpg (GnuPG) 2.0."*)
|
|
|
|
echo "Please upgrade to at least gpg 2.1.10 to check for weak signatures" > /dev/stderr
|
2023-02-07 18:27:32 +01:00
|
|
|
printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null
|
|
|
|
exit $?
|
2017-03-06 22:13:40 +01:00
|
|
|
;;
|
|
|
|
# We assume if you're running 2.1+, you're probably running 2.1.10+
|
|
|
|
# gpg will fail otherwise
|
|
|
|
# We assume if you're running 1.X, it is either 1.4.1X or 1.4.20+
|
|
|
|
# gpg will fail otherwise
|
|
|
|
esac
|
|
|
|
done
|
2023-02-07 18:27:32 +01:00
|
|
|
printf '%s\n' "$INPUT" | gpg --trust-model always --weak-digest sha1 "$@" 2>/dev/null
|
|
|
|
exit $?
|
2015-10-23 11:05:42 +02:00
|
|
|
fi
|