fix(crypto): reject malformed nonce in check()
This commit is contained in:
@@ -42,6 +42,10 @@ class Nonce
|
|||||||
*/
|
*/
|
||||||
public static function check(string $nonce, string $passphrase = ''): bool
|
public static function check(string $nonce, string $passphrase = ''): bool
|
||||||
{
|
{
|
||||||
|
if ($nonce === '' || !ctype_xdigit($nonce) || strlen($nonce) % 2 !== 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$decripted = openssl_decrypt(
|
$decripted = openssl_decrypt(
|
||||||
hex2bin($nonce),
|
hex2bin($nonce),
|
||||||
'aes-128-ecb',
|
'aes-128-ecb',
|
||||||
|
|||||||
Reference in New Issue
Block a user