mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
g10: Create expiring keys in quick key generation mode.
* doc/gpg.texi: Document that fact. * g10/keygen.c (quick_generate_keypair): Use a default value. * tests/openpgp/quick-key-manipulation.scm: Test that fact. GnuPG-bug-id: 2701 Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
429891a704
commit
dd3dde07a9
3 changed files with 22 additions and 17 deletions
|
@ -27,6 +27,13 @@
|
|||
(define (exact id)
|
||||
(string-append "=" id))
|
||||
|
||||
;; Convenient accessors for the colon output.
|
||||
(define (:length x) (string->number (list-ref x 2)))
|
||||
(define (:alg x) (string->number (list-ref x 3)))
|
||||
(define (:expire x) (list-ref x 6))
|
||||
(define (:fpr x) (list-ref x 9))
|
||||
(define (:cap x) (list-ref x 11))
|
||||
|
||||
(define (count-uids-of-secret-key id)
|
||||
(length (filter (lambda (x) (and (string=? "uid" (car x))
|
||||
(not (string=? "r" (cadr x)))))
|
||||
|
@ -47,10 +54,11 @@
|
|||
(info "Checking quick key generation...")
|
||||
(call-check `(,@GPG --quick-gen-key ,alpha))
|
||||
|
||||
(assert (= 1 (count-uids-of-secret-key alpha)))
|
||||
(define keyinfo (gpg-with-colons `(-k ,(exact alpha))))
|
||||
(define fpr (:fpr (assoc "fpr" keyinfo)))
|
||||
|
||||
(define fpr (list-ref (assoc "fpr" (gpg-with-colons `(-k ,(exact alpha))))
|
||||
9))
|
||||
(assert (= 1 (count-uids-of-secret-key alpha)))
|
||||
(assert (not (equal? "" (:expire (assoc "pub" keyinfo)))))
|
||||
|
||||
(info "Checking that we can add a user ID...")
|
||||
|
||||
|
@ -82,11 +90,10 @@
|
|||
(info "Checking that we can change the expiration time.")
|
||||
|
||||
(define (expiration-time id)
|
||||
(list-ref (assoc "pub" (gpg-with-colons `(-k ,id)))
|
||||
6))
|
||||
(:expire (assoc "pub" (gpg-with-colons `(-k ,id)))))
|
||||
|
||||
;; XXX This assumes that by default keys are created without
|
||||
;; expiration date. See issue2701.
|
||||
;; Remove the expiration date.
|
||||
(call-check `(,@gpg --quick-set-expire ,fpr "0"))
|
||||
(assert (equal? "" (expiration-time fpr)))
|
||||
|
||||
;; Make the key expire in one year.
|
||||
|
@ -94,10 +101,6 @@
|
|||
;; XXX It'd be nice to check that the value is right.
|
||||
(assert (not (equal? "" (expiration-time fpr))))
|
||||
|
||||
;; And remove the expiration date.
|
||||
(call-check `(,@gpg --quick-set-expire ,fpr "0"))
|
||||
(assert (equal? "" (expiration-time fpr)))
|
||||
|
||||
|
||||
;;
|
||||
;; Check --quick-addkey
|
||||
|
@ -111,12 +114,6 @@
|
|||
;; This keeps track of the number of subkeys.
|
||||
(define count (length (get-subkeys)))
|
||||
|
||||
;; Convenient accessors for the colon output.
|
||||
(define (:length x) (string->number (list-ref x 2)))
|
||||
(define (:alg x) (string->number (list-ref x 3)))
|
||||
(define (:expire x) (list-ref x 6))
|
||||
(define (:cap x) (list-ref x 11))
|
||||
|
||||
(for-each-p
|
||||
"Checking that we can add subkeys..."
|
||||
(lambda (args check)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue