Ask help for using IRONCLAD package
Hello, Nathan FroydI'm a young Lisp programmer from China. I wrote a SNMP (RFC3412) client package [1] for Common Lisp, some of the SNMPv3 (authentication and privacy) is based on you IRONCLAD package. My package only support LispWorks now.
I met some issue about using DES-CBC encrypt & decrypt function, follow is my test code:
(defparameter *encrypted-data*
#(#x9f #xfd #x95 #xf2 #x78 #x15 #x51 #x58 #x1e #xab #xee #x20 #x89 #x17 #xc6 #x18
#xee #x3f #xe9 #xf0 #xa1 #x81 #xb0 #x9b #x40 #x21 #xfc #x9c #xb3 #xe5 #xef #xd5
#xff #x7b #x47 #xfe #x1d #xc8 #xc9 #x9e #x94 #xd0 #x88 #x3f #xb2 #x7c #xaf #x6f))
(defparameter *iv*
(concatenate '(simple-array (unsigned-byte 8) (*))
(mapcar #'logxor '(#x00 #x00 #x00 #x01 #x31 #xba #x81 #x87)
'(#x5c #x26 #xfa #xc3 #x8d #x72 #x47 #x12))))
(defparameter *key*
(concatenate '(simple-array (unsigned-byte 8) (*))
#(#xf3 #xd8 #xbe #xae #xb1 #x84 #xf2 #xb0)))
(defun priv-test ()
(let ((cipher (ironclad:make-cipher :des
:mode :cbc
:key *key*
:initialization-vector *iv*))
(data (copy-seq *encrypted-data*)))
(format t "~X~%" data)
(ironclad:encrypt-in-place cipher data)
(format t "~X~%" data)
(ironclad:decrypt-in-place cipher data)
(format t "~X~%" data)))
And this is the running result:
SNMP 26 > (priv-test)
#(9F FD 95 F2 78 15 51 58 1E AB EE 20 89 17 C6 18 EE 3F E9 F0 A1 81 B0 9B 40 21 FC 9C B3 E5
EF D5 FF 7B 47 FE 1D C8 C9 9E 94 D0 88 3F B2 7C AF 6F)
#(DF 1C D E4 97 FE 35 CF 9A 4E 6 80 FF FF 39 F0 8C 76 D9 B7 C 20 39 46 C7 F 0 F 18 A0 41 D5
2F D6 C4 18 72 49 70 36 13 8A E2 83 99 7F B8 98)
#(D0 51 8D B3 5D A2 2F 55 1E AB EE 20 89 17 C6 18 EE 3F E9 F0 A1 81 B0 9B 40 21 FC 9C B3 E5
EF D5 FF 7B 47 FE 1D C8 C9 9E 94 D0 88 3F B2 7C AF 6F)
NIL
This is my problem: the *encrypted-data*'s first 8 octets is changed when I encrypt and decrypt it!
Is this a bug of ironclad or my mistake when use it?
Thank you very much!
Chun TIAN (binghe)
[1] cl-net-snmp, http://sourceforge.net/projects/cl-net-snmp