Skip to content

Commit 4149bd2

Browse files
committed
🚿
1 parent 3ba7987 commit 4149bd2

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Profit!
4545
### Create a secret
4646
The secret is usually being created once during the activation process in a user control panel.
4747
So all you need to do there is to display it to the user in a convenient way -
48-
as a text string and QR code for example - and save it somewhere with the user data.
48+
as a text string and [QR code](https://github.com/chillerlan/php-qrcode/blob/9964cf8ff1ad90d17c360bd320cf18e16cd59829/examples/authenticator.php) for example - and save it somewhere with the user data.
4949
```php
5050
use chillerlan\Authenticator\{Authenticator, AuthenticatorOptions};
5151

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
@@ -43,7 +43,9 @@ public function getHMAC(int $counter):string{
4343
}
4444
// @codeCoverageIgnoreStart
4545
$data = (PHP_INT_SIZE < 8)
46+
// 32-bit
4647
? "\x00\x00\x00\x00".pack('N', $counter)
48+
// 64-bit
4749
: pack('J', $counter);
4850
// @codeCoverageIgnoreEnd
4951
return hash_hmac($this->options->algorithm, $data, $this->secret, true);
@@ -60,8 +62,8 @@ public function getCode(string $hmac):int{
6062
}
6163

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

6769
/**

0 commit comments

Comments
 (0)