diff options
author | Neal H. Walfield <[email protected]> | 2015-12-02 19:51:52 +0000 |
---|---|---|
committer | Neal H. Walfield <[email protected]> | 2015-12-02 23:00:54 +0000 |
commit | cedbd4709eed6fead9d1b271f96860c00547c77c (patch) | |
tree | fe95c27b0c0c7da51f0ef66bc0e1aa43444c514a /tests/openpgp/use-exact-key.test | |
parent | build: Require at least Libassuan 2.4.1. (diff) | |
download | gnupg-cedbd4709eed6fead9d1b271f96860c00547c77c.tar.gz gnupg-cedbd4709eed6fead9d1b271f96860c00547c77c.zip |
gpg: Use the matching key if the search description is exact.
* g10/gpg.c (check_user_ids): If the search description is for an
exact match (a keyid or fingerprint that ends in '!'), then use the
matching key, not the primary key.
* tests/openpgp/Makefile.am (TESTS): Add use-exact-key.test.
(priv_keys): Add privkeys/00FE67F28A52A8AA08FFAED20AF832DA916D1985.asc,
privkeys/1DF48228FEFF3EC2481B106E0ACA8C465C662CC5.asc,
privkeys/A2832820DC9F40751BDCD375BB0945BA33EC6B4C.asc,
privkeys/ADE710D74409777B7729A7653373D820F67892E0.asc and
privkeys/CEFC51AF91F68A2904FBFF62C4F075A4785B803F.asc.
(sample_keys): Add
samplekeys/E657FB607BB4F21C90BB6651BC067AF28BC90111.asc.
* tests/openpgp/privkeys/00FE67F28A52A8AA08FFAED20AF832DA916D1985.asc:
New file.
* tests/openpgp/privkeys/1DF48228FEFF3EC2481B106E0ACA8C465C662CC5.asc:
New file.
* tests/openpgp/privkeys/A2832820DC9F40751BDCD375BB0945BA33EC6B4C.asc:
New file.
* tests/openpgp/privkeys/ADE710D74409777B7729A7653373D820F67892E0.asc:
New file.
* tests/openpgp/privkeys/CEFC51AF91F68A2904FBFF62C4F075A4785B803F.asc:
New file.
* tests/openpgp/samplekeys/E657FB607BB4F21C90BB6651BC067AF28BC90111.asc:
New file.
* tests/openpgp/use-exact-key.test: New file.
* tests/openpgp/version.test: Install the new private keys.
--
Signed-off-by: Neal H. Walfield <[email protected]>
Reported-by: Reported-by: Kristian Fiskerstrand
<[email protected]>
Fixes-commit: 10cca02
Diffstat (limited to 'tests/openpgp/use-exact-key.test')
-rwxr-xr-x | tests/openpgp/use-exact-key.test | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/openpgp/use-exact-key.test b/tests/openpgp/use-exact-key.test new file mode 100755 index 000000000..cbbd0090a --- /dev/null +++ b/tests/openpgp/use-exact-key.test @@ -0,0 +1,55 @@ +#!/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 <[email protected]> +# 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 + if ! echo | $GPG -s -u "$x" | $GPG --verify --status-fd=1 \ + | grep -q 'VALIDSIG 5FBA84ACE02DCB17DA3DFF6BBCA43C441EA97479' + then + echo | $GPG -s -u "$x" | $GPG --verify --status-fd=2 + error "Unexpected key used for signing (not the signing subkey, specified \"$x\")." + exit 1 + fi +done + +# But, if we request a particular signing key, we should get it. +for x in 8BC90111 F5F77B83 1EA97479 +do + if ! echo | $GPG -s -u "$x!" | $GPG --verify --status-fd=1 \ + | grep -q "VALIDSIG [0-9A-F]*$x " + then + echo | $GPG -s -u "$x!" | $GPG --verify --status-fd=2 + error "Unexpected key used for signing (specified: \"$x!\")." + exit 1 + fi +done + +exit 0 |