From bd8126558dc7a022d7853d803d7134ffa1b7bc52 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 30 Apr 2020 15:43:19 +0200 Subject: openpgp: 'lookup-key-by-{id,fingerprint}' return the key first. Previously, 'lookup-key-by-{id,fingerprint}' would always return the list of packets where the primary key is first. Thus, the caller would need to use 'find' to actually find the requested key. * guix/openpgp.scm (keyring-insert): Always add KEY to PACKETS. (lookup-key-by-id, lookup-key-by-fingerprint): Change to return the key as the first value. (verify-openpgp-signature): Remove now unneeded call to 'find'. * tests/openpgp.scm ("get-openpgp-keyring"): Adjust accordingly. --- tests/openpgp.scm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tests/openpgp.scm') diff --git a/tests/openpgp.scm b/tests/openpgp.scm index cc5e6cbcf7..a85fe6a6cb 100644 --- a/tests/openpgp.scm +++ b/tests/openpgp.scm @@ -160,17 +160,17 @@ Pz7oopeN72xgggYUNT37ezqN3MeCqw0= (keyring (get-openpgp-keyring (open-bytevector-input-port (call-with-input-file key read-radix-64))))) - (match (lookup-key-by-id keyring %civodul-key-id) - (((? openpgp-public-key? primary) packets ...) - (let ((fingerprint (openpgp-public-key-fingerprint primary))) - (and (= (openpgp-public-key-id primary) %civodul-key-id) - (not (openpgp-public-key-subkey? primary)) - (string=? (openpgp-format-fingerprint fingerprint) - %civodul-fingerprint) - (string=? (openpgp-user-id-value (find openpgp-user-id? packets)) - "Ludovic Courtès ") - (equal? (lookup-key-by-id keyring %civodul-key-id) - (lookup-key-by-fingerprint keyring fingerprint)))))))) + (let-values (((primary packets) + (lookup-key-by-id keyring %civodul-key-id))) + (let ((fingerprint (openpgp-public-key-fingerprint primary))) + (and (= (openpgp-public-key-id primary) %civodul-key-id) + (not (openpgp-public-key-subkey? primary)) + (string=? (openpgp-format-fingerprint fingerprint) + %civodul-fingerprint) + (string=? (openpgp-user-id-value (find openpgp-user-id? packets)) + "Ludovic Courtès ") + (eq? (lookup-key-by-fingerprint keyring fingerprint) + primary)))))) (test-equal "get-openpgp-detached-signature/ascii" (list `(,%dsa-key-id ,%dsa-key-fingerprint dsa sha256) -- cgit v1.2.3