zone.lisp: Maintain `:sshfp' fingerprints in binary internally.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 27 Jun 2018 08:18:21 +0000 (09:18 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 27 Jun 2018 08:18:21 +0000 (09:18 +0100)
This means that we can format them with line splitting, which is good.

zone.lisp

index 2267026..96cddfb 100644 (file)
--- a/zone.lisp
+++ b/zone.lisp
                              (= (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)