From 7cf6460add07baab255155f105f3a37aa71a0f69 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Wed, 27 Jun 2018 09:18:21 +0100 Subject: [PATCH] zone.lisp: Maintain `:sshfp' fingerprints in binary internally. This means that we can format them with line splitting, which is good. --- zone.lisp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/zone.lisp b/zone.lisp index 2267026..96cddfb 100644 --- a/zone.lisp +++ b/zone.lisp @@ -946,26 +946,23 @@ (= (length words) 4)) (error "Invalid SSHFP record.")) (pop words) - (destructuring-bind (alg type fpr) words + (destructuring-bind (alg type fprhex) words (rec :data (list (parse-integer alg) (parse-integer type) - fpr)))))))) + (decode-hex fprhex))))))))) (t (dolist (item (listify data)) - (destructuring-bind (fpr &key (alg 'rsa) (type 'sha-1)) + (destructuring-bind (fprhex &key (alg 'rsa) (type 'sha-1)) (listify item) (rec :data (list (lookup-enum alg 'sshfp-algorithm :min 0 :max 255) (lookup-enum type 'sshfp-type :min 0 :max 255) - fpr))))))) + (decode-hex fprhex)))))))) (defmethod zone-record-rrdata ((type (eql :sshfp)) zr) (destructuring-bind (alg type fpr) (zr-data zr) (rec-u8 alg) (rec-u8 type) - (do ((i 0 (+ i 2)) - (n (length fpr))) - ((>= i n)) - (rec-u8 (parse-integer fpr :start i :end (+ i 2) :radix 16)))) + (rec-octet-vector fpr)) 44) (defenum tlsa-usage () @@ -1632,7 +1629,9 @@ $TTL ~2@*~D~2%" prio weight port (bind-hostname host)))) (defmethod zone-write-record ((format (eql :bind)) (type (eql :sshfp)) zr) - (bind-format-record zr "~{~2D ~2D ~A~}~%" (zr-data zr))) + (destructuring-bind (alg type fpr) (zr-data zr) + (bind-format-record zr "~2D ~2D " alg type) + (bind-write-hex fpr 12))) (defmethod zone-write-record ((format (eql :bind)) (type (eql :tlsa)) zr) (destructuring-bind (usage selector match data) (zr-data zr) -- 2.11.0