cl-rw

Layered streams for Common Lisp
git clone https://logand.com/git/cl-rw.git/
Log | Files | Refs

commit cbf95e3f4a7622c66e4b4b95c19e66a0adc222ba
parent 6ebd3cbd560dd4397cdfcb9c43485e82ef2ed1cc
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sun, 19 Oct 2014 17:05:03 +0200

dont use dotted lists for convenience

Diffstat:
Mder.lisp | 60++++++++++++++++++++++++++++++------------------------------
1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/der.lisp b/der.lisp @@ -89,7 +89,7 @@ ;; primitive (1 ;; boolean (assert (eql 1 (rw:next-u8 reader))) - (cons 'boolean (ecase (rw:next-u8 reader) (0 nil) (255 t)))) + (list 'boolean (ecase (rw:next-u8 reader) (0 nil) (255 t)))) (2 ;; integer (let ((n (len))) (assert (plusp n)) @@ -104,7 +104,7 @@ (let ((m (rw:next-u8 reader)) (z 0)) ;; TODO as octet string? - (dotimes (i (1- n) (cons 'bit-string (cons m (ash z (- m))))) + (dotimes (i (1- n) (list 'bit-string m (ash z (- m)))) (setq z (logior (ash z 8) (rw:next-u8 reader))))))) (4 ;; octet-string ;; TODO variant with bounds @@ -147,18 +147,18 @@ (z (make-array n :element-type '(unsigned-byte 8) :initial-element 0))) - (dotimes (i n (cons 'utf8string (octets-to-utf8-string z))) + (dotimes (i n (list 'utf8string (octets-to-utf8-string z))) (setf (aref z i) (rw:next-u8 reader))))) (19 ;; printablestring - (cons 'printable-string (ascii))) + (list 'printable-string (ascii))) #+nil (20 ;; t61string TeletexString #x14 (let* ((n (rw:next-u8 reader)) (z (make-string n))) - (dotimes (i n (cons 't61string z)) + (dotimes (i n (list 't61string z)) (setf (char z i) (code-char (rw:next-u8 reader)))))) (22 ;; ia5string - (cons 'ia5string (ascii))) + (list 'ia5string (ascii))) (23 ;; utctime ;; YYMMDDhhmmZ ;; YYMMDDhhmm+hh'mm' @@ -166,7 +166,7 @@ ;; YYMMDDhhmmssZ ;; YYMMDDhhmmss+hh'mm' ;; YYMMDDhhmmss-hh'mm' - (cons 'utctime (ascii))) + (list 'utctime (ascii))) #+nil (30 ;; BMPString #x1e ) @@ -179,14 +179,14 @@ (49 ;; SET #x31 (cons 'set (decode (rw:shorter-reader reader (len))))) (80 - (cons '???-key-identifier + (list '???-key-identifier (decode (rw:shorter-reader reader (len))))) (160 ;; ??? crl-extensions signed certificate version #xa0 ;; (int inside) 2 = signed certificate v3 - (cons '???-signed-certificate-version + (list '???-signed-certificate-version (decode (rw:shorter-reader reader (len))))) (163 ;; ??? signed certificate extensions #xa3 - (cons '???-signed-certificate-extensions + (list '???-signed-certificate-extensions (decode (rw:shorter-reader reader (len))))) ;; ;;;;;;;;;; #+nil @@ -257,11 +257,11 @@ (boolean (rw:write-u8 writer 1) (rw:write-u8 writer 1) - (rw:write-u8 writer (if (cdr x) 255 0))) + (rw:write-u8 writer (if (cadr x) 255 0))) (bit-string (rw:write-u8 writer 3) (let* ((m (cadr x)) - (x (ash (cddr x) m)) + (x (ash (caddr x) m)) (nbytes (ceiling (log x 256)))) (len (+ 1 nbytes)) (rw:write-u8 writer m) @@ -290,7 +290,7 @@ do (rw:write-u8 writer x)))) (utf8string (rw:write-u8 writer 12) - (let ((x (utf8-string-to-octets (cdr x)))) + (let ((x (utf8-string-to-octets (cadr x)))) (len (length x)) (loop for x across x @@ -299,27 +299,27 @@ ;;(set 17) (printable-string (rw:write-u8 writer 19) - (ascii (cdr x))) + (ascii (cadr x))) ;;(t61string 20) (ia5string (rw:write-u8 writer 22) - (ascii (cdr x))) + (ascii (cadr x))) (utctime (rw:write-u8 writer 23) - (ascii (cdr x))) + (ascii (cadr x))) (set (rw:write-u8 writer 49) (seq (list (cdr x)))) (???-key-identifier (rw:write-u8 writer 80) - (seq (list (cdr x)))) + (seq (list (cadr x)))) (???-signed-certificate-version (rw:write-u8 writer 160) ;; (int inside) 2 = signed certificate v3 - (seq (list (cdr x)))) + (seq (list (cadr x)))) (???-signed-certificate-extensions (rw:write-u8 writer 163) - (seq (list (cdr x)))) + (seq (list (cadr x)))) (t ;; sequence (rw:write-u8 writer 48) (seq x))))))) @@ -332,18 +332,18 @@ (-129 (2 2 #xff #x7f)) (128 (2 2 0 #x80)) (256 (2 2 1 0)) - ((utctime . "910506234540Z") + ((utctime "910506234540Z") (#x17 #x0d #x39 #x31 #x30 #x35 #x30 #x36 #x32 #x33 #x34 #x35 #x34 #x30 #x5a)) - ((utctime . "910506164540-0700") + ((utctime "910506164540-0700") (#x17 #x11 #x39 #x31 #x30 #x35 #x30 #x36 #x31 #x36 #x34 #x35 #x34 #x30 #x2D #x30 #x37 #x30 #x30)) - ((ia5string . "test1@rsa.com") + ((ia5string "test1@rsa.com") (#x16 #x0d #x74 #x65 #x73 #x74 #x31 #x40 #x72 #x73 #x61 #x2e #x63 #x6f #x6d)) (#(1 #x23 #x45 #x67 #x89 #xab #xcd #xef) (4 8 1 #x23 #x45 #x67 #x89 #xab #xcd #xef)) - ;;(#x1b977 . (3 4 6 #x6e #x5d #xc0)) + ;;(#x1b977 (3 4 6 #x6e #x5d #xc0)) ;; ("cl'es publiques" ;; (#x14 #x0f #x63 #x6c #xc2 #x65 #x73 #x20 #x70 #x75 #x62 #x6c #x69 #x71 ;; #x75 #x65 #x73)) @@ -351,17 +351,17 @@ (6 9 #x2b 6 1 4 1 #x82 #x37 #x15 #x14)) ((oid 1 2 840 113549 1 1 1) (6 9 #x2a #x86 #x48 #x86 #xf7 #x0d 1 1 1)) - ((printable-string . "TestCN") + ((printable-string "TestCN") (#x13 6 #x54 #x65 #x73 #x74 #x43 #x4e)) - ((utf8string . "certreq") + ((utf8string "certreq") (#x0c 7 #x63 #x65 #x72 #x74 #x72 #x65 #x71)) ((-128 (oid 1 3 6 1 4 1 311 21 20)) (48 14 2 1 #x80 6 9 #x2b 6 1 4 1 #x82 #x37 #x15 #x14)) ((set -128 (oid 1 3 6 1 4 1 311 21 20)) (49 16 48 14 2 1 #x80 6 9 #x2b 6 1 4 1 #x82 #x37 #x15 #x14)) - ((bit-string 7 . #x12345) + ((bit-string 7 #x12345) (3 4 7 145 162 128)) - ((bit-string 0 . 2698675166254423367516254728464483749335066557673396396108386839514779489334034500324580997831747386071008453389756292324108345979589057920899409611221513386337727594567671688384339497590058060942411175326729608798043193698773547875145474433044091370658538092792546412868245105307028798977746453087673869761039285801616342559358044930049) + ((bit-string 0 2698675166254423367516254728464483749335066557673396396108386839514779489334034500324580997831747386071008453389756292324108345979589057920899409611221513386337727594567671688384339497590058060942411175326729608798043193698773547875145474433044091370658538092792546412868245105307028798977746453087673869761039285801616342559358044930049) (3 129 141 0 48 129 137 2 129 129 0 190 108 252 172 88 61 44 244 2 196 54 234 121 210 210 109 187 113 178 18 221 62 24 169 233 140 184 208 68 149 157 121 142 @@ -370,7 +370,7 @@ 42 90 233 119 5 180 145 138 55 114 178 56 28 117 191 40 208 75 167 181 49 36 201 14 178 137 153 55 95 175 220 201 180 9 124 38 129 234 159 152 83 53 138 75 187 159 227 220 197 148 150 3 101 147 2 3 1 0 1)) - ((bit-string 0 . 118034060124092381042289152588939068226888691459037221227696280629223206095830260576779540892200452501272518674360944045140270719338674600852168851119591300542021466662967353378826595297215969104790405581663753704791058639429297119582166792869070820194273847407288579294634063908956456813605370210920536000302) + ((bit-string 0 118034060124092381042289152588939068226888691459037221227696280629223206095830260576779540892200452501272518674360944045140270719338674600852168851119591300542021466662967353378826595297215969104790405581663753704791058639429297119582166792869070820194273847407288579294634063908956456813605370210920536000302) (3 129 129 0 168 22 9 103 226 192 63 113 163 84 253 199 177 202 0 36 253 22 43 188 146 85 229 191 251 36 223 176 216 103 195 166 18 84 153 187 248 65 159 @@ -405,7 +405,7 @@ #\P #\R #\I #\V #\A #\T #\E #\space #\K #\E #\Y #\- #\- #\- #\- #\-)) - (prog1 (cons 'private-key (decode (rw.base64:decode-reader reader))) + (prog1 (list 'private-key (decode (rw.base64:decode-reader reader))) ;;(rw:till (rw:peek-reader (rw.base64:decode-reader reader))) (rw:skip reader) (assert @@ -421,7 +421,7 @@ #\B #\E #\G #\I #\N #\space #\C #\E #\R #\T #\I #\F #\I #\C #\A #\T #\E #\- #\- #\- #\- #\-)) - (prog1 (cons 'certificate (decode (rw.base64:decode-reader reader))) + (prog1 (list 'certificate (decode (rw.base64:decode-reader reader))) ;;(rw:till (rw:peek-reader (rw.base64:decode-reader reader))) (rw:skip reader) (assert