Skip to content

Commit ba3a200

Browse files
committed
🚿
1 parent ad87a07 commit ba3a200

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/AuthenticatorOptionsTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ protected function set_adjacent(int $adjacent):void{
167167
* @throws \InvalidArgumentException
168168
*/
169169
protected function set_secret_length(int $secret_length):void{
170-
// ~ 80 to 640 bits
170+
171171
if($secret_length < 16 || $secret_length > 1024){
172172
throw new InvalidArgumentException('Invalid secret length: '.$secret_length);
173173
}

src/Authenticators/HOTP.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public function getHMAC(int $counter):string{
4444
}
4545
// @codeCoverageIgnoreStart
4646
$data = (PHP_INT_SIZE < 8)
47+
// 32-bit
4748
? "\x00\x00\x00\x00".pack('N', $counter)
49+
// 64-bit
4850
: pack('J', $counter);
4951
// @codeCoverageIgnoreEnd
5052
return hash_hmac($this->options->algorithm, $data, $this->secret, true);
@@ -61,8 +63,8 @@ public function getCode(#[SensitiveParameter] string $hmac):int{
6163
}
6264

6365
$b = ($data[strlen($hmac)] & 0xF);
64-
// phpcs:ignore
65-
return (($data[$b + 1] & 0x7F) << 24) | ($data[$b + 2] << 16) | ($data[$b + 3] << 8) | $data[$b + 4];
66+
67+
return (($data[$b + 1] & 0x7F) << 24) | ($data[$b + 2] << 16) | ($data[$b + 3] << 8) | $data[$b + 4]; // phpcs:ignore
6668
}
6769

6870
/**

0 commit comments

Comments
 (0)