2
0

sha.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* --------------------------------- SHA.H ------------------------------- */
  2. /*
  3. * NIST Secure Hash Algorithm.
  4. *
  5. * Written 2 September 1992, Peter C. Gutmann.
  6. * This implementation placed in the public domain.
  7. *
  8. * Modified 1 June 1993, Colin Plumb.
  9. * Renamed to SHA and comments updated a bit 1 November 1995, Colin Plumb.
  10. * These modifications placed in the public domain.
  11. *
  12. * Comments to pgut1@cs.aukuni.ac.nz
  13. */
  14. /* Typedefs for various word sizes */
  15. #include "types.h"
  16. /*
  17. * Since 64-bit machines are the wave of the future, we may as well
  18. * support them directly.
  19. */
  20. /* The SHA block size and message digest sizes, in bytes */
  21. #define SHA_BLOCKSIZE 64
  22. #define SHA_DIGESTSIZE 20
  23. /*
  24. * The structure for storing SHA info.
  25. * data[] is placed first in case offsets of 0 are faster
  26. * for some reason; it's the most often accessed field.
  27. */
  28. struct SHAContext {
  29. word32 data[ 16 ]; /* SHA data buffer */
  30. word32 digest[ 5 ]; /* Message digest */
  31. #ifdef HAVE64
  32. word64 count;
  33. #else
  34. word32 countHi, countLo; /* 64-bit byte count */
  35. #endif
  36. };
  37. /* Which standard? FIPS 180 or FIPS 180.1? */
  38. #define SHA_VERSION 1
  39. /* Whether the machine is little-endian or not */
  40. #if !defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
  41. #define BIG_ENDIAN 1
  42. #endif
  43. void shaInit(struct SHAContext *sha);
  44. void shaTransform(struct SHAContext *sha);
  45. void shaUpdate(struct SHAContext *sha, word8 const *buffer, unsigned count);
  46. void shaFinal(struct SHAContext *shaInfo, word8 *hash);