Hash: fix PHP 8.2 error

see https://github.com/php/php-src/issues/8924
This commit is contained in:
terrafrost 2022-08-27 07:59:39 -05:00
parent c5a9ee5234
commit 2026b0c0db

View File

@ -575,10 +575,10 @@ class Hash
// For the last chunk: pad to 32-byte boundary, endian-adjust, // For the last chunk: pad to 32-byte boundary, endian-adjust,
// NH hash and add bit-length. Concatenate the result to Y. // NH hash and add bit-length. Concatenate the result to Y.
// //
$length = strlen($m[$i]); $length = count($m) ? strlen($m[$i]) : 0;
$pad = 32 - ($length % 32); $pad = 32 - ($length % 32);
$pad = max(32, $length + $pad % 32); $pad = max(32, $length + $pad % 32);
$m[$i] = str_pad($m[$i], $pad, "\0"); // zeropad $m[$i] = str_pad(isset($m[$i]) ? $m[$i] : '', $pad, "\0"); // zeropad
$m[$i] = pack('N*', ...unpack('V*', $m[$i])); // ENDIAN-SWAP $m[$i] = pack('N*', ...unpack('V*', $m[$i])); // ENDIAN-SWAP
$y .= static::nh($k, $m[$i], new BigInteger($length * 8)); $y .= static::nh($k, $m[$i], new BigInteger($length * 8));