comparison src/hashes/chc/chc.c @ 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
4 * algorithms in a highly modular and flexible manner. 4 * algorithms in a highly modular and flexible manner.
5 * 5 *
6 * The library is free for all purposes without any express 6 * The library is free for all purposes without any express
7 * guarantee it works. 7 * guarantee it works.
8 * 8 *
9 * Tom St Denis, [email protected], http://libtomcrypt.org 9 * Tom St Denis, [email protected], http://libtomcrypt.com
10 */ 10 */
11 11
12 #include "tomcrypt.h" 12 #include "tomcrypt.h"
13 13
14 /** 14 /**
28 const struct ltc_hash_descriptor chc_desc = { 28 const struct ltc_hash_descriptor chc_desc = {
29 "chc_hash", 12, 0, 0, { 0 }, 0, 29 "chc_hash", 12, 0, 0, { 0 }, 0,
30 &chc_init, 30 &chc_init,
31 &chc_process, 31 &chc_process,
32 &chc_done, 32 &chc_done,
33 &chc_test 33 &chc_test,
34 NULL
34 }; 35 };
35 36
36 /** 37 /**
37 Initialize the CHC state with a given cipher 38 Initialize the CHC state with a given cipher
38 @param cipher The index of the cipher you wish to bind 39 @param cipher The index of the cipher you wish to bind
139 } 140 }
140 if ((err = cipher_descriptor[cipher_idx].setup(md->chc.state, cipher_blocksize, 0, key)) != CRYPT_OK) { 141 if ((err = cipher_descriptor[cipher_idx].setup(md->chc.state, cipher_blocksize, 0, key)) != CRYPT_OK) {
141 XFREE(key); 142 XFREE(key);
142 return err; 143 return err;
143 } 144 }
144 memcpy(T[1], buf, cipher_blocksize); 145 XMEMCPY(T[1], buf, cipher_blocksize);
145 cipher_descriptor[cipher_idx].ecb_encrypt(buf, T[0], key); 146 cipher_descriptor[cipher_idx].ecb_encrypt(buf, T[0], key);
146 for (x = 0; x < cipher_blocksize; x++) { 147 for (x = 0; x < cipher_blocksize; x++) {
147 md->chc.state[x] ^= T[0][x] ^ T[1][x]; 148 md->chc.state[x] ^= T[0][x] ^ T[1][x];
148 } 149 }
149 XFREE(key); 150 XFREE(key);
277 278
278 for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) { 279 for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) {
279 chc_init(&md); 280 chc_init(&md);
280 chc_process(&md, tests[x].msg, strlen((char *)tests[x].msg)); 281 chc_process(&md, tests[x].msg, strlen((char *)tests[x].msg));
281 chc_done(&md, out); 282 chc_done(&md, out);
282 if (memcmp(out, tests[x].md, tests[x].len)) { 283 if (XMEMCMP(out, tests[x].md, tests[x].len)) {
283 return CRYPT_FAIL_TESTVECTOR; 284 return CRYPT_FAIL_TESTVECTOR;
284 } 285 }
285 } 286 }
286 if (oldhashidx != UNDEFED_HASH) { 287 if (oldhashidx != UNDEFED_HASH) {
287 chc_register(oldhashidx); 288 chc_register(oldhashidx);
291 } 292 }
292 293
293 #endif 294 #endif
294 295
295 /* $Source: /cvs/libtom/libtomcrypt/src/hashes/chc/chc.c,v $ */ 296 /* $Source: /cvs/libtom/libtomcrypt/src/hashes/chc/chc.c,v $ */
296 /* $Revision: 1.3 $ */ 297 /* $Revision: 1.6 $ */
297 /* $Date: 2005/05/05 14:35:58 $ */ 298 /* $Date: 2006/11/01 09:28:17 $ */