Annotation of src/include/sha1.h, Revision 1.1
1.1 ! millert 1: /* --------------------------------- SHA1.H ------------------------------- */
! 2:
! 3: /* NIST proposed Secure Hash Standard.
! 4:
! 5: Written 2 September 1992, Peter C. Gutmann.
! 6: This implementation placed in the public domain.
! 7:
! 8: Comments to pgut1@cs.aukuni.ac.nz */
! 9:
! 10: /* Useful defines/typedefs */
! 11:
! 12: typedef unsigned char BYTE;
! 13: typedef u_int32_t LONG;
! 14:
! 15: /* The SHA1 block size and message digest sizes, in bytes */
! 16:
! 17: #define SHA1_BLOCKSIZE 64
! 18: #define SHA1_DIGESTSIZE 20
! 19:
! 20: /* The structure for storing SHA1 info */
! 21:
! 22: typedef struct {
! 23: LONG digest[ 5 ]; /* Message digest */
! 24: LONG countLo, countHi; /* 64-bit bit count */
! 25: LONG data[ 16 ]; /* SHA1 data buffer */
! 26: } SHA1_INFO;
! 27:
! 28: /* The next def turns on the change to the algorithm introduced by NIST at
! 29: * the behest of the NSA. It supposedly corrects a weakness in the original
! 30: * formulation. Bruce Schneier described it thus in a posting to the
! 31: * Cypherpunks mailing list on June 21, 1994 (as told to us by Steve Bellovin):
! 32: *
! 33: * This is the fix to the Secure Hash Standard, NIST FIPS PUB 180:
! 34: *
! 35: * In Section 7 of FIPS 180 (page 9), the line which reads
! 36: *
! 37: * "b) For t=16 to 79 let Wt = Wt-3 XOR Wt-8 XOR Wt-14 XOR
! 38: * Wt-16."
! 39: *
! 40: * is to be replaced by
! 41: *
! 42: * "b) For t=16 to 79 let Wt = S1(Wt-3 XOR Wt-8 XOR Wt-14 XOR
! 43: * Wt-16)."
! 44: *
! 45: * where S1 is a left circular shift by one bit as defined in
! 46: * Section 3 of FIPS 180 (page 6):
! 47: *
! 48: * S1(X) = (X<<1) OR (X>>31).
! 49: *
! 50: */
! 51:
! 52: #define NEW_SHA1