/** * @dataProvider testVerifyData */ public function testVerify($secret, $input, $output, $expectedResult) { $totp = new TOTP($secret); $this->assertEquals($expectedResult, $totp->verify($output, $input)); }
/** * Verify one time code using the otp instance * @param $one_time_code * @param TOTP|null $totp * @return bool */ public function verifyCode($one_time_code, TOTP $totp = null) { if ($totp !== null) { return $totp->verify($one_time_code); } else { return $this->totp->verify($one_time_code); } }
public function onValidateOneTimePassword($value) { switch ($this->oneTimePasswordType) { case TwoFactorAuthentication::OTP_HOTP: $oneTimePassword = new HOTP('', $this->getOneTimePasswordCode()); break; case TwoFactorAuthentication::OTP_TOTP: $oneTimePassword = new TOTP('', $this->getOneTimePasswordCode()); break; default: throw new RuntimeException('No valid OTP type set: ' . $this->oneTimePasswordType); } return $oneTimePassword->verify($value); }