Imported upstream version 0.59.3
[hcoop/debian/courier-authlib.git] / sha1 / sha1.h
1 #ifndef sha1_h
2 #define sha1_h
3
4 /*
5 ** Copyright 2001 Double Precision, Inc.
6 ** See COPYING for distribution information.
7 */
8
9 static const char sha1_h_rcsid[]="$Id: sha1.h,v 1.4 2005/02/21 03:18:30 mrsam Exp $";
10
11 #if HAVE_CONFIG_H
12 #include "sha1/config.h"
13 #endif
14
15 #if HAVE_SYS_TYPES_H
16 #include <sys/types.h>
17 #endif
18
19 #define SHA1_DIGEST_SIZE 20
20 #define SHA1_BLOCK_SIZE 64
21
22 #define SHA256_DIGEST_SIZE 32
23 #define SHA256_BLOCK_SIZE 64
24
25 typedef SHA1_WORD SHA256_WORD;
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 typedef unsigned char SHA1_DIGEST[20];
32 typedef unsigned char SHA256_DIGEST[32];
33
34 #ifdef SHA1_INTERNAL
35
36 struct SHA1_CONTEXT {
37
38 SHA1_WORD H[5];
39
40 unsigned char blk[SHA1_BLOCK_SIZE];
41 unsigned blk_ptr;
42 } ;
43
44 struct SHA256_CONTEXT {
45
46 SHA256_WORD H[8];
47
48 unsigned char blk[SHA256_BLOCK_SIZE];
49 unsigned blk_ptr;
50 } ;
51
52 void sha1_context_init(struct SHA1_CONTEXT *);
53 void sha1_context_hash(struct SHA1_CONTEXT *,
54 const unsigned char[SHA1_BLOCK_SIZE]);
55 void sha1_context_hashstream(struct SHA1_CONTEXT *, const void *, unsigned);
56 void sha1_context_endstream(struct SHA1_CONTEXT *, unsigned long);
57 void sha1_context_digest(struct SHA1_CONTEXT *, SHA1_DIGEST);
58 void sha1_context_restore(struct SHA1_CONTEXT *, const SHA1_DIGEST);
59
60 void sha256_context_init(struct SHA256_CONTEXT *);
61 void sha256_context_hash(struct SHA256_CONTEXT *,
62 const unsigned char[SHA256_BLOCK_SIZE]);
63 void sha256_context_hashstream(struct SHA256_CONTEXT *,
64 const void *, unsigned);
65 void sha256_context_endstream(struct SHA256_CONTEXT *, unsigned long);
66 void sha256_context_digest(struct SHA256_CONTEXT *, SHA256_DIGEST);
67 void sha256_context_restore(struct SHA256_CONTEXT *, const SHA256_DIGEST);
68
69 #endif
70
71 void sha1_digest(const void *, unsigned, SHA1_DIGEST);
72 const char *sha1_hash(const char *);
73
74 void sha256_digest(const void *, unsigned, SHA1_DIGEST);
75 const char *sha256_hash(const char *);
76
77 #ifdef __cplusplus
78 } ;
79 #endif
80
81 #endif