php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65891 PHP is missing a sha3() function
Submitted: 2013-10-13 21:58 UTC Modified: 2017-03-11 17:21 UTC
Votes:33
Avg. Score:4.7 ± 0.5
Reproduced:26 of 27 (96.3%)
Same Version:14 (53.8%)
Same OS:20 (76.9%)
From: scott dot baker at gmail dot com Assigned: nikic (profile)
Status: Closed Package: hash related
PHP Version: 5.5.5RC1 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: scott dot baker at gmail dot com
New email:
PHP Version: OS:

 

 [2013-10-13 21:58 UTC] scott dot baker at gmail dot com
Description:
------------
PHP has md5() and sha1() functions, but there is no sha3() function. Now that keccak has been officially declared the winner, PHP needs a sha3() function to match.

Optionally support could be added to hash() for keccak, but I think a standalone sha3() would be preferable.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-13 22:00 UTC] scott dot baker at gmail dot com
There has already been some work on this, it probably just needs to be merged in to core PHP?

https://github.com/strawbrary/php-sha3
 [2013-10-14 06:04 UTC] pajoye@php.net
I would rather add it to the hash extension, more consistent.
 [2013-10-15 16:50 UTC] scott dot baker at gmail dot com
Perhaps we could have support for both hash() and sha3() methods? 

I really like the sha3() method that strawbrary wrote. It's very logical and easy to remember. hash() requires me to remember the order of parameters, and the hash name. sha3() seems more direct.
 [2013-10-15 17:18 UTC] nikic@php.net
I agree with Pierre. This is a hash function, so it belongs in the hash extension. There is no point in adding an individual function for every single hash type.
 [2014-07-12 19:57 UTC] ryacko at gmail dot com
Except that SHA-3 is a hash function with a variable length and variable security margin.

One could add the four SHA3 standards, but that wouldn't make available all the possible ways to use SHA3.

It could be used as stream cipher for instance. 

http://keccak.noekeon.org/tune.html
 [2015-11-11 14:06 UTC] divinity76 at gmail dot com
add it to the hash function and stop whining about sha3(), once its in the hash() it can _very_ easily be polyfilled if you want it. however, a slight problem is that sha3 is variable-length, so hash() needs to be modified to take a new argument of output size
 [2017-03-11 17:21 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2017-03-11 17:21 UTC] nikic@php.net
The hash extension supports sha3 as of PHP 7.1, using the names sha3-224, sha3-256, sha3-384, sha3-512. Relevant commit: https://github.com/php/php-src/commit/d244b54c67cc2725283b78d4bb128501ae7910d3
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 10:01:28 2024 UTC