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