Skip to content

Commit 309a47d

Browse files
committed
Move :cert-signature decode/encode methods into a more appropriate file
1 parent 6d56b18 commit 309a47d

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

src/cert-key.lisp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -197,26 +197,6 @@ Please refer to [1] for more details.
197197
(rfc4251:encode :string "" s))
198198
(rfc4251:encode :buffer (rfc4251:get-binary-stream-bytes s) stream)))
199199

200-
(defmethod rfc4251:decode ((type (eql :cert-signature)) stream &key)
201-
"Decode certificate key signature"
202-
(let* ((type-data (multiple-value-list (rfc4251:decode :string stream)))
203-
(blob-data (multiple-value-list (rfc4251:decode :buffer stream)))
204-
(type (first type-data))
205-
(blob (first blob-data))
206-
(total (+ (second type-data) (second blob-data)))
207-
(signature-type (get-signature-type-or-lose type))
208-
(signature (make-instance 'signature
209-
:type signature-type
210-
:blob blob)))
211-
(values signature total)))
212-
213-
(defmethod rfc4251:encode ((type (eql :cert-signature)) (value signature) stream &key)
214-
"Encode certificate signature into the given stream"
215-
(with-accessors ((type signature-type) (blob signature-blob)) value
216-
(let ((type-name (getf type :name)))
217-
(+ (rfc4251:encode :string type-name stream)
218-
(rfc4251:encode :buffer blob stream)))))
219-
220200
(defclass certificate (base-public-key)
221201
((nonce
222202
:initarg :nonce

src/signature.lisp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,24 @@
7070
:initform (error "Must specify signature blob")
7171
:documentation "Computed signature blob"))
7272
(:documentation "Certificate signature"))
73+
74+
75+
(defmethod rfc4251:decode ((type (eql :cert-signature)) stream &key)
76+
"Decode certificate key signature from the given binary stream"
77+
(let* ((type-data (multiple-value-list (rfc4251:decode :string stream)))
78+
(blob-data (multiple-value-list (rfc4251:decode :buffer stream)))
79+
(type (first type-data))
80+
(blob (first blob-data))
81+
(total (+ (second type-data) (second blob-data)))
82+
(signature-type (get-signature-type-or-lose type))
83+
(signature (make-instance 'signature
84+
:type signature-type
85+
:blob blob)))
86+
(values signature total)))
87+
88+
(defmethod rfc4251:encode ((type (eql :cert-signature)) (value signature) stream &key)
89+
"Encode certificate signature into the given stream"
90+
(with-accessors ((type signature-type) (blob signature-blob)) value
91+
(let ((type-name (getf type :name)))
92+
(+ (rfc4251:encode :string type-name stream)
93+
(rfc4251:encode :buffer blob stream)))))

0 commit comments

Comments
 (0)