[crypticl-cvs] CVS crypticl/src

tskogan tskogan at common-lisp.net
Sat Jan 6 12:42:11 UTC 2007


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

Modified Files:
	common.lisp 
Log Message:
Adding utils needed by SHA-256.


--- /project/crypticl/cvsroot/crypticl/src/common.lisp	2005/10/01 16:34:44	1.4
+++ /project/crypticl/cvsroot/crypticl/src/common.lisp	2007/01/06 12:42:11	1.5
@@ -104,14 +104,22 @@
   (ldb (byte 32 0) (reduce #'+ args)))
 
 
-(defun 32-left-rot (a by)
+(defun left-rot-32 (a by)
   "Left rotation modulo 32. If number longer than 32 bits, ignore extra bits."
-  (let ((break (- 32 by)))
-    (dpb (ldb (byte break 0) a)
-	 (byte break by)
-	 (ldb (byte by break)
-	      a))))
-
+  (let ((pivot (- 32 by)))
+    (dpb (ldb (byte pivot 0) a)
+	 (byte pivot by)
+	 (ldb (byte by pivot) a))))
+
+(defun right-rot-32 (a by)
+  "Right rotation modulo 32. If number longer than 32 bits, ignore extra bits.
+
+1) Shift the (32 - by) left bits to the right by places
+2) Shift the right by bits all over to the left.
+"
+  (let ((leftpart (- 32 by)))
+    (+ (ash a (- by))
+       (ash (ldb (byte by 0) a) leftpart))))
 
 (defun make-string-reader-function (string)
   "Return a function that reads one byte at a time from a string or nil




More information about the Crypticl-cvs mailing list