Mercurial > dropbear
annotate src/headers/tomcrypt_hash.h @ 380:d5faf4814ddb libtomcrypt-orig libtomcrypt-1.16
Update to LibTomCrypt 1.16
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 11 Jan 2007 02:22:00 +0000 |
parents | 59400faa4b44 |
children |
rev | line source |
---|---|
280
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1 /* ---- HASH FUNCTIONS ---- */ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2 #ifdef SHA512 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
3 struct sha512_state { |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
4 ulong64 length, state[8]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
5 unsigned long curlen; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
6 unsigned char buf[128]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
7 }; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
8 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
9 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
10 #ifdef SHA256 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
11 struct sha256_state { |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
12 ulong64 length; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
13 ulong32 state[8], curlen; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
14 unsigned char buf[64]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
15 }; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
16 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
17 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
18 #ifdef SHA1 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
19 struct sha1_state { |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
20 ulong64 length; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
21 ulong32 state[5], curlen; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
22 unsigned char buf[64]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
23 }; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
24 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
25 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
26 #ifdef MD5 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
27 struct md5_state { |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
28 ulong64 length; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
29 ulong32 state[4], curlen; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
30 unsigned char buf[64]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
31 }; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
32 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
33 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
34 #ifdef MD4 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
35 struct md4_state { |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
36 ulong64 length; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
37 ulong32 state[4], curlen; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
38 unsigned char buf[64]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
39 }; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
40 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
41 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
42 #ifdef TIGER |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
43 struct tiger_state { |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
44 ulong64 state[3], length; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
45 unsigned long curlen; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
46 unsigned char buf[64]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
47 }; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
48 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
49 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
50 #ifdef MD2 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
51 struct md2_state { |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
52 unsigned char chksum[16], X[48], buf[16]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
53 unsigned long curlen; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
54 }; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
55 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
56 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
57 #ifdef RIPEMD128 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
58 struct rmd128_state { |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
59 ulong64 length; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
60 unsigned char buf[64]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
61 ulong32 curlen, state[4]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
62 }; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
63 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
64 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
65 #ifdef RIPEMD160 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
66 struct rmd160_state { |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
67 ulong64 length; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
68 unsigned char buf[64]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
69 ulong32 curlen, state[5]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
70 }; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
71 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
72 |
380 | 73 #ifdef RIPEMD256 |
74 struct rmd256_state { | |
75 ulong64 length; | |
76 unsigned char buf[64]; | |
77 ulong32 curlen, state[8]; | |
78 }; | |
79 #endif | |
80 | |
81 #ifdef RIPEMD320 | |
82 struct rmd320_state { | |
83 ulong64 length; | |
84 unsigned char buf[64]; | |
85 ulong32 curlen, state[10]; | |
86 }; | |
87 #endif | |
88 | |
280
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
89 #ifdef WHIRLPOOL |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
90 struct whirlpool_state { |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
91 ulong64 length, state[8]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
92 unsigned char buf[64]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
93 ulong32 curlen; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
94 }; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
95 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
96 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
97 #ifdef CHC_HASH |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
98 struct chc_state { |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
99 ulong64 length; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
100 unsigned char state[MAXBLOCKSIZE], buf[MAXBLOCKSIZE]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
101 ulong32 curlen; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
102 }; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
103 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
104 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
105 typedef union Hash_state { |
380 | 106 char dummy[1]; |
280
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
107 #ifdef CHC_HASH |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
108 struct chc_state chc; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
109 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
110 #ifdef WHIRLPOOL |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
111 struct whirlpool_state whirlpool; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
112 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
113 #ifdef SHA512 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
114 struct sha512_state sha512; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
115 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
116 #ifdef SHA256 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
117 struct sha256_state sha256; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
118 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
119 #ifdef SHA1 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
120 struct sha1_state sha1; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
121 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
122 #ifdef MD5 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
123 struct md5_state md5; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
124 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
125 #ifdef MD4 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
126 struct md4_state md4; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
127 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
128 #ifdef MD2 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
129 struct md2_state md2; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
130 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
131 #ifdef TIGER |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
132 struct tiger_state tiger; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
133 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
134 #ifdef RIPEMD128 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
135 struct rmd128_state rmd128; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
136 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
137 #ifdef RIPEMD160 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
138 struct rmd160_state rmd160; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
139 #endif |
380 | 140 #ifdef RIPEMD256 |
141 struct rmd256_state rmd256; | |
142 #endif | |
143 #ifdef RIPEMD320 | |
144 struct rmd320_state rmd320; | |
145 #endif | |
280
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
146 void *data; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
147 } hash_state; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
148 |
380 | 149 /** hash descriptor */ |
280
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
150 extern struct ltc_hash_descriptor { |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
151 /** name of hash */ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
152 char *name; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
153 /** internal ID */ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
154 unsigned char ID; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
155 /** Size of digest in octets */ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
156 unsigned long hashsize; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
157 /** Input block size in octets */ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
158 unsigned long blocksize; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
159 /** ASN.1 OID */ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
160 unsigned long OID[16]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
161 /** Length of DER encoding */ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
162 unsigned long OIDlen; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
163 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
164 /** Init a hash state |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
165 @param hash The hash to initialize |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
166 @return CRYPT_OK if successful |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
167 */ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
168 int (*init)(hash_state *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
169 /** Process a block of data |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
170 @param hash The hash state |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
171 @param in The data to hash |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
172 @param inlen The length of the data (octets) |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
173 @return CRYPT_OK if successful |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
174 */ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
175 int (*process)(hash_state *hash, const unsigned char *in, unsigned long inlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
176 /** Produce the digest and store it |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
177 @param hash The hash state |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
178 @param out [out] The destination of the digest |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
179 @return CRYPT_OK if successful |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
180 */ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
181 int (*done)(hash_state *hash, unsigned char *out); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
182 /** Self-test |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
183 @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
184 */ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
185 int (*test)(void); |
380 | 186 |
187 /* accelerated hmac callback: if you need to-do multiple packets just use the generic hmac_memory and provide a hash callback */ | |
188 int (*hmac_block)(const unsigned char *key, unsigned long keylen, | |
189 const unsigned char *in, unsigned long inlen, | |
190 unsigned char *out, unsigned long *outlen); | |
191 | |
280
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
192 } hash_descriptor[]; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
193 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
194 #ifdef CHC_HASH |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
195 int chc_register(int cipher); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
196 int chc_init(hash_state * md); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
197 int chc_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
198 int chc_done(hash_state * md, unsigned char *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
199 int chc_test(void); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
200 extern const struct ltc_hash_descriptor chc_desc; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
201 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
202 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
203 #ifdef WHIRLPOOL |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
204 int whirlpool_init(hash_state * md); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
205 int whirlpool_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
206 int whirlpool_done(hash_state * md, unsigned char *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
207 int whirlpool_test(void); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
208 extern const struct ltc_hash_descriptor whirlpool_desc; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
209 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
210 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
211 #ifdef SHA512 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
212 int sha512_init(hash_state * md); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
213 int sha512_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
214 int sha512_done(hash_state * md, unsigned char *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
215 int sha512_test(void); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
216 extern const struct ltc_hash_descriptor sha512_desc; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
217 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
218 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
219 #ifdef SHA384 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
220 #ifndef SHA512 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
221 #error SHA512 is required for SHA384 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
222 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
223 int sha384_init(hash_state * md); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
224 #define sha384_process sha512_process |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
225 int sha384_done(hash_state * md, unsigned char *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
226 int sha384_test(void); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
227 extern const struct ltc_hash_descriptor sha384_desc; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
228 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
229 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
230 #ifdef SHA256 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
231 int sha256_init(hash_state * md); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
232 int sha256_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
233 int sha256_done(hash_state * md, unsigned char *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
234 int sha256_test(void); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
235 extern const struct ltc_hash_descriptor sha256_desc; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
236 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
237 #ifdef SHA224 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
238 #ifndef SHA256 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
239 #error SHA256 is required for SHA224 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
240 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
241 int sha224_init(hash_state * md); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
242 #define sha224_process sha256_process |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
243 int sha224_done(hash_state * md, unsigned char *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
244 int sha224_test(void); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
245 extern const struct ltc_hash_descriptor sha224_desc; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
246 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
247 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
248 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
249 #ifdef SHA1 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
250 int sha1_init(hash_state * md); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
251 int sha1_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
252 int sha1_done(hash_state * md, unsigned char *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
253 int sha1_test(void); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
254 extern const struct ltc_hash_descriptor sha1_desc; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
255 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
256 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
257 #ifdef MD5 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
258 int md5_init(hash_state * md); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
259 int md5_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
260 int md5_done(hash_state * md, unsigned char *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
261 int md5_test(void); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
262 extern const struct ltc_hash_descriptor md5_desc; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
263 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
264 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
265 #ifdef MD4 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
266 int md4_init(hash_state * md); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
267 int md4_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
268 int md4_done(hash_state * md, unsigned char *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
269 int md4_test(void); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
270 extern const struct ltc_hash_descriptor md4_desc; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
271 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
272 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
273 #ifdef MD2 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
274 int md2_init(hash_state * md); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
275 int md2_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
276 int md2_done(hash_state * md, unsigned char *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
277 int md2_test(void); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
278 extern const struct ltc_hash_descriptor md2_desc; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
279 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
280 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
281 #ifdef TIGER |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
282 int tiger_init(hash_state * md); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
283 int tiger_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
284 int tiger_done(hash_state * md, unsigned char *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
285 int tiger_test(void); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
286 extern const struct ltc_hash_descriptor tiger_desc; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
287 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
288 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
289 #ifdef RIPEMD128 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
290 int rmd128_init(hash_state * md); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
291 int rmd128_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
292 int rmd128_done(hash_state * md, unsigned char *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
293 int rmd128_test(void); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
294 extern const struct ltc_hash_descriptor rmd128_desc; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
295 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
296 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
297 #ifdef RIPEMD160 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
298 int rmd160_init(hash_state * md); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
299 int rmd160_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
300 int rmd160_done(hash_state * md, unsigned char *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
301 int rmd160_test(void); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
302 extern const struct ltc_hash_descriptor rmd160_desc; |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
303 #endif |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
304 |
380 | 305 #ifdef RIPEMD256 |
306 int rmd256_init(hash_state * md); | |
307 int rmd256_process(hash_state * md, const unsigned char *in, unsigned long inlen); | |
308 int rmd256_done(hash_state * md, unsigned char *hash); | |
309 int rmd256_test(void); | |
310 extern const struct ltc_hash_descriptor rmd256_desc; | |
311 #endif | |
312 | |
313 #ifdef RIPEMD320 | |
314 int rmd320_init(hash_state * md); | |
315 int rmd320_process(hash_state * md, const unsigned char *in, unsigned long inlen); | |
316 int rmd320_done(hash_state * md, unsigned char *hash); | |
317 int rmd320_test(void); | |
318 extern const struct ltc_hash_descriptor rmd320_desc; | |
319 #endif | |
320 | |
321 | |
280
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
322 int find_hash(const char *name); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
323 int find_hash_id(unsigned char ID); |
380 | 324 int find_hash_oid(const unsigned long *ID, unsigned long IDlen); |
280
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
325 int find_hash_any(const char *name, int digestlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
326 int register_hash(const struct ltc_hash_descriptor *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
327 int unregister_hash(const struct ltc_hash_descriptor *hash); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
328 int hash_is_valid(int idx); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
329 |
380 | 330 LTC_MUTEX_PROTO(ltc_hash_mutex) |
280
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
331 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
332 int hash_memory(int hash, |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
333 const unsigned char *in, unsigned long inlen, |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
334 unsigned char *out, unsigned long *outlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
335 int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen, |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
336 const unsigned char *in, unsigned long inlen, ...); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
337 int hash_filehandle(int hash, FILE *in, unsigned char *out, unsigned long *outlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
338 int hash_file(int hash, const char *fname, unsigned char *out, unsigned long *outlen); |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
339 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
340 /* a simple macro for making hash "process" functions */ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
341 #define HASH_PROCESS(func_name, compress_name, state_var, block_size) \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
342 int func_name (hash_state * md, const unsigned char *in, unsigned long inlen) \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
343 { \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
344 unsigned long n; \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
345 int err; \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
346 LTC_ARGCHK(md != NULL); \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
347 LTC_ARGCHK(in != NULL); \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
348 if (md-> state_var .curlen > sizeof(md-> state_var .buf)) { \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
349 return CRYPT_INVALID_ARG; \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
350 } \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
351 while (inlen > 0) { \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
352 if (md-> state_var .curlen == 0 && inlen >= block_size) { \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
353 if ((err = compress_name (md, (unsigned char *)in)) != CRYPT_OK) { \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
354 return err; \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
355 } \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
356 md-> state_var .length += block_size * 8; \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
357 in += block_size; \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
358 inlen -= block_size; \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
359 } else { \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
360 n = MIN(inlen, (block_size - md-> state_var .curlen)); \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
361 memcpy(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n); \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
362 md-> state_var .curlen += n; \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
363 in += n; \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
364 inlen -= n; \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
365 if (md-> state_var .curlen == block_size) { \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
366 if ((err = compress_name (md, md-> state_var .buf)) != CRYPT_OK) { \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
367 return err; \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
368 } \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
369 md-> state_var .length += 8*block_size; \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
370 md-> state_var .curlen = 0; \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
371 } \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
372 } \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
373 } \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
374 return CRYPT_OK; \ |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
375 } |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
376 |
59400faa4b44
Re-import libtomcrypt 1.05 for cleaner propagating.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
377 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_hash.h,v $ */ |
380 | 378 /* $Revision: 1.19 $ */ |
379 /* $Date: 2006/11/05 01:36:43 $ */ |