Source code pulled from OpenBSD for OpenNTPD. The place to contribute to this code is via the OpenBSD CVS tree.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.6 KiB

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