summaryrefslogtreecommitdiff
path: root/guix/openpgp.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-04-30 15:56:54 +0200
committerLudovic Courtès <ludo@gnu.org>2020-05-04 09:56:13 +0200
commitb835e158d51c873a99367afd27f3d57cfe92e10e (patch)
tree8171de07c5efe95411327208aa7990286aabf69e /guix/openpgp.scm
parentbd8126558dc7a022d7853d803d7134ffa1b7bc52 (diff)
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.
Diffstat (limited to 'guix/openpgp.scm')
-rw-r--r--guix/openpgp.scm9
1 files changed, 8 insertions, 1 deletions
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))))