Bug #70312 [NEW]: HAVAL gives wrong hashes in specific cases

From: Date: Thu, 20 Aug 2015 15:00:40 +0000
Subject: Bug #70312 [NEW]: HAVAL gives wrong hashes in specific cases
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195373@lists.php.net to get a copy of this message
From: letsgolee at naver dot com Operating system: Windows/linux PHP version: 5.4.44 Package: hash related Bug Type: Bug Bug description:HAVAL gives wrong hashes in specific cases Description: ------------ HAVAL pads a string with a wrong pad length, if the remaining string is over 64 and under 118 bytes length. The suspect code is: index = (unsigned int) ((context->count[0] >> 3) & 0x3f); when the remaining string is under 63 bytes long then there seems no problem, but when a string is over 64 and under 118 then it seems to have a wrong padding length. If you test "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMOPQRSTUVWXYZ0123456789" then, it will give you right hash value, because the string length is 183 and it is above 128 and the remaining string length is 55. And 55 is under 64 so it will give a right result. Test script: --------------- hash('haval256,5', '1234567890123456789012345678901234567890123456789012345678901234'); Expected result: ---------------- fb73c19300b14d5cb393d929bf005e6c2d459a4c9c009e9813af1d2d3637ee8f Actual result: -------------- 498f3710ed9373908405d608e15df8157ef777abe85794b67f590347b4506fb2 -- Edit bug report at https://bugs.php.net/bug.php?id=70312&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70312&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70312&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70312&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70312&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70312&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70312&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70312&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70312&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70312&r=support Expected behavior: https://bugs.php.net/fix.php?id=70312&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70312&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70312&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70312&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70312&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70312&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70312&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70312&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70312&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70312&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70312&r=mysqlcfg

« previous php.bugs (#195373) next »