summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-04-25 23:23:51 +0200
committerLudovic Courtès <ludo@gnu.org>2020-05-04 09:56:12 +0200
commit4459c7859c286ab54fa3a9901c8a17591b04c516 (patch)
tree867a6768699931c621b7c41d5fbfaa58f4d5ffa7 /tests
parent43408e304ffb1149f35cb539b40d673d567c9116 (diff)
openpgp: Decode the issuer-fingerprint signature subpacket.
* guix/openpgp.scm (SUBPACKET-ISSUER-FINGERPRINT): New variable. (openpgp-signature-issuer-fingerprint): New procedure. (key-id-matches-fingerprint?): New procedure. (get-signature): Look for the 'issuer and 'issuer-fingerprint subpackets. Ensure the issuer key ID matches the fingerprint when both are available. (parse-subpackets): Handle SUBPACKET-ISSUER-FINGERPRINT. * tests/openpgp.scm (%rsa-key-fingerprint) (%dsa-key-fingerprint, %ed25519-key-fingerprint): New variables. * tests/openpgp.scm ("get-openpgp-detached-signature/ascii"): Check the result of 'openpgp-signature-issuer-fingerprint'.
Diffstat (limited to 'tests')
-rw-r--r--tests/openpgp.scm22
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/openpgp.scm b/tests/openpgp.scm
index 8a3c7bbeb7d..20d65171fd8 100644
--- a/tests/openpgp.scm
+++ b/tests/openpgp.scm
@@ -18,6 +18,7 @@
18 18
19(define-module (tests-openpgp) 19(define-module (tests-openpgp)
20 #:use-module (guix openpgp) 20 #:use-module (guix openpgp)
21 #:use-module (gcrypt base16)
21 #:use-module (gcrypt hash) 22 #:use-module (gcrypt hash)
22 #:use-module (gcrypt pk-crypto) 23 #:use-module (gcrypt pk-crypto)
23 #:use-module (ice-9 binary-ports) 24 #:use-module (ice-9 binary-ports)
@@ -65,6 +66,16 @@ vBSFjNSiVHsuAA==
65(define %dsa-key-id #x587918047BE8BD2C) ;dsa.key 66(define %dsa-key-id #x587918047BE8BD2C) ;dsa.key
66(define %ed25519-key-id #x771F49CBFAAE072D) ;ed25519.key 67(define %ed25519-key-id #x771F49CBFAAE072D) ;ed25519.key
67 68
69(define %rsa-key-fingerprint
70 (base16-string->bytevector
71 (string-downcase "385F86CFC86B665A5C165E6BAE25DA2A70DEED59")))
72(define %dsa-key-fingerprint
73 (base16-string->bytevector
74 (string-downcase "2884A980422330A4F33DD97F587918047BE8BD2C")))
75(define %ed25519-key-fingerprint
76 (base16-string->bytevector
77 (string-downcase "44D31E21AF7138F9B632280A771F49CBFAAE072D")))
78
68 79
69;;; The following are detached signatures created commands like: 80;;; The following are detached signatures created commands like:
70;;; echo 'Hello!' | gpg -sba --digest-algo sha512 81;;; echo 'Hello!' | gpg -sba --digest-algo sha512
@@ -160,15 +171,16 @@ Pz7oopeN72xgggYUNT37ezqN3MeCqw0=
160 "Ludovic Courtès <ludo@gnu.org>")))))) 171 "Ludovic Courtès <ludo@gnu.org>"))))))
161 172
162(test-equal "get-openpgp-detached-signature/ascii" 173(test-equal "get-openpgp-detached-signature/ascii"
163 (list `(,%dsa-key-id dsa sha256) 174 (list `(,%dsa-key-id ,%dsa-key-fingerprint dsa sha256)
164 `(,%rsa-key-id rsa sha256) 175 `(,%rsa-key-id ,%rsa-key-fingerprint rsa sha256)
165 `(,%ed25519-key-id eddsa sha256) 176 `(,%ed25519-key-id ,%ed25519-key-fingerprint eddsa sha256)
166 `(,%ed25519-key-id eddsa sha512) 177 `(,%ed25519-key-id ,%ed25519-key-fingerprint eddsa sha512)
167 `(,%ed25519-key-id eddsa sha1)) 178 `(,%ed25519-key-id ,%ed25519-key-fingerprint eddsa sha1))
168 (map (lambda (str) 179 (map (lambda (str)
169 (let ((signature (get-openpgp-detached-signature/ascii 180 (let ((signature (get-openpgp-detached-signature/ascii
170 (open-input-string str)))) 181 (open-input-string str))))
171 (list (openpgp-signature-issuer signature) 182 (list (openpgp-signature-issuer signature)
183 (openpgp-signature-issuer-fingerprint signature)
172 (openpgp-signature-public-key-algorithm signature) 184 (openpgp-signature-public-key-algorithm signature)
173 (openpgp-signature-hash-algorithm signature)))) 185 (openpgp-signature-hash-algorithm signature))))
174 (list %hello-signature/dsa 186 (list %hello-signature/dsa