sha1.h 954 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef _SHA1_H
  2. #define _SHA1_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #ifndef _STD_TYPES
  7. #define _STD_TYPES
  8. #define uchar unsigned char
  9. #define uint unsigned int
  10. #define ulong unsigned long int
  11. #endif
  12. typedef struct
  13. {
  14. ulong total[2];
  15. ulong state[5];
  16. uchar buffer[64];
  17. }
  18. sha1_context;
  19. /*
  20. * Core SHA-1 functions
  21. */
  22. void sha1_starts( sha1_context *ctx );
  23. void sha1_update( sha1_context *ctx, uchar *input, uint length );
  24. void sha1_finish( sha1_context *ctx, uchar digest[20] );
  25. /*
  26. * Output SHA-1(file contents), returns 0 if successful.
  27. */
  28. int sha1_file( char *filename, uchar digest[20] );
  29. /*
  30. * Output SHA-1(buf)
  31. */
  32. void sha1_csum( uchar *buf, uint buflen, uchar digest[20] );
  33. /*
  34. * Output HMAC-SHA-1(key,buf)
  35. */
  36. void sha1_hmac( uchar *key, uint keylen, uchar *buf, uint buflen,
  37. uchar digest[20] );
  38. /*
  39. * Checkup routine
  40. */
  41. int sha1_self_test( void );
  42. #ifdef __cplusplus
  43. }
  44. #endif
  45. #endif /* sha1.h */