From 310c18e6bbd8e7f78a0a45f0501cb1dc6fab2159 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 20 Jun 2018 18:27:34 +0300 Subject: move OTPHP to vendor/; additionally move Base32 class to OTPHP namespace --- vendor/OTPHP/HOTP.php | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 vendor/OTPHP/HOTP.php (limited to 'vendor/OTPHP/HOTP.php') diff --git a/vendor/OTPHP/HOTP.php b/vendor/OTPHP/HOTP.php new file mode 100644 index 000000000..7092fd9ff --- /dev/null +++ b/vendor/OTPHP/HOTP.php @@ -0,0 +1,74 @@ +generateOTP($count); + } + + + /** + * Verify if a password is valid for a specific counter value + * + * @param integer $otp the one-time password + * @param integer $counter the counter value + * @return bool true if the counter is valid, false otherwise + */ + public function verify($otp, $counter) { + return ($otp == $this->at($counter)); + } + + /** + * Returns the uri for a specific secret for hotp method. + * Can be encoded as a image for simple configuration in + * Google Authenticator. + * + * @param string $name the name of the account / profile + * @param integer $initial_count the initial counter + * @return string the uri for the hmac secret + */ + public function provisioning_uri($name, $initial_count) { + return "otpauth://hotp/".urlencode($name)."?secret={$this->secret}&counter=$initial_count"; + } + } + +} -- cgit v1.2.3-54-g00ecf