2015-12-22 14:21:18 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
. $srcdir/defs.inc || exit 3
|
|
|
|
|
|
|
|
#set -x
|
|
|
|
|
|
|
|
# Make sure $srcdir is set.
|
|
|
|
if test "x$srcdir" = x
|
|
|
|
then
|
|
|
|
echo srcdir environment variable not set!
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Import the sample key
|
|
|
|
#
|
|
|
|
# pub 1024R/8BC90111 2015-12-02
|
|
|
|
# Key fingerprint = E657 FB60 7BB4 F21C 90BB 6651 BC06 7AF2 8BC9 0111
|
|
|
|
# uid [ultimate] Barrett Brown <barrett@example.org>
|
|
|
|
# sub 1024R/3E880CFF 2015-12-02 (encryption)
|
|
|
|
# sub 1024R/F5F77B83 2015-12-02 (signing)
|
|
|
|
# sub 1024R/45117079 2015-12-02 (encryption)
|
|
|
|
# sub 1024R/1EA97479 2015-12-02 (signing)
|
|
|
|
info "Importing public key."
|
|
|
|
if $GPG --import $srcdir/samplekeys/E657FB607BB4F21C90BB6651BC067AF28BC90111.asc
|
|
|
|
then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
error "$k: import failed"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# By default, the most recent, valid signing subkey (1EA97479).
|
|
|
|
for x in 8BC90111 3E880CFF F5F77B83 45117079 1EA97479
|
|
|
|
do
|
|
|
|
info
|
|
|
|
info "Trying --default-key $x"
|
|
|
|
|
|
|
|
if ! echo | $GPG --default-key "$x" -s | $GPG --verify --status-fd=1 \
|
2016-03-02 17:55:56 +01:00
|
|
|
| grep 'VALIDSIG 5FBA84ACE02DCB17DA3DFF6BBCA43C441EA97479' >/dev/null
|
2015-12-22 14:21:18 +01:00
|
|
|
then
|
|
|
|
echo | $GPG --default-key "$x" -s | $GPG --verify --status-fd=2
|
|
|
|
error "Unexpected key used for signing (not the signing subkey, specified \"$x\")."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# By default, the most recent, valid encryption subkey (45117079).
|
|
|
|
for x in 8BC90111 3E880CFF F5F77B83 45117079 1EA97479
|
|
|
|
do
|
|
|
|
info
|
|
|
|
info "Trying --default-key $x --encrypt-to-default-key"
|
|
|
|
|
|
|
|
# We need another recipient, because --encrypt-to-default-key is
|
|
|
|
# not considered a recipient and gpg doesn't encrypt without any
|
|
|
|
# recipients.
|
|
|
|
#
|
|
|
|
# Note: it doesn't matter whether we specify the primary key or
|
|
|
|
# a subkey: the newest encryption subkey will be used.
|
2016-04-04 13:10:28 +02:00
|
|
|
if ! echo | $GPG ${opt_always} \
|
2015-12-22 14:21:18 +01:00
|
|
|
--default-key "$x" --encrypt-to-default-key \
|
|
|
|
-r 439F02CA -e \
|
|
|
|
| $GPG --list-packets \
|
2016-03-02 17:55:56 +01:00
|
|
|
| grep "keyid[ ][A-F0-9]*45117079" >/dev/null
|
2015-12-22 14:21:18 +01:00
|
|
|
then
|
2016-04-04 13:10:28 +02:00
|
|
|
echo | $GPG ${opt_always} \
|
2015-12-22 14:21:18 +01:00
|
|
|
--default-key "$x" --encrypt-to-default-key \
|
|
|
|
-r 439F02CA -e \
|
|
|
|
| $GPG --list-packets 1>&2
|
|
|
|
error "Unexpected key used for signing (specified \"$x\")."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|