Req #75266 [NEW]: hash_algos doesnt work properly for listing HMAC algos

From: Date: Wed, 27 Sep 2017 09:41:35 +0000
Subject: Req #75266 [NEW]: hash_algos doesnt work properly for listing HMAC algos
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211381@lists.php.net to get a copy of this message
From: phpdoc at mail dot my1 dot info Operating system: Win8.1 x64 PHP version: 7.2.0RC2 Package: *Encryption and hash functions Bug Type: Feature/Change Request Bug description:hash_algos doesnt work properly for listing HMAC algos Description: ------------ --- From manual page: http://www.php.net/function.hash-hmac --- This is a mix of a doc problem and a feature request. Simply said the doc says, that one should refer to the hash_algos funtion to see what can be used for HMACs but that's not entirely true, as it contains algorithms that cant be used for HMAC. while I know that it's totally stupid to use things like CRC32 or Adler32 for HMACs, but this doesnt change that there isnt a proper list fuunction for HMACs. Test script: --------------- <?php $garray=[]; $barray=[]; foreach (hash_algos() as $hashx) { $h=hash_hmac($hashx,"hello","hello"); if($h) {$garray[$hashx]=$h;} else {$barray[$hashx]=$h;} } var_dump($garray,$barray); if(count($barray)>0) { echo "hashes that dont work for HMAC are: ".implode(", ",array_keys($barray)); } else { echo "all hashes are compatible with HMAC" } ?> Expected result: ---------------- a list of algos and their HMACs, an empty array for the hashes that dont work as well as the output "all hashes are compatible with HMAC" Actual result: -------------- 2 Lists of algos one which has working hmacs and another which has false as the value, as well as the output: "hashes that dont work for HMAC are: adler32, crc32, crc32b, fnv132, fnv1a32, fnv164, fnv1a64, joaat" -- Edit bug report at https://bugs.php.net/bug.php?id=75266&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75266&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75266&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75266&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75266&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75266&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75266&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75266&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75266&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75266&r=support Expected behavior: https://bugs.php.net/fix.php?id=75266&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75266&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75266&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75266&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75266&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75266&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75266&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75266&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75266&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75266&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75266&r=mysqlcfg

« previous php.bugs (#211381) next »