comparison 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
comparison
equal deleted inserted replaced
280:59400faa4b44 380:d5faf4814ddb
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
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
73 #ifdef WHIRLPOOL 89 #ifdef WHIRLPOOL
74 struct whirlpool_state { 90 struct whirlpool_state {
75 ulong64 length, state[8]; 91 ulong64 length, state[8];
76 unsigned char buf[64]; 92 unsigned char buf[64];
77 ulong32 curlen; 93 ulong32 curlen;
85 ulong32 curlen; 101 ulong32 curlen;
86 }; 102 };
87 #endif 103 #endif
88 104
89 typedef union Hash_state { 105 typedef union Hash_state {
106 char dummy[1];
90 #ifdef CHC_HASH 107 #ifdef CHC_HASH
91 struct chc_state chc; 108 struct chc_state chc;
92 #endif 109 #endif
93 #ifdef WHIRLPOOL 110 #ifdef WHIRLPOOL
94 struct whirlpool_state whirlpool; 111 struct whirlpool_state whirlpool;
118 struct rmd128_state rmd128; 135 struct rmd128_state rmd128;
119 #endif 136 #endif
120 #ifdef RIPEMD160 137 #ifdef RIPEMD160
121 struct rmd160_state rmd160; 138 struct rmd160_state rmd160;
122 #endif 139 #endif
140 #ifdef RIPEMD256
141 struct rmd256_state rmd256;
142 #endif
143 #ifdef RIPEMD320
144 struct rmd320_state rmd320;
145 #endif
123 void *data; 146 void *data;
124 } hash_state; 147 } hash_state;
125 148
149 /** hash descriptor */
126 extern struct ltc_hash_descriptor { 150 extern struct ltc_hash_descriptor {
127 /** name of hash */ 151 /** name of hash */
128 char *name; 152 char *name;
129 /** internal ID */ 153 /** internal ID */
130 unsigned char ID; 154 unsigned char ID;
157 int (*done)(hash_state *hash, unsigned char *out); 181 int (*done)(hash_state *hash, unsigned char *out);
158 /** Self-test 182 /** Self-test
159 @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled 183 @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled
160 */ 184 */
161 int (*test)(void); 185 int (*test)(void);
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
162 } hash_descriptor[]; 192 } hash_descriptor[];
163 193
164 #ifdef CHC_HASH 194 #ifdef CHC_HASH
165 int chc_register(int cipher); 195 int chc_register(int cipher);
166 int chc_init(hash_state * md); 196 int chc_init(hash_state * md);
270 int rmd160_done(hash_state * md, unsigned char *hash); 300 int rmd160_done(hash_state * md, unsigned char *hash);
271 int rmd160_test(void); 301 int rmd160_test(void);
272 extern const struct ltc_hash_descriptor rmd160_desc; 302 extern const struct ltc_hash_descriptor rmd160_desc;
273 #endif 303 #endif
274 304
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
275 int find_hash(const char *name); 322 int find_hash(const char *name);
276 int find_hash_id(unsigned char ID); 323 int find_hash_id(unsigned char ID);
324 int find_hash_oid(const unsigned long *ID, unsigned long IDlen);
277 int find_hash_any(const char *name, int digestlen); 325 int find_hash_any(const char *name, int digestlen);
278 int register_hash(const struct ltc_hash_descriptor *hash); 326 int register_hash(const struct ltc_hash_descriptor *hash);
279 int unregister_hash(const struct ltc_hash_descriptor *hash); 327 int unregister_hash(const struct ltc_hash_descriptor *hash);
280 int hash_is_valid(int idx); 328 int hash_is_valid(int idx);
281 329
282 LTC_MUTEX_PROTO(ltc_hash_mutex); 330 LTC_MUTEX_PROTO(ltc_hash_mutex)
283 331
284 int hash_memory(int hash, 332 int hash_memory(int hash,
285 const unsigned char *in, unsigned long inlen, 333 const unsigned char *in, unsigned long inlen,
286 unsigned char *out, unsigned long *outlen); 334 unsigned char *out, unsigned long *outlen);
287 int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen, 335 int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen,
325 } \ 373 } \
326 return CRYPT_OK; \ 374 return CRYPT_OK; \
327 } 375 }
328 376
329 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_hash.h,v $ */ 377 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_hash.h,v $ */
330 /* $Revision: 1.12 $ */ 378 /* $Revision: 1.19 $ */
331 /* $Date: 2005/06/19 18:00:28 $ */ 379 /* $Date: 2006/11/05 01:36:43 $ */