Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/HOTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class HOTP
*/
public static function generateByCounter(string $key, int $counter): HOTPResult
{
// the counter value can be more than one byte long,
// The counter value can be more than one byte long,
// so we need to pack it down properly.
$curCounter = [ 0, 0, 0, 0, 0, 0, 0, 0 ];
for ($i = 7; $i >= 0; $i--) {
Expand Down Expand Up @@ -69,7 +69,7 @@ public static function generateByTime(string $key, int $window, $timestamp = fal
* @param int $min the minimum window to accept before $timestamp
* @param int $max the maximum window to accept after $timestamp
* @param int|false $timestamp a timestamp to calculate for, defaults to time()
* @return array of HOTPResult
* @return HOTPResult[]
*/
public static function generateByTimeWindow(string $key, int $window, int $min = -1, int $max = 1, $timestamp = false): array
{
Expand Down
8 changes: 0 additions & 8 deletions src/HOTPResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ class HOTPResult
protected $decimal;
protected $hex;

/**
* Build an HOTP Result
* @param string $value the value to construct with
* @codeCoverageIgnore
*/
public function __construct(string $value)
{
// store raw
Expand All @@ -32,7 +27,6 @@ public function __construct(string $value)

/**
* Returns the string version of the HOTP
* @return string
*/
public function toString(): string
{
Expand All @@ -41,7 +35,6 @@ public function toString(): string

/**
* Returns the hex version of the HOTP
* @return string
*/
public function toHex(): string
{
Expand All @@ -53,7 +46,6 @@ public function toHex(): string

/**
* Returns the decimal version of the HOTP
* @return int
*/
public function toDec(): int
{
Expand Down
32 changes: 6 additions & 26 deletions tests/HOTPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* @copyright 2020
* @license BSD-3-Clause
* @version 1.0
*
* @covers \jakobo\HOTP\HOTP
* @covers \jakobo\HOTP\HOTPResult
*/
class HOTPTest extends TestCase
{
Expand Down Expand Up @@ -100,17 +103,7 @@ public function provideHOTP(): array
];
}

/**
* @param int $seed
* @param array $result
*
* @covers \jakobo\HOTP\HOTP::generateByCounter
* @covers \jakobo\HOTP\HOTPResult::toString
* @covers \jakobo\HOTP\HOTPResult::toHex
* @covers \jakobo\HOTP\HOTPResult::toDec
* @covers \jakobo\HOTP\HOTPResult::toHOTP
* @dataProvider provideHOTP
*/
/** @dataProvider provideHOTP */
public function testHOTP(int $seed, array $result): void
{
$hotp = HOTP::generateByCounter(self::KEY, $seed);
Expand Down Expand Up @@ -147,14 +140,7 @@ public function provideTOTP(): array
];
}

/**
* @param string $seed
* @param string $result
*
* @covers \jakobo\HOTP\HOTP::generateByTime
* @covers \jakobo\HOTP\HOTPResult::toHOTP
* @dataProvider provideTOTP
*/
/** @dataProvider provideTOTP */
public function testTOTP(string $seed, string $result): void
{
$totp = HOTP::generateByTime(self::KEY, 30, $seed);
Expand Down Expand Up @@ -183,13 +169,7 @@ public function provideGenerateByTimeWindow(): array
];
}

/**
* @param string $seed
* @param string[] $result
* @covers \jakobo\HOTP\HOTP::generateByTimeWindow
* @covers \jakobo\HOTP\HOTPResult::toHOTP
* @dataProvider provideGenerateByTimeWindow
*/
/** @dataProvider provideGenerateByTimeWindow */
public function testGenerateByTimeWindow(string $seed, array $result): void
{
$results = HOTP::generateByTimeWindow(
Expand Down