mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-28 07:12:30 -05:00
gnupg: Compile regexps only once.
This halves the run time on a large number of subsequent 'gnupg-verify' calls. * guix/gnupg.scm (sigid-rx, goodsig-rx, validsig-rx, expkeysig-rx) (errsig-rx): New variables, lifted from... (gnupg-verify)[status-line->sexp]: ... here.
This commit is contained in:
parent
6a0b9500f9
commit
d8169d05bb
1 changed files with 19 additions and 17 deletions
|
@ -59,6 +59,25 @@ (define %openpgp-key-server
|
||||||
;; unreliable.
|
;; unreliable.
|
||||||
(make-parameter "pool.sks-keyservers.net"))
|
(make-parameter "pool.sks-keyservers.net"))
|
||||||
|
|
||||||
|
;; Regexps for status lines. See file `doc/DETAILS' in GnuPG.
|
||||||
|
|
||||||
|
(define sigid-rx
|
||||||
|
(make-regexp
|
||||||
|
"^\\[GNUPG:\\] SIG_ID ([A-Za-z0-9+/]+) ([[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}) ([[:digit:]]+)"))
|
||||||
|
(define goodsig-rx
|
||||||
|
(make-regexp "^\\[GNUPG:\\] GOODSIG ([[:xdigit:]]+) (.+)$"))
|
||||||
|
(define validsig-rx
|
||||||
|
(make-regexp
|
||||||
|
"^\\[GNUPG:\\] VALIDSIG ([[:xdigit:]]+) ([[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}) ([[:digit:]]+) .*$"))
|
||||||
|
(define expkeysig-rx ; good signature, but expired key
|
||||||
|
(make-regexp "^\\[GNUPG:\\] EXPKEYSIG ([[:xdigit:]]+) (.*)$"))
|
||||||
|
(define errsig-rx
|
||||||
|
;; Note: The fingeprint part (the last element of the line) appeared in
|
||||||
|
;; GnuPG 2.2.7 according to 'doc/DETAILS', and it may be missing.
|
||||||
|
(make-regexp
|
||||||
|
"^\\[GNUPG:\\] ERRSIG ([[:xdigit:]]+) ([^ ]+) ([^ ]+) ([^ ]+) ([[:digit:]]+) ([[:digit:]]+)(.*)"))
|
||||||
|
|
||||||
|
|
||||||
(define* (gnupg-verify sig file
|
(define* (gnupg-verify sig file
|
||||||
#:optional (keyring (current-keyring)))
|
#:optional (keyring (current-keyring)))
|
||||||
"Verify signature SIG for FILE against the keys in KEYRING. All the keys in
|
"Verify signature SIG for FILE against the keys in KEYRING. All the keys in
|
||||||
|
@ -71,23 +90,6 @@ (define (maybe-fingerprint str)
|
||||||
(fpr fpr)))
|
(fpr fpr)))
|
||||||
|
|
||||||
(define (status-line->sexp line)
|
(define (status-line->sexp line)
|
||||||
;; See file `doc/DETAILS' in GnuPG.
|
|
||||||
(define sigid-rx
|
|
||||||
(make-regexp
|
|
||||||
"^\\[GNUPG:\\] SIG_ID ([A-Za-z0-9+/]+) ([[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}) ([[:digit:]]+)"))
|
|
||||||
(define goodsig-rx
|
|
||||||
(make-regexp "^\\[GNUPG:\\] GOODSIG ([[:xdigit:]]+) (.+)$"))
|
|
||||||
(define validsig-rx
|
|
||||||
(make-regexp
|
|
||||||
"^\\[GNUPG:\\] VALIDSIG ([[:xdigit:]]+) ([[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}) ([[:digit:]]+) .*$"))
|
|
||||||
(define expkeysig-rx ; good signature, but expired key
|
|
||||||
(make-regexp "^\\[GNUPG:\\] EXPKEYSIG ([[:xdigit:]]+) (.*)$"))
|
|
||||||
(define errsig-rx
|
|
||||||
;; Note: The fingeprint part (the last element of the line) appeared in
|
|
||||||
;; GnuPG 2.2.7 according to 'doc/DETAILS', and it may be missing.
|
|
||||||
(make-regexp
|
|
||||||
"^\\[GNUPG:\\] ERRSIG ([[:xdigit:]]+) ([^ ]+) ([^ ]+) ([^ ]+) ([[:digit:]]+) ([[:digit:]]+)(.*)"))
|
|
||||||
|
|
||||||
(cond ((regexp-exec sigid-rx line)
|
(cond ((regexp-exec sigid-rx line)
|
||||||
=>
|
=>
|
||||||
(lambda (match)
|
(lambda (match)
|
||||||
|
|
Loading…
Reference in a new issue