]> jfr.im git - irc/quakenet/newserv.git/blob - lib/sha1.h
A4STATS: remove E style escapes and switch to createtable for indices
[irc/quakenet/newserv.git] / lib / sha1.h
1 /* $OpenBSD: sha1.h,v 1.16 2004/01/22 21:48:02 espie 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 #include <sys/types.h>
13
14 typedef struct {
15 u_int32_t state[5];
16 u_int32_t count[2];
17 unsigned char buffer[64];
18 } SHA1_CTX;
19
20 #include <sys/cdefs.h>
21
22 __BEGIN_DECLS
23 void SHA1Transform(u_int32_t [5], const unsigned char [64]);
24 void SHA1Init(SHA1_CTX *);
25 void SHA1Update(SHA1_CTX *, const unsigned char *, unsigned int);
26 void SHA1Final(unsigned char [20], SHA1_CTX *);
27 char *SHA1End(SHA1_CTX *, char *);
28 char *SHA1File(char *, char *);
29 char *SHA1Data(const unsigned char *, size_t, char *);
30 __END_DECLS
31
32 #define SHA1_DIGESTSIZE 20
33 #define SHA1_BLOCKSIZE 64
34 #define HTONDIGEST(x) do { \
35 x[0] = htonl(x[0]); \
36 x[1] = htonl(x[1]); \
37 x[2] = htonl(x[2]); \
38 x[3] = htonl(x[3]); \
39 x[4] = htonl(x[4]); } while (0)
40
41 #define NTOHDIGEST(x) do { \
42 x[0] = ntohl(x[0]); \
43 x[1] = ntohl(x[1]); \
44 x[2] = ntohl(x[2]); \
45 x[3] = ntohl(x[3]); \
46 x[4] = ntohl(x[4]); } while (0)
47
48 #endif /* _SHA1_H */