1 /* $OpenBSD: sha1.h,v 1.10 2002/02/16 21:27:17 millert Exp $ */ 2 3 /* 4 * SHA-1 in C 5 * By Steve Reid <steve@edmweb.com> 6 * 100% Public Domain 7 */ 8 9 #ifndef _SHA1_H 10 #define _SHA1_H 11 12 typedef struct { 13 u_int32_t state[5]; 14 u_int32_t count[2]; 15 u_char buffer[64]; 16 } SHA1_CTX; 17 18 void SHA1Transform(u_int32_t state[5], const u_char buffer[64]); 19 void SHA1Init(SHA1_CTX *context); 20 void SHA1Update(SHA1_CTX *context, const u_char *data, u_int len); 21 void SHA1Final(u_char digest[20], SHA1_CTX *context); 22 char *SHA1End(SHA1_CTX *, char *); 23 char *SHA1File(char *, char *); 24 char *SHA1Data(const u_char *, size_t, char *); 25 26 #define SHA1_DIGESTSIZE 20 27 #define SHA1_BLOCKSIZE 64 28 #define HTONDIGEST(x) { \ 29 x[0] = htonl(x[0]); \ 30 x[1] = htonl(x[1]); \ 31 x[2] = htonl(x[2]); \ 32 x[3] = htonl(x[3]); \ 33 x[4] = htonl(x[4]); } 34 35 #define NTOHDIGEST(x) { \ 36 x[0] = ntohl(x[0]); \ 37 x[1] = ntohl(x[1]); \ 38 x[2] = ntohl(x[2]); \ 39 x[3] = ntohl(x[3]); \ 40 x[4] = ntohl(x[4]); } 41 42 #endif /* _SHA1_H */ 43