[crypticl-cvs] CVS update: crypticl/src/aes.lisp crypticl/src/load.lisp crypticl/src/sha.lisp

Tage Stabell-Kulo tstabell at common-lisp.net
Wed Nov 24 22:54:50 UTC 2004


Update of /project/crypticl/cvsroot/crypticl/src
In directory common-lisp.net:/tmp/cvs-serv16331/src

Modified Files:
	aes.lisp load.lisp sha.lisp 
Log Message:
Changed variable T to tmp and S tom Sbox.

Date: Wed Nov 24 23:54:40 2004
Author: tstabell

Index: crypticl/src/aes.lisp
diff -u crypticl/src/aes.lisp:1.3 crypticl/src/aes.lisp:1.4
--- crypticl/src/aes.lisp:1.3	Sun Nov  7 13:04:17 2004
+++ crypticl/src/aes.lisp	Wed Nov 24 23:54:38 2004
@@ -63,7 +63,7 @@
     57  75 221 124 132 151 162 253  28  36 108 180 199  82 246   1)
     )
 
-(defconstant S
+(defconstant Sbox
   #( 99 124 119 123 242 107 111 197  48   1 103  43 254 215 171 118
    202 130 201 125 250  89  71 240 173 212 162 175 156 164 114 192
    183 253 147  38  54  63 247 204  52 165 229 241 113 216  49  21
@@ -220,7 +220,7 @@
 	 (ROUNDS (get-num-rounds (length key)))
 	 (tk (make-array (list 4 Nk)))
 	 (w (make-array (list (1+ ROUNDS) 4 NB)))
-	 (T 0)
+	 (tmp 0)
 	 (RCpointer 1)
 	 (key (change-key-format key Nk)))
     
@@ -232,17 +232,17 @@
     ;;Copy key into first slot in round key
     (for (col 0 Nk)
 	 (for (row 0 4)
-	      (setf (aref w (floor T NB) row (mod T NB)) (aref tk row col)))
-	 (incf T))
+	      (setf (aref w (floor tmp NB) row (mod tmp NB)) (aref tk row col)))
+	 (incf tmp))
     
     
     ;;Calculate as much round key material as we need. i counts 32 bits words.
-    (while (< T (* (1+ ROUNDS) NB))
+    (while (< tmp (* (1+ ROUNDS) NB))
 	   (for (i 0 4)
 		(setf (aref tk i 0) 
 		  (logxor
 		   (aref tk i 0)
-		   (aref S (aref tk (mod (1+ i) 4) (1- Nk))))))
+		   (aref Sbox (aref tk (mod (1+ i) 4) (1- Nk))))))
 	   
 	   (setf (aref tk 0 0) 
 	     (logxor
@@ -269,7 +269,7 @@
 		    (setf (aref tk i 4)
 		      (logxor
 		       (aref tk i 4)
-		       (aref S (aref tk i 3)))))
+		       (aref Sbox (aref tk i 3)))))
 	       (for (j 5 Nk)
 		    (for (i 0 4)
 			 (setf (aref tk i j)
@@ -280,9 +280,9 @@
 	   ;;Copy values to round key
 	   (for (col 0 Nk)
 		(for (row 0 4)
-		     (setf (aref w (floor T NB) row (mod T NB)) 
+		     (setf (aref w (floor tmp NB) row (mod tmp NB)) 
 		       (aref tk row col)))
-		(incf T)))
+		(incf tmp)))
     w))
 
 	       
@@ -303,14 +303,14 @@
       (add-round-key state rk)
   
       (for (r 1 ROUNDS)
-	   (sub-bytes state S)
+	   (sub-bytes state Sbox)
 	   (shift-rows state t)
 	   (mix-columns state)
 	   (fill-rk r)
 	   (add-round-key state rk))
       
       ;;Last round is special. No mix-columns
-      (sub-bytes state S)
+      (sub-bytes state Sbox)
       (shift-rows state t)
       (fill-rk ROUNDS)
       (add-round-key state rk))))


Index: crypticl/src/load.lisp
diff -u crypticl/src/load.lisp:1.4 crypticl/src/load.lisp:1.5
--- crypticl/src/load.lisp:1.4	Sun Nov 14 20:56:29 2004
+++ crypticl/src/load.lisp	Wed Nov 24 23:54:38 2004
@@ -9,6 +9,10 @@
 ;;;; Author: Tåle Skogan <tasko at frisurf.no>
 ;;;; Distribution:  See the accompanying file LICENSE.
 
+;;To-do:
+;;-port this to non-Allegro lisps.  excl: is Allegro spesific.  Clisp 
+;; chokes on the Norwegian charachter in Tåle (above).
+
 (in-package cl-user)
 
 ;;(proclaim '(optimize (speed 2) (safety 1) (space 1) (debug 3)))


Index: crypticl/src/sha.lisp
diff -u crypticl/src/sha.lisp:1.2 crypticl/src/sha.lisp:1.3
--- crypticl/src/sha.lisp:1.2	Sun Nov  7 01:17:35 2004
+++ crypticl/src/sha.lisp	Wed Nov 24 23:54:38 2004
@@ -47,6 +47,16 @@
   (values (ldb (byte 32 32) message-length-in-bits)
 	  (ldb (byte 32 0) message-length-in-bits)))
 
+(defun new-sha1-length64 (mess-len octet-vector start)
+  "Returns octet-vector after the interger mess-len has been encoded as eight bytes, high order bits first, starting at start"
+  (do ((char 56 (- char 8)))
+      ((> 0 char) 
+       octet-vector)
+    (setf (aref octet-vector start)
+      (ldb (byte 8 char) mess-len))
+    (incf start)))
+
+
 
 (defun sha-function-1 (x y z)
   (logior (logand x y)(logand (lognot x) z) ))
@@ -372,7 +382,7 @@
 		"84983e441c3bd26ebaae4aa1f95129e5e54670f1")
 	  (list #300(2 2 2)
 		"e697e7834a688d2c982003a312da660a17a0fc9d"))))
-
+    (format t "Testing SHA-1.~%")
     (dolist (x test-list (format t "Short vectors OK.~%"))
       (let ((in (first x))
 	    (ex (second x)))





More information about the Crypticl-cvs mailing list