Doc #75266 [Opn->Csd]: hash_algos doesnt work properly for listing HMAC algos
| From: | cmb@php.net | Date: | Wed, 27 Sep 2017 15:21:46 +0000 |
| Subject: | Doc #75266 [Opn->Csd]: hash_algos doesnt work properly for listing HMAC algos | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-15002@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: cmb@php.net
Reported by: phpdoc at mail dot my1 dot info
Summary: hash_algos doesnt work properly for listing HMAC
algos
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: *Encryption and hash functions
Operating System: Win8.1 x64
PHP Version: 7.2.0RC2
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> here's also a minor issue where hash_hmac_algos() isn't listed in the New
> Functions section of UPGRADING.
Fixed with <http://git.php.net/?p=php-src.git;a=commit;h=b0d6d27>.
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
Previous Comments:
------------------------------------------------------------------------
[2017-09-27 15:13:35] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=343152
Log: Fix bug #75266: hash_algos doesnt work properly for listing HMAC algos
------------------------------------------------------------------------
[2017-09-27 10:04:21] requinix@php.net
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.
------------------------------------------------------------------------
[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