Skip to content

Commit a75710e

Browse files
committed
Allow unrecognized subpacket types.
Per RFC 4880: An implementation SHOULD ignore any subpacket of a type that it does not recognize.
1 parent a55f8b9 commit a75710e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

quicklisp/openpgp.lisp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,16 +456,19 @@ values are decoded; others signal an error. See RFC4880 section 4.3."
456456
DEFINE-FIELD) from PSTREAM."
457457
(funcall (get field 'reader-function 'missing-reader-function) pstream))
458458

459-
(defun read-field-value (field pstream)
459+
(defun read-field-value (field pstream &key (default nil defaultp))
460460
"Read and FIELD from PSTREAM and look up and return its symbolic
461461
value."
462462
(let* ((raw-value (read-field field pstream))
463463
(translation (assoc raw-value (get field 'values-alist))))
464-
(unless translation
464+
(when (and (not translation)
465+
(not defaultp))
465466
(error "Unsupported value ~A for field ~A"
466467
raw-value
467468
field))
468-
(cdr translation)))
469+
(if translation
470+
(cdr translation)
471+
default)))
469472

470473
(define-field signature-type (:type u8)
471474
;; RFC 4880 section 5.2.1
@@ -488,6 +491,7 @@ value."
488491
(22 . :preferred-compression-algorithms)
489492
(23 . :key-server-preferences)
490493
(27 . :key-flags)
494+
(28 . :signer-user-id)
491495
(30 . :features))
492496

493497
(define-field public-key-algorithm (:type u8)
@@ -530,7 +534,8 @@ size, from PSTREAM. See RFC4880 5.2.3.1 for details."
530534
"Read a single signature subpacket from PSTREAM. Returns the packet
531535
type and data as multiple values."
532536
(let* ((length (read-subpacket-length pstream))
533-
(type (read-field-value 'subpacket-type pstream))
537+
(type (read-field-value 'subpacket-type pstream
538+
:default :unrecognized))
534539
(data (read-n-octets (1- length) pstream)))
535540
(values type data)))
536541

0 commit comments

Comments
 (0)