comparison libtomcrypt/src/headers/tomcrypt_hash.h @ 1435:f849a5ca2efc

update to libtomcrypt 1.17 (with Dropbear changes)
author Matt Johnston <matt@ucc.asn.au>
date Sat, 24 Jun 2017 17:50:50 +0800
parents 0cbe8f6dbf9e
children 6dba84798cd5
comparison
equal deleted inserted replaced
1434:27b9ddb06b09 1435:f849a5ca2efc
1 /* ---- HASH FUNCTIONS ---- */ 1 /* ---- HASH FUNCTIONS ---- */
2 #ifdef SHA512 2 #ifdef LTC_SHA512
3 struct sha512_state { 3 struct sha512_state {
4 ulong64 length, state[8]; 4 ulong64 length, state[8];
5 unsigned long curlen; 5 unsigned long curlen;
6 unsigned char buf[128]; 6 unsigned char buf[128];
7 }; 7 };
8 #endif 8 #endif
9 9
10 #ifdef SHA256 10 #ifdef LTC_SHA256
11 struct sha256_state { 11 struct sha256_state {
12 ulong64 length; 12 ulong64 length;
13 ulong32 state[8], curlen; 13 ulong32 state[8], curlen;
14 unsigned char buf[64]; 14 unsigned char buf[64];
15 }; 15 };
16 #endif 16 #endif
17 17
18 #ifdef SHA1 18 #ifdef LTC_SHA1
19 struct sha1_state { 19 struct sha1_state {
20 ulong64 length; 20 ulong64 length;
21 ulong32 state[5], curlen; 21 ulong32 state[5], curlen;
22 unsigned char buf[64]; 22 unsigned char buf[64];
23 }; 23 };
24 #endif 24 #endif
25 25
26 #ifdef MD5 26 #ifdef LTC_MD5
27 struct md5_state { 27 struct md5_state {
28 ulong64 length; 28 ulong64 length;
29 ulong32 state[4], curlen; 29 ulong32 state[4], curlen;
30 unsigned char buf[64]; 30 unsigned char buf[64];
31 }; 31 };
32 #endif 32 #endif
33 33
34 #ifdef MD4 34 #ifdef LTC_MD4
35 struct md4_state { 35 struct md4_state {
36 ulong64 length; 36 ulong64 length;
37 ulong32 state[4], curlen; 37 ulong32 state[4], curlen;
38 unsigned char buf[64]; 38 unsigned char buf[64];
39 }; 39 };
40 #endif 40 #endif
41 41
42 #ifdef TIGER 42 #ifdef LTC_TIGER
43 struct tiger_state { 43 struct tiger_state {
44 ulong64 state[3], length; 44 ulong64 state[3], length;
45 unsigned long curlen; 45 unsigned long curlen;
46 unsigned char buf[64]; 46 unsigned char buf[64];
47 }; 47 };
48 #endif 48 #endif
49 49
50 #ifdef MD2 50 #ifdef LTC_MD2
51 struct md2_state { 51 struct md2_state {
52 unsigned char chksum[16], X[48], buf[16]; 52 unsigned char chksum[16], X[48], buf[16];
53 unsigned long curlen; 53 unsigned long curlen;
54 }; 54 };
55 #endif 55 #endif
56 56
57 #ifdef RIPEMD128 57 #ifdef LTC_RIPEMD128
58 struct rmd128_state { 58 struct rmd128_state {
59 ulong64 length; 59 ulong64 length;
60 unsigned char buf[64]; 60 unsigned char buf[64];
61 ulong32 curlen, state[4]; 61 ulong32 curlen, state[4];
62 }; 62 };
63 #endif 63 #endif
64 64
65 #ifdef RIPEMD160 65 #ifdef LTC_RIPEMD160
66 struct rmd160_state { 66 struct rmd160_state {
67 ulong64 length; 67 ulong64 length;
68 unsigned char buf[64]; 68 unsigned char buf[64];
69 ulong32 curlen, state[5]; 69 ulong32 curlen, state[5];
70 }; 70 };
71 #endif 71 #endif
72 72
73 #ifdef RIPEMD256 73 #ifdef LTC_RIPEMD256
74 struct rmd256_state { 74 struct rmd256_state {
75 ulong64 length; 75 ulong64 length;
76 unsigned char buf[64]; 76 unsigned char buf[64];
77 ulong32 curlen, state[8]; 77 ulong32 curlen, state[8];
78 }; 78 };
79 #endif 79 #endif
80 80
81 #ifdef RIPEMD320 81 #ifdef LTC_RIPEMD320
82 struct rmd320_state { 82 struct rmd320_state {
83 ulong64 length; 83 ulong64 length;
84 unsigned char buf[64]; 84 unsigned char buf[64];
85 ulong32 curlen, state[10]; 85 ulong32 curlen, state[10];
86 }; 86 };
87 #endif 87 #endif
88 88
89 #ifdef WHIRLPOOL 89 #ifdef LTC_WHIRLPOOL
90 struct whirlpool_state { 90 struct whirlpool_state {
91 ulong64 length, state[8]; 91 ulong64 length, state[8];
92 unsigned char buf[64]; 92 unsigned char buf[64];
93 ulong32 curlen; 93 ulong32 curlen;
94 }; 94 };
95 #endif 95 #endif
96 96
97 #ifdef CHC_HASH 97 #ifdef LTC_CHC_HASH
98 struct chc_state { 98 struct chc_state {
99 ulong64 length; 99 ulong64 length;
100 unsigned char state[MAXBLOCKSIZE], buf[MAXBLOCKSIZE]; 100 unsigned char state[MAXBLOCKSIZE], buf[MAXBLOCKSIZE];
101 ulong32 curlen; 101 ulong32 curlen;
102 }; 102 };
103 #endif 103 #endif
104 104
105 typedef union Hash_state { 105 typedef union Hash_state {
106 char dummy[1]; 106 char dummy[1];
107 #ifdef CHC_HASH 107 #ifdef LTC_CHC_HASH
108 struct chc_state chc; 108 struct chc_state chc;
109 #endif 109 #endif
110 #ifdef WHIRLPOOL 110 #ifdef LTC_WHIRLPOOL
111 struct whirlpool_state whirlpool; 111 struct whirlpool_state whirlpool;
112 #endif 112 #endif
113 #ifdef SHA512 113 #ifdef LTC_SHA512
114 struct sha512_state sha512; 114 struct sha512_state sha512;
115 #endif 115 #endif
116 #ifdef SHA256 116 #ifdef LTC_SHA256
117 struct sha256_state sha256; 117 struct sha256_state sha256;
118 #endif 118 #endif
119 #ifdef SHA1 119 #ifdef LTC_SHA1
120 struct sha1_state sha1; 120 struct sha1_state sha1;
121 #endif 121 #endif
122 #ifdef MD5 122 #ifdef LTC_MD5
123 struct md5_state md5; 123 struct md5_state md5;
124 #endif 124 #endif
125 #ifdef MD4 125 #ifdef LTC_MD4
126 struct md4_state md4; 126 struct md4_state md4;
127 #endif 127 #endif
128 #ifdef MD2 128 #ifdef LTC_MD2
129 struct md2_state md2; 129 struct md2_state md2;
130 #endif 130 #endif
131 #ifdef TIGER 131 #ifdef LTC_TIGER
132 struct tiger_state tiger; 132 struct tiger_state tiger;
133 #endif 133 #endif
134 #ifdef RIPEMD128 134 #ifdef LTC_RIPEMD128
135 struct rmd128_state rmd128; 135 struct rmd128_state rmd128;
136 #endif 136 #endif
137 #ifdef RIPEMD160 137 #ifdef LTC_RIPEMD160
138 struct rmd160_state rmd160; 138 struct rmd160_state rmd160;
139 #endif 139 #endif
140 #ifdef RIPEMD256 140 #ifdef LTC_RIPEMD256
141 struct rmd256_state rmd256; 141 struct rmd256_state rmd256;
142 #endif 142 #endif
143 #ifdef RIPEMD320 143 #ifdef LTC_RIPEMD320
144 struct rmd320_state rmd320; 144 struct rmd320_state rmd320;
145 #endif 145 #endif
146 void *data; 146 void *data;
147 } hash_state; 147 } hash_state;
148 148
189 const unsigned char *in, unsigned long inlen, 189 const unsigned char *in, unsigned long inlen,
190 unsigned char *out, unsigned long *outlen); 190 unsigned char *out, unsigned long *outlen);
191 191
192 } hash_descriptor[]; 192 } hash_descriptor[];
193 193
194 #ifdef CHC_HASH 194 #ifdef LTC_CHC_HASH
195 int chc_register(int cipher); 195 int chc_register(int cipher);
196 int chc_init(hash_state * md); 196 int chc_init(hash_state * md);
197 int chc_process(hash_state * md, const unsigned char *in, unsigned long inlen); 197 int chc_process(hash_state * md, const unsigned char *in, unsigned long inlen);
198 int chc_done(hash_state * md, unsigned char *hash); 198 int chc_done(hash_state * md, unsigned char *hash);
199 int chc_test(void); 199 int chc_test(void);
200 extern const struct ltc_hash_descriptor chc_desc; 200 extern const struct ltc_hash_descriptor chc_desc;
201 #endif 201 #endif
202 202
203 #ifdef WHIRLPOOL 203 #ifdef LTC_WHIRLPOOL
204 int whirlpool_init(hash_state * md); 204 int whirlpool_init(hash_state * md);
205 int whirlpool_process(hash_state * md, const unsigned char *in, unsigned long inlen); 205 int whirlpool_process(hash_state * md, const unsigned char *in, unsigned long inlen);
206 int whirlpool_done(hash_state * md, unsigned char *hash); 206 int whirlpool_done(hash_state * md, unsigned char *hash);
207 int whirlpool_test(void); 207 int whirlpool_test(void);
208 extern const struct ltc_hash_descriptor whirlpool_desc; 208 extern const struct ltc_hash_descriptor whirlpool_desc;
209 #endif 209 #endif
210 210
211 #ifdef SHA512 211 #ifdef LTC_SHA512
212 int sha512_init(hash_state * md); 212 int sha512_init(hash_state * md);
213 int sha512_process(hash_state * md, const unsigned char *in, unsigned long inlen); 213 int sha512_process(hash_state * md, const unsigned char *in, unsigned long inlen);
214 int sha512_done(hash_state * md, unsigned char *hash); 214 int sha512_done(hash_state * md, unsigned char *hash);
215 int sha512_test(void); 215 int sha512_test(void);
216 extern const struct ltc_hash_descriptor sha512_desc; 216 extern const struct ltc_hash_descriptor sha512_desc;
217 #endif 217 #endif
218 218
219 #ifdef SHA384 219 #ifdef LTC_SHA384
220 #ifndef SHA512 220 #ifndef LTC_SHA512
221 #error SHA512 is required for SHA384 221 #error LTC_SHA512 is required for LTC_SHA384
222 #endif 222 #endif
223 int sha384_init(hash_state * md); 223 int sha384_init(hash_state * md);
224 #define sha384_process sha512_process 224 #define sha384_process sha512_process
225 int sha384_done(hash_state * md, unsigned char *hash); 225 int sha384_done(hash_state * md, unsigned char *hash);
226 int sha384_test(void); 226 int sha384_test(void);
227 extern const struct ltc_hash_descriptor sha384_desc; 227 extern const struct ltc_hash_descriptor sha384_desc;
228 #endif 228 #endif
229 229
230 #ifdef SHA256 230 #ifdef LTC_SHA256
231 int sha256_init(hash_state * md); 231 int sha256_init(hash_state * md);
232 int sha256_process(hash_state * md, const unsigned char *in, unsigned long inlen); 232 int sha256_process(hash_state * md, const unsigned char *in, unsigned long inlen);
233 int sha256_done(hash_state * md, unsigned char *hash); 233 int sha256_done(hash_state * md, unsigned char *hash);
234 int sha256_test(void); 234 int sha256_test(void);
235 extern const struct ltc_hash_descriptor sha256_desc; 235 extern const struct ltc_hash_descriptor sha256_desc;
236 236
237 #ifdef SHA224 237 #ifdef LTC_SHA224
238 #ifndef SHA256 238 #ifndef LTC_SHA256
239 #error SHA256 is required for SHA224 239 #error LTC_SHA256 is required for LTC_SHA224
240 #endif 240 #endif
241 int sha224_init(hash_state * md); 241 int sha224_init(hash_state * md);
242 #define sha224_process sha256_process 242 #define sha224_process sha256_process
243 int sha224_done(hash_state * md, unsigned char *hash); 243 int sha224_done(hash_state * md, unsigned char *hash);
244 int sha224_test(void); 244 int sha224_test(void);
245 extern const struct ltc_hash_descriptor sha224_desc; 245 extern const struct ltc_hash_descriptor sha224_desc;
246 #endif 246 #endif
247 #endif 247 #endif
248 248
249 #ifdef SHA1 249 #ifdef LTC_SHA1
250 int sha1_init(hash_state * md); 250 int sha1_init(hash_state * md);
251 int sha1_process(hash_state * md, const unsigned char *in, unsigned long inlen); 251 int sha1_process(hash_state * md, const unsigned char *in, unsigned long inlen);
252 int sha1_done(hash_state * md, unsigned char *hash); 252 int sha1_done(hash_state * md, unsigned char *hash);
253 int sha1_test(void); 253 int sha1_test(void);
254 extern const struct ltc_hash_descriptor sha1_desc; 254 extern const struct ltc_hash_descriptor sha1_desc;
255 #endif 255 #endif
256 256
257 #ifdef MD5 257 #ifdef LTC_MD5
258 int md5_init(hash_state * md); 258 int md5_init(hash_state * md);
259 int md5_process(hash_state * md, const unsigned char *in, unsigned long inlen); 259 int md5_process(hash_state * md, const unsigned char *in, unsigned long inlen);
260 int md5_done(hash_state * md, unsigned char *hash); 260 int md5_done(hash_state * md, unsigned char *hash);
261 int md5_test(void); 261 int md5_test(void);
262 extern const struct ltc_hash_descriptor md5_desc; 262 extern const struct ltc_hash_descriptor md5_desc;
263 #endif 263 #endif
264 264
265 #ifdef MD4 265 #ifdef LTC_MD4
266 int md4_init(hash_state * md); 266 int md4_init(hash_state * md);
267 int md4_process(hash_state * md, const unsigned char *in, unsigned long inlen); 267 int md4_process(hash_state * md, const unsigned char *in, unsigned long inlen);
268 int md4_done(hash_state * md, unsigned char *hash); 268 int md4_done(hash_state * md, unsigned char *hash);
269 int md4_test(void); 269 int md4_test(void);
270 extern const struct ltc_hash_descriptor md4_desc; 270 extern const struct ltc_hash_descriptor md4_desc;
271 #endif 271 #endif
272 272
273 #ifdef MD2 273 #ifdef LTC_MD2
274 int md2_init(hash_state * md); 274 int md2_init(hash_state * md);
275 int md2_process(hash_state * md, const unsigned char *in, unsigned long inlen); 275 int md2_process(hash_state * md, const unsigned char *in, unsigned long inlen);
276 int md2_done(hash_state * md, unsigned char *hash); 276 int md2_done(hash_state * md, unsigned char *hash);
277 int md2_test(void); 277 int md2_test(void);
278 extern const struct ltc_hash_descriptor md2_desc; 278 extern const struct ltc_hash_descriptor md2_desc;
279 #endif 279 #endif
280 280
281 #ifdef TIGER 281 #ifdef LTC_TIGER
282 int tiger_init(hash_state * md); 282 int tiger_init(hash_state * md);
283 int tiger_process(hash_state * md, const unsigned char *in, unsigned long inlen); 283 int tiger_process(hash_state * md, const unsigned char *in, unsigned long inlen);
284 int tiger_done(hash_state * md, unsigned char *hash); 284 int tiger_done(hash_state * md, unsigned char *hash);
285 int tiger_test(void); 285 int tiger_test(void);
286 extern const struct ltc_hash_descriptor tiger_desc; 286 extern const struct ltc_hash_descriptor tiger_desc;
287 #endif 287 #endif
288 288
289 #ifdef RIPEMD128 289 #ifdef LTC_RIPEMD128
290 int rmd128_init(hash_state * md); 290 int rmd128_init(hash_state * md);
291 int rmd128_process(hash_state * md, const unsigned char *in, unsigned long inlen); 291 int rmd128_process(hash_state * md, const unsigned char *in, unsigned long inlen);
292 int rmd128_done(hash_state * md, unsigned char *hash); 292 int rmd128_done(hash_state * md, unsigned char *hash);
293 int rmd128_test(void); 293 int rmd128_test(void);
294 extern const struct ltc_hash_descriptor rmd128_desc; 294 extern const struct ltc_hash_descriptor rmd128_desc;
295 #endif 295 #endif
296 296
297 #ifdef RIPEMD160 297 #ifdef LTC_RIPEMD160
298 int rmd160_init(hash_state * md); 298 int rmd160_init(hash_state * md);
299 int rmd160_process(hash_state * md, const unsigned char *in, unsigned long inlen); 299 int rmd160_process(hash_state * md, const unsigned char *in, unsigned long inlen);
300 int rmd160_done(hash_state * md, unsigned char *hash); 300 int rmd160_done(hash_state * md, unsigned char *hash);
301 int rmd160_test(void); 301 int rmd160_test(void);
302 extern const struct ltc_hash_descriptor rmd160_desc; 302 extern const struct ltc_hash_descriptor rmd160_desc;
303 #endif 303 #endif
304 304
305 #ifdef RIPEMD256 305 #ifdef LTC_RIPEMD256
306 int rmd256_init(hash_state * md); 306 int rmd256_init(hash_state * md);
307 int rmd256_process(hash_state * md, const unsigned char *in, unsigned long inlen); 307 int rmd256_process(hash_state * md, const unsigned char *in, unsigned long inlen);
308 int rmd256_done(hash_state * md, unsigned char *hash); 308 int rmd256_done(hash_state * md, unsigned char *hash);
309 int rmd256_test(void); 309 int rmd256_test(void);
310 extern const struct ltc_hash_descriptor rmd256_desc; 310 extern const struct ltc_hash_descriptor rmd256_desc;
311 #endif 311 #endif
312 312
313 #ifdef RIPEMD320 313 #ifdef LTC_RIPEMD320
314 int rmd320_init(hash_state * md); 314 int rmd320_init(hash_state * md);
315 int rmd320_process(hash_state * md, const unsigned char *in, unsigned long inlen); 315 int rmd320_process(hash_state * md, const unsigned char *in, unsigned long inlen);
316 int rmd320_done(hash_state * md, unsigned char *hash); 316 int rmd320_done(hash_state * md, unsigned char *hash);
317 int rmd320_test(void); 317 int rmd320_test(void);
318 extern const struct ltc_hash_descriptor rmd320_desc; 318 extern const struct ltc_hash_descriptor rmd320_desc;
372 } \ 372 } \
373 } \ 373 } \
374 return CRYPT_OK; \ 374 return CRYPT_OK; \
375 } 375 }
376 376
377 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_hash.h,v $ */ 377 /* $Source$ */
378 /* $Revision: 1.19 $ */ 378 /* $Revision$ */
379 /* $Date: 2006/11/05 01:36:43 $ */ 379 /* $Date$ */