From b835e158d51c873a99367afd27f3d57cfe92e10e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 30 Apr 2020 15:56:54 +0200 Subject: 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 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'guix/openpgp.scm') diff --git a/guix/openpgp.scm b/guix/openpgp.scm index 987660fa29..2b2997dcd4 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) @@ -1067,3 +1068,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)))) -- cgit v1.2.3