Mercurial > dropbear
diff tiger.c @ 143:5d99163f7e32 libtomcrypt-orig
import of libtomcrypt 0.99
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 19 Dec 2004 11:34:45 +0000 |
parents | 6362d3854bb4 |
children | 7ed585a2c53b |
line wrap: on
line diff
--- a/tiger.c Tue Jun 15 14:07:21 2004 +0000 +++ b/tiger.c Sun Dec 19 11:34:45 2004 +0000 @@ -558,7 +558,7 @@ #endif /* one round of the hash function */ -INLINE static void round(ulong64 *a, ulong64 *b, ulong64 *c, ulong64 x, int mul) +INLINE static void tiger_round(ulong64 *a, ulong64 *b, ulong64 *c, ulong64 x, int mul) { ulong64 tmp; tmp = (*c ^= x); @@ -574,14 +574,14 @@ /* one complete pass */ static void pass(ulong64 *a, ulong64 *b, ulong64 *c, ulong64 *x, int mul) { - round(a,b,c,x[0],mul); - round(b,c,a,x[1],mul); - round(c,a,b,x[2],mul); - round(a,b,c,x[3],mul); - round(b,c,a,x[4],mul); - round(c,a,b,x[5],mul); - round(a,b,c,x[6],mul); - round(b,c,a,x[7],mul); + tiger_round(a,b,c,x[0],mul); + tiger_round(b,c,a,x[1],mul); + tiger_round(c,a,b,x[2],mul); + tiger_round(a,b,c,x[3],mul); + tiger_round(b,c,a,x[4],mul); + tiger_round(c,a,b,x[5],mul); + tiger_round(a,b,c,x[6],mul); + tiger_round(b,c,a,x[7],mul); } /* The key mixing schedule */ @@ -606,9 +606,9 @@ } #ifdef CLEAN_STACK -static void _tiger_compress(hash_state *md, unsigned char *buf) +static int _tiger_compress(hash_state *md, unsigned char *buf) #else -static void tiger_compress(hash_state *md, unsigned char *buf) +static int tiger_compress(hash_state *md, unsigned char *buf) #endif { ulong64 a, b, c, x[8]; @@ -632,17 +632,21 @@ md->tiger.state[0] = a ^ md->tiger.state[0]; md->tiger.state[1] = b - md->tiger.state[1]; md->tiger.state[2] = c + md->tiger.state[2]; + + return CRYPT_OK; } #ifdef CLEAN_STACK -static void tiger_compress(hash_state *md, unsigned char *buf) +static int tiger_compress(hash_state *md, unsigned char *buf) { - _tiger_compress(md, buf); + int err; + err = _tiger_compress(md, buf); burn_stack(sizeof(ulong64) * 11 + sizeof(unsigned long)); + return err; } #endif -void tiger_init(hash_state *md) +int tiger_init(hash_state *md) { _ARGCHK(md != NULL); md->tiger.state[0] = CONST64(0x0123456789ABCDEF); @@ -650,6 +654,7 @@ md->tiger.state[2] = CONST64(0xF096A5B4C3B2E187); md->tiger.curlen = 0; md->tiger.length = 0; + return CRYPT_OK; } HASH_PROCESS(tiger_process, tiger_compress, tiger, 64)