Hash: use hash method for sha3 when available

This commit is contained in:
terrafrost 2018-10-13 07:48:47 -05:00
parent 3df87e8632
commit 39d3ffbeb1

View File

@ -302,6 +302,9 @@ class Hash
}
if (in_array(substr($hash, 0, 5), ['sha3-', 'shake'])) {
// PHP 7.1.0 introduced support for "SHA3 fixed mode algorithms":
// http://php.net/ChangeLog-7.php#7.1.0
if (version_compare(PHP_VERSION, '7.1.0') < 0 || substr($hash, 0,5) == 'shake') {
//preg_match('#(\d+)$#', $hash, $matches);
//$this->parameters['capacity'] = 2 * $matches[1]; // 1600 - $this->blockSize
//$this->parameters['rate'] = 1600 - $this->parameters['capacity']; // == $this->blockSize
@ -316,6 +319,7 @@ class Hash
];
$hash = ['phpseclib\Crypt\Hash', PHP_INT_SIZE == 8 ? 'sha3_64' : 'sha3_32'];
}
}
if ($hash == 'sha512/224' || $hash == 'sha512/256') {
// PHP 7.1.0 introduced sha512/224 and sha512/256 support: