summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortherealssj <mehul.guptagm@gmail.com>2016-06-09 19:51:22 +0530
committertherealssj <mehul.guptagm@gmail.com>2016-06-09 19:51:22 +0530
commitd16a2d9c2f5929ea25474987419b06dc23c76b6f (patch)
treef1f19445016586af29ad241c3475cf4ef4c00e73 /src
parent352d99292defaee6b704084d2cea45b8836a90fd (diff)
downloadotp-d16a2d9c2f5929ea25474987419b06dc23c76b6f.zip
otp-d16a2d9c2f5929ea25474987419b06dc23c76b6f.tar.gz
otp-d16a2d9c2f5929ea25474987419b06dc23c76b6f.tar.bz2
Minor Fixes and Updated Tests
Diffstat (limited to 'src')
-rw-r--r--src/Otp.php12
-rw-r--r--src/OtpInterface.php2
2 files changed, 9 insertions, 5 deletions
diff --git a/src/Otp.php b/src/Otp.php
index 0a2b599..1df9782 100644
--- a/src/Otp.php
+++ b/src/Otp.php
@@ -62,8 +62,8 @@ class Otp implements OtpInterface
*/
public function hotp($secret, $counter)
{
- if (!is_numeric($counter)) {
- throw new \InvalidArgumentException('Counter must be integer');
+ if (!is_numeric($counter) || $counter < 0) {
+ throw new \InvalidArgumentException('Invalid counter supplied');
}
$hash = hash_hmac(
@@ -96,10 +96,14 @@ class Otp implements OtpInterface
return $this->safeCompare($this->hotp($secret, $counter), $key);
}
+
+ /* (non-PHPdoc)
+ * @see Otp.OtpInterface::checkHotpResync()
+ */
public function checkHotpResync($secret, $counter, $key, $counterwindow = 2)
{
- if (!is_numeric($counter)) {
- throw new \InvalidArgumentException('Counter must be integer');
+ if (!is_numeric($counter) || $counter < 0) {
+ throw new \InvalidArgumentException('Invalid counter supplied');
}
if(!is_numeric($counterwindow) || $counterwindow < 0){
diff --git a/src/OtpInterface.php b/src/OtpInterface.php
index b91b5f1..e241d5d 100644
--- a/src/OtpInterface.php
+++ b/src/OtpInterface.php
@@ -48,7 +48,7 @@ interface OtpInterface
* @param integer $counter Counter
* @param string $key User supplied key
*
- * @return boolean the counter if key is correct else false
+ * @return boolean True if key is correct
*/
function checkHotp($secret, $counter, $key);