Index: ext/hash/hash_tiger.c =================================================================== RCS file: /repository/php-src/ext/hash/hash_tiger.c,v retrieving revision 1.4.2.2 diff -u -r1.4.2.2 hash_tiger.c --- ext/hash/hash_tiger.c 2 Dec 2005 01:59:44 -0000 1.4.2.2 +++ ext/hash/hash_tiger.c 6 Jan 2006 13:21:54 -0000 @@ -24,7 +24,7 @@ #include "php_hash_tiger_tables.h" /* {{{ */ -#define save_abc \ +#define save_abc() \ aa = a; \ bb = b; \ cc = c; @@ -51,7 +51,7 @@ round(a,b,c,x6,mul) \ round(b,c,a,x7,mul) -#define key_schedule \ +#define key_schedule() \ x0 -= x7 ^ L64(0xA5A5A5A5A5A5A5A5); \ x1 ^= x0; \ x2 += x1; \ @@ -69,45 +69,44 @@ x6 += x5; \ x7 -= x6 ^ L64(0x0123456789ABCDEF); -#define feedforward \ +#define feedforward() \ a ^= aa; \ b -= bb; \ c += cc; +/* }}} */ -#define compress(passes) \ - save_abc \ - pass(a,b,c,5) \ - key_schedule \ - pass(c,a,b,7) \ - key_schedule \ - pass(b,c,a,9) \ - for(pass_no=0; pass_nostate[0]; + b = context->state[1]; + c = context->state[2]; + + x0 = H[0]; x1 = H[1]; x2 = H[2]; x3 = H[3]; + x4 = H[4]; x5 = H[5]; x6 = H[6]; x7 = H[7]; + + save_abc(); + + pass(a,b,c,5); + key_schedule(); + pass(c,a,b,7); + key_schedule(); + pass(b,c,a,9); + + for (pass_no = 0; pass_no < context->passes; pass_no++) { + key_schedule(); + pass(a,b,c,9); + tmpa=a; a=c; c=b; b=tmpa; + } + feedforward(); + + context->state[0] = a; + context->state[1] = b; + context->state[2] = c; } -/* }}} */ static inline void TigerFinalize(PHP_TIGER_CTX *context) { @@ -121,14 +120,14 @@ if (context->length > 56) { memset(&context->buffer[context->length], 0, 64 - context->length); - tiger_compress(context->passes, ((php_hash_uint64 *) context->buffer), context->state); + TigerCompress(context, (php_hash_uint64 *) context->buffer); memset(context->buffer, 0, 56); } else { memset(&context->buffer[context->length], 0, 56 - context->length); } memcpy(&context->buffer[56], &context->passed, sizeof(php_hash_uint64)); - tiger_compress(context->passes, ((php_hash_uint64 *) context->buffer), context->state); + TigerCompress(context, (php_hash_uint64 *) context->buffer); } PHP_HASH_API void PHP_3TIGERInit(PHP_TIGER_CTX *context) @@ -159,13 +158,13 @@ if (context->length) { i = 64 - context->length; memcpy(&context->buffer[context->length], input, i); - tiger_compress(context->passes, ((const php_hash_uint64 *) context->buffer), context->state); + TigerCompress(context, (php_hash_uint64 *) context->buffer); memset(context->buffer, 0, 64); context->passed += 512; } for (; i + 64 <= len; i += 64) { - tiger_compress(context->passes, ((const php_hash_uint64 *) (input + i)), context->state); + TigerCompress(context, (php_hash_uint64 *) (input + i)); context->passed += 512; }