Imported Upstream version 0.63.0
[hcoop/debian/courier-authlib.git] / sha1 / sha1.h
1 #ifndef sha1_h
2 #define sha1_h
3
4 /*
5 ** Copyright 2001-2008 Double Precision, Inc.
6 ** See COPYING for distribution information.
7 */
8
9 static const char sha1_h_rcsid[]="$Id: sha1.h,v 1.6 2008/12/18 12:08:26 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 #define SHA512_DIGEST_SIZE 64
26 #define SHA512_BLOCK_SIZE 128
27
28 typedef SHA1_WORD SHA256_WORD;
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 typedef unsigned char SHA1_DIGEST[20];
35 typedef unsigned char SHA256_DIGEST[32];
36 typedef unsigned char SHA512_DIGEST[64];
37
38 #ifdef SHA1_INTERNAL
39
40 struct SHA1_CONTEXT {
41
42 SHA1_WORD H[5];
43
44 unsigned char blk[SHA1_BLOCK_SIZE];
45 unsigned blk_ptr;
46 } ;
47
48 struct SHA256_CONTEXT {
49
50 SHA256_WORD H[8];
51
52 unsigned char blk[SHA256_BLOCK_SIZE];
53 unsigned blk_ptr;
54 } ;
55
56 struct SHA512_CONTEXT {
57
58 SHA512_WORD H[8];
59
60 unsigned char blk[SHA512_BLOCK_SIZE];
61 unsigned blk_ptr;
62 } ;
63
64 void sha1_context_init(struct SHA1_CONTEXT *);
65 void sha1_context_hash(struct SHA1_CONTEXT *,
66 const unsigned char[SHA1_BLOCK_SIZE]);
67 void sha1_context_hashstream(struct SHA1_CONTEXT *, const void *, unsigned);
68 void sha1_context_endstream(struct SHA1_CONTEXT *, unsigned long);
69 void sha1_context_digest(struct SHA1_CONTEXT *, SHA1_DIGEST);
70 void sha1_context_restore(struct SHA1_CONTEXT *, const SHA1_DIGEST);
71
72 void sha256_context_init(struct SHA256_CONTEXT *);
73 void sha256_context_hash(struct SHA256_CONTEXT *,
74 const unsigned char[SHA256_BLOCK_SIZE]);
75 void sha256_context_hashstream(struct SHA256_CONTEXT *,
76 const void *, unsigned);
77 void sha256_context_endstream(struct SHA256_CONTEXT *, unsigned long);
78 void sha256_context_digest(struct SHA256_CONTEXT *, SHA256_DIGEST);
79 void sha256_context_restore(struct SHA256_CONTEXT *, const SHA256_DIGEST);
80
81 void sha512_context_init(struct SHA512_CONTEXT *);
82 void sha512_context_hash(struct SHA512_CONTEXT *,
83 const unsigned char[SHA512_BLOCK_SIZE]);
84 void sha512_context_hashstream(struct SHA512_CONTEXT *,
85 const void *, unsigned);
86 void sha512_context_endstream(struct SHA512_CONTEXT *, SHA512_WORD);
87 void sha512_context_digest(struct SHA512_CONTEXT *, SHA512_DIGEST);
88 void sha512_context_restore(struct SHA512_CONTEXT *, const SHA512_DIGEST);
89
90 #endif
91
92 void sha1_digest(const void *, unsigned, SHA1_DIGEST);
93 const char *sha1_hash(const char *);
94
95 typedef unsigned char SSHA_RAND[4];
96
97 const char *ssha_hash(const char *, SSHA_RAND);
98
99 void sha256_digest(const void *, unsigned, SHA256_DIGEST);
100
101 const char *sha256_hash(const char *);
102
103 void sha512_digest(const void *, unsigned, SHA512_DIGEST);
104
105 const char *sha512_hash(const char *);
106
107 #ifdef __cplusplus
108 } ;
109 #endif
110
111 #endif