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