Andreas Krennmair:
[apps/madmutt.git] / sha1.h
1 /*
2  SHA-1 in C
3
4  By Steve Reid <steve@edmweb.com>, with small changes to make it
5  fit into mutt by Thomas Roessler <roessler@does-not-exist.org>.
6
7 */
8
9 #ifndef _SHA1_H
10 # define _SHA1_H
11
12 #include "config.h"
13
14 #include <sys/types.h>
15 #if HAVE_INTTYPES_H
16 # include <inttypes.h>
17 #else
18 # if HAVE_STDINT_H
19 #  include <stdint.h>
20 # endif
21 #endif
22
23 #ifndef HAVE_UINT32_T
24 #  if SIZEOF_INT == 4
25 typedef unsigned int uint32_t;
26 #  elif SIZEOF_LONG == 4
27 typedef unsigned long uint32_t;
28 #  endif
29 #endif
30
31 typedef struct {
32   uint32_t state[5];
33   uint32_t count[2];
34   unsigned char buffer[64];
35 } SHA1_CTX;
36
37 void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
38 void SHA1Init(SHA1_CTX* context);
39 void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len);
40 void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
41
42 # define SHA1_Transform SHA1Transform
43 # define SHA1_Init SHA1Init
44 # define SHA1_Update SHA1Update
45 # define SHA1_Final SHA1Final
46
47 # define SHA_DIGEST_LENGTH 20
48
49 #endif
50