Skip to content

Commit 86f5f01

Browse files
committed
Prevent timing attack on HMAC #12152
1 parent 64dd32b commit 86f5f01

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

server/Application/Handler/DatatransHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private function checkSignature(array $body, string $key): void
8484
$aliasCC = $body['aliasCC'] ?? '';
8585
$valueToSign = $aliasCC . @$body['merchantId'] . @$body['amount'] . @$body['currency'] . @$body['refno'];
8686
$expectedSign = hash_hmac('sha256', mb_trim($valueToSign), hex2bin(mb_trim($key)));
87-
if ($expectedSign !== $body['sign']) {
87+
if (!hash_equals($expectedSign, $body['sign'])) {
8888
throw new Exception('Invalid HMAC signature');
8989
}
9090
}

0 commit comments

Comments
 (0)