Update of /project/crypticl/cvsroot/crypticl/src In directory clnet:/tmp/cvs-serv24715
Modified Files: sha256.lisp Log Message: The six logical functions.
--- /project/crypticl/cvsroot/crypticl/src/sha256.lisp 2007/01/06 12:58:08 1.1 +++ /project/crypticl/cvsroot/crypticl/src/sha256.lisp 2007/01/06 13:46:37 1.2 @@ -50,6 +50,33 @@ ;;; SHA-256 uses six logical functions, where each function operates on 32-bit ;;; words, which are represented as x, y, and z. The result of each function ;;; is a new 32-bit word. +;;; +;;; Note on notation in the docstrings: +;;; not is a bitwise not operation, also referred to as the complement +;;; operation. +(defun ch-256 (x y z) + "(x and y) xor (not x and z)" + (logxor (logand x y) + (logand (lognot x) z))) + +(defun maj-256 (x y z) + "(x and y) xor (x and z) xor (y and z)" + (logxor (logand x y) + (logand x z) + (logand y z))) + +(defun sum-0 (x) + "ROTR 2(x) xor ROTR 13(x) xor ROTR 22(x)" + (logxor (right-rot-32 x 2) + (right-rot-32 x 13) + (right-rot-32 x 22))) + +(defun sum-1 (x) + "ROTR 6(x) xor ROTR 11(x) xor ROTR 25(x)" + (logxor (right-rot-32 x 6) + (right-rot-32 x 11) + (right-rot-32 x 25))) + (defun sigma-0 (x) "ROTR 7(x) xor ROTR 18(x) xor SHR 3(x)" (logxor (right-rot-32 x 7)