[crypticl-cvs] CVS crypticl/src

tskogan tskogan at common-lisp.net
Sun Feb 4 21:12:58 UTC 2007


Update of /project/crypticl/cvsroot/crypticl/src
In directory clnet:/tmp/cvs-serv25425

Modified Files:
	aes.lisp 
Log Message:
Remove debug cruft.


--- /project/crypticl/cvsroot/crypticl/src/aes.lisp	2007/02/04 21:00:58	1.11
+++ /project/crypticl/cvsroot/crypticl/src/aes.lisp	2007/02/04 21:12:58	1.12
@@ -210,12 +210,6 @@
 	      (setf (aref block j i) (aref data k))
 	      (incf k)))))
 
-(defun foo ()
-  (let ((o (make-AES))
-        (key  (generate-key 'AES 256)))
-    (init-encrypt o key :iv #24(1))
-    (encrypt o #(0 1 2))))
-
 (defun copy-array-3d-fixed (dst src fixed row col)
   "Copy from 3D fixed*row*col src to row*col dst array."
   (for (i 0 row)
@@ -330,7 +324,7 @@
         (256-key (hexo "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"))
         words)
     (declare (ignore 256-key))
-    (setf words (aes-key-expansion key))    
+    (setf words (aes-key-expansion key :debug t))    
     (for (i 0 (/ (length words) 4))
          (format t "word ~,2R: ~A~%" i (hex-word words i)))))
 	       
@@ -928,13 +922,19 @@
 
 (defun aes-test-cbc (key pt ct iv &optional count)
   "Input as hex strings"
-  (let ((KEY (hexo key))
-        (PT (hexo pt))
-        (CT (make-byte-array 16))
-        (CV (hexo iv)))                 ; chaining value
+  (let* ((KEY (hexo key))
+         (PT (hexo pt))
+         (CT (make-byte-array 16))
+         (CV (hexo iv))
+         ;; Don't compute round key more than once
+         (num-rounds (get-num-rounds (length KEY)))
+         (round-key (aes-key-expansion KEY)))
+    
     (dotimes (j 10000)
-      (xor-array PT CV)                 ; xor with iv
-      (aes-encrypt-octet-vector PT KEY 'ecb)
+      (xor-array PT CV)                 ; xor with iv      
+      (aes-ecb-mode PT round-key num-rounds t)
+      ;;(aes-encrypt-octet-vector PT KEY 'ecb)
+      
       ;; PT is now encrypted (= CT)
       (acopy PT :out CT)
       ;; next plaintext is previous cipher text which




More information about the Crypticl-cvs mailing list