Req->Doc #75266 [Opn]: hash_algos doesnt work properly for listing HMAC algos
| From: | requinix@php.net | Date: | Wed, 27 Sep 2017 10:04:24 +0000 |
| Subject: | Req->Doc #75266 [Opn]: hash_algos doesnt work properly for listing HMAC algos | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-15001@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75266&edit=1
ID: 75266
Updated by: requinix@php.net
Reported by: phpdoc at mail dot my1 dot info
Summary: hash_algos doesnt work properly for listing HMAC
algos
Status: Open
-Type: Feature/Change Request
+Type: Documentation Problem
Package: *Encryption and hash functions
Operating System: Win8.1 x64
PHP Version: 7.2.0RC2
Block user comment: N
Private report: N
New Comment:
PHP 7.2 will introduce a function specifically for this:
array hash_hmac_algos ( void )
Return a list of registered hashing algorithms suitable for hash_hmac
I don't think documentation has been written for it yet.
There's also a minor issue where hash_hmac_algos() isn't listed in the New Functions
section of UPGRADING.
Previous Comments:
------------------------------------------------------------------------
[2017-09-27 09:41:29] phpdoc at mail dot my1 dot info
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 this bug report at https://bugs.php.net/bug.php?id=75266&edit=1