[BACK]Return to sha1.h CVS log [TXT][DIR] Up to [local] / src / include

Annotation of src/include/sha1.h, Revision 1.3

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:
1.2       millert    10: #ifndef _SHA1_H
                     11: #define _SHA1_H
                     12:
1.1       millert    13: /* The SHA1 block size and message digest sizes, in bytes */
                     14:
                     15: #define SHA1_BLOCKSIZE   64
                     16: #define SHA1_DIGESTSIZE  20
                     17:
                     18: /* The structure for storing SHA1 info */
                     19:
                     20: typedef struct {
1.3     ! millert    21:        u_int32_t digest[ 5 ];          /* Message digest */
        !            22:        u_int32_t countLo, countHi;     /* 64-bit bit count */
        !            23:        u_int32_t data[ 16 ];           /* SHA1 data buffer */
        !            24: } SHA1_INFO;
1.1       millert    25:
                     26: /* The next def turns on the change to the algorithm introduced by NIST at
                     27:  * the behest of the NSA.  It supposedly corrects a weakness in the original
                     28:  * formulation.  Bruce Schneier described it thus in a posting to the
                     29:  * Cypherpunks mailing list on June 21, 1994 (as told to us by Steve Bellovin):
                     30:  *
                     31:  *     This is the fix to the Secure Hash Standard, NIST FIPS PUB 180:
                     32:  *
                     33:  *          In Section 7 of FIPS 180 (page 9), the line which reads
                     34:  *
                     35:  *          "b) For t=16 to 79 let Wt = Wt-3 XOR Wt-8 XOR Wt-14 XOR
                     36:  *          Wt-16."
                     37:  *
                     38:  *          is to be replaced by
                     39:  *
                     40:  *          "b) For t=16 to 79 let Wt = S1(Wt-3 XOR Wt-8 XOR Wt-14 XOR
                     41:  *          Wt-16)."
                     42:  *
                     43:  *          where S1 is a left circular shift by one bit as defined in
                     44:  *          Section 3 of FIPS 180 (page 6):
                     45:  *
                     46:  *          S1(X) = (X<<1) OR (X>>31).
                     47:  *
                     48:  */
1.2       millert    49: #define NEW_SHA1
1.1       millert    50:
1.3     ! millert    51: void sha1Init __P((SHA1_INFO *));
        !            52: void sha1Transform __P((SHA1_INFO *));
        !            53: void sha1Final __P((SHA1_INFO *));
        !            54: void sha1Update __P((SHA1_INFO *, unsigned char *, int));
1.2       millert    55:
                     56: #endif /* _SHA1_H */