mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-31 21:21:55 +00:00
Hash: use hash method for sha3 when available
This commit is contained in:
parent
3df87e8632
commit
39d3ffbeb1
@ -302,6 +302,9 @@ class Hash
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (in_array(substr($hash, 0, 5), ['sha3-', 'shake'])) {
|
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);
|
//preg_match('#(\d+)$#', $hash, $matches);
|
||||||
//$this->parameters['capacity'] = 2 * $matches[1]; // 1600 - $this->blockSize
|
//$this->parameters['capacity'] = 2 * $matches[1]; // 1600 - $this->blockSize
|
||||||
//$this->parameters['rate'] = 1600 - $this->parameters['capacity']; // == $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'];
|
$hash = ['phpseclib\Crypt\Hash', PHP_INT_SIZE == 8 ? 'sha3_64' : 'sha3_32'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($hash == 'sha512/224' || $hash == 'sha512/256') {
|
if ($hash == 'sha512/224' || $hash == 'sha512/256') {
|
||||||
// PHP 7.1.0 introduced sha512/224 and sha512/256 support:
|
// PHP 7.1.0 introduced sha512/224 and sha512/256 support:
|
||||||
|
Loading…
Reference in New Issue
Block a user