From: Michael Wallner Date: Thu, 24 Nov 2005 14:28:34 +0000 (+0000) Subject: - fix tiger algo X-Git-Tag: RELEASE_2_0_2~99 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4875427d1672cd0b621068ce41ec943fc2060fab;p=php - fix tiger algo --- diff --git a/ext/hash/hash_tiger.c b/ext/hash/hash_tiger.c index c0fc57ee10..57edac3cc5 100644 --- a/ext/hash/hash_tiger.c +++ b/ext/hash/hash_tiger.c @@ -109,19 +109,6 @@ } /* }}} */ -static inline void TigerTransform(PHP_TIGER_CTX *context, const unsigned char *input, size_t length) -{ - php_hash_uint64 i = (php_hash_uint64) length << 3; - const php_hash_uint64 *ptr = (const php_hash_uint64 *) input; - - context->passed += i; - - for (; i >= 64; i -= 64) { - tiger_compress(context->passes, ptr, context->state); - ptr += 8; - } -} - static inline void TigerFinalize(PHP_TIGER_CTX *context) { context->passed += (php_hash_uint64) context->length << 3; @@ -161,7 +148,7 @@ PHP_HASH_API void PHP_4TIGERInit(PHP_TIGER_CTX *context) context->state[2] = L64(0xF096A5B4C3B2E187); } -PHP_HASH_API void PHP_TIGERUpdate(PHP_TIGER_CTX *context, unsigned char *input, size_t len) +PHP_HASH_API void PHP_TIGERUpdate(PHP_TIGER_CTX *context, const unsigned char *input, size_t len) { if (context->length + len < 64) { memcpy(&context->buffer[context->length], input, len); @@ -172,12 +159,14 @@ PHP_HASH_API void PHP_TIGERUpdate(PHP_TIGER_CTX *context, unsigned char *input, if (context->length) { i = 64 - context->length; memcpy(&context->buffer[context->length], input, i); - TigerTransform(context, context->buffer, 64); + tiger_compress(context->passes, ((const php_hash_uint64 *) context->buffer), context->state); memset(context->buffer, 0, 64); + context->passed += 512; } for (; i + 64 <= len; i += 64) { - TigerTransform(context, input + i, 64); + tiger_compress(context->passes, ((const php_hash_uint64 *) (input + i)), context->state); + context->passed += 512; } memcpy(context->buffer, input + i, r); diff --git a/ext/hash/php_hash_tiger.h b/ext/hash/php_hash_tiger.h index 75046d41ca..e3291c3ce1 100644 --- a/ext/hash/php_hash_tiger.h +++ b/ext/hash/php_hash_tiger.h @@ -47,7 +47,7 @@ typedef struct { PHP_HASH_API void PHP_3TIGERInit(PHP_TIGER_CTX *context); PHP_HASH_API void PHP_4TIGERInit(PHP_TIGER_CTX *context); -PHP_HASH_API void PHP_TIGERUpdate(PHP_TIGER_CTX *context, unsigned char *input, size_t len); +PHP_HASH_API void PHP_TIGERUpdate(PHP_TIGER_CTX *context, const unsigned char *input, size_t len); PHP_HASH_API void PHP_TIGER128Final(unsigned char digest[16], PHP_TIGER_CTX *context); PHP_HASH_API void PHP_TIGER160Final(unsigned char digest[20], PHP_TIGER_CTX *context); PHP_HASH_API void PHP_TIGER192Final(unsigned char digest[24], PHP_TIGER_CTX *context); diff --git a/ext/hash/tests/tiger.phpt b/ext/hash/tests/tiger.phpt index 712750aec0..ee3f249bf1 100644 --- a/ext/hash/tests/tiger.phpt +++ b/ext/hash/tests/tiger.phpt @@ -6,12 +6,13 @@ tiger --EXPECT-- 24f0130c63ac933216166e76b1bb925ff373de2d49584e7a f258c1e88414ab2a527ab541ffc5b8bf935f7b951c132951 +8ee409a14e6066933b63d5b2abca63d71a78f55e29eb4649 2586156d16bf9ab1e6e48bdf5e038f8053c30e071db3bcb0 3ee8a9405396ddba1bc038508af4164ac1fe59ef58916a85 -