[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
08/12: openpgp: Add 'string->openpgp-packet'.
From: |
guix-commits |
Subject: |
08/12: openpgp: Add 'string->openpgp-packet'. |
Date: |
Fri, 1 May 2020 12:46:18 -0400 (EDT) |
civodul pushed a commit to branch wip-openpgp
in repository guix.
commit 616c000c9a9e78443439bb29b7c5eb56779374c9
Author: Ludovic Courtès <address@hidden>
AuthorDate: Thu Apr 30 15:56:54 2020 +0200
openpgp: Add 'string->openpgp-packet'.
* guix/openpgp.scm (string->openpgp-packet): New procedure.
* tests/openpgp.scm ("verify-openpgp-signature, missing key")
("verify-openpgp-signature, good signatures")
("verify-openpgp-signature, bad signature"): Use it.
---
guix/openpgp.scm | 9 ++++++++-
tests/openpgp.scm | 15 +++------------
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/guix/openpgp.scm b/guix/openpgp.scm
index 26ca90a..1887504 100644
--- a/guix/openpgp.scm
+++ b/guix/openpgp.scm
@@ -55,7 +55,8 @@
lookup-key-by-fingerprint
get-openpgp-keyring
- read-radix-64)
+ read-radix-64
+ string->openpgp-packet)
#:use-module (rnrs bytevectors)
#:use-module (rnrs io ports)
#:use-module (srfi srfi-1)
@@ -1080,3 +1081,9 @@ end-of-file object if the Radix-64 sequence was
truncated."
(values #f kind)))
(loop (cons str lines))))))))
(values #f #f))))
+
+(define (string->openpgp-packet str)
+ "Read STR, an ASCII-armored OpenPGP packet, and return the corresponding
+OpenPGP record."
+ (get-packet
+ (open-bytevector-input-port (call-with-input-string str read-radix-64))))
diff --git a/tests/openpgp.scm b/tests/openpgp.scm
index a85fe6a..0beab6f 100644
--- a/tests/openpgp.scm
+++ b/tests/openpgp.scm
@@ -194,10 +194,7 @@ Pz7oopeN72xgggYUNT37ezqN3MeCqw0=
(test-equal "verify-openpgp-signature, missing key"
`(missing-key ,%rsa-key-fingerprint)
(let* ((keyring (get-openpgp-keyring (%make-void-port "r")))
- (signature (get-openpgp-packet
- (open-bytevector-input-port
- (call-with-input-string %hello-signature/rsa
- read-radix-64)))))
+ (signature (string->openpgp-packet %hello-signature/rsa)))
(let-values (((status key)
(verify-openpgp-signature signature keyring
(open-input-string "Hello!\n"))))
@@ -214,10 +211,7 @@ Pz7oopeN72xgggYUNT37ezqN3MeCqw0=
(keyring (get-openpgp-keyring
(open-bytevector-input-port
(call-with-input-file key read-radix-64))))
- (signature (get-openpgp-packet
- (open-bytevector-input-port
- (call-with-input-string signature
- read-radix-64)))))
+ (signature (string->openpgp-packet signature)))
(let-values (((status key)
(verify-openpgp-signature signature keyring
(open-input-string
"Hello!\n"))))
@@ -246,10 +240,7 @@ Pz7oopeN72xgggYUNT37ezqN3MeCqw0=
"tests/ed25519.key" "tests/ed25519.key"
"tests/ed25519.key"))))
(map (lambda (signature)
- (let ((signature (get-openpgp-packet
- (open-bytevector-input-port
- (call-with-input-string signature
- read-radix-64)))))
+ (let ((signature (string->openpgp-packet signature)))
(let-values (((status key)
(verify-openpgp-signature signature keyring
(open-input-string
"What?!"))))
- branch wip-openpgp created (now 8916c2f), guix-commits, 2020/05/01
- 01/12: Add '.guix-authorizations'., guix-commits, 2020/05/01
- 02/12: DRAFT Add (guix openpgp)., guix-commits, 2020/05/01
- 04/12: openpgp: Store the issuer key id and fingerprint in <openpgp-signature>., guix-commits, 2020/05/01
- 03/12: openpgp: Decode the issuer-fingerprint signature subpacket., guix-commits, 2020/05/01
- 05/12: openpgp: Add 'lookup-key-by-fingerprint'., guix-commits, 2020/05/01
- 07/12: openpgp: 'lookup-key-by-{id, fingerprint}' return the key first., guix-commits, 2020/05/01
- 09/12: git-authenticate: Use (guix openpgp)., guix-commits, 2020/05/01
- 06/12: openpgp: 'verify-openpgp-signature' looks up by fingerprint when possible., guix-commits, 2020/05/01
- 08/12: openpgp: Add 'string->openpgp-packet'.,
guix-commits <=
- 11/12: git-authenticate: Load the list of authorized keys from the tree., guix-commits, 2020/05/01
- 10/12: .guix-authorizations: Augment., guix-commits, 2020/05/01
- 12/12: git-authenticate: Load the keyring from the repository., guix-commits, 2020/05/01