Change the meaning of the window parameter to always indicate the number

of codes to check *in addition* to the current code.  Note that for TOTP,
the window goes in both directions; a window of 1 means to check the
current code plus the previous and next.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@849 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
Dag-Erling Smørgrav 2014-12-15 16:42:31 +00:00
parent e959d8c160
commit cec8549503
2 changed files with 4 additions and 4 deletions

View File

@ -121,13 +121,13 @@ oath_hotp_match(struct oath_key *k, unsigned int response, int window)
if (k == NULL)
return (-1);
if (window < 1)
if (window < 0)
return (-1);
if (k->mode != om_hotp)
return (-1);
if (k->counter >= UINT64_MAX - window)
if (k->counter >= UINT64_MAX - window - 1)
return (-1);
for (int i = 0; i < window; ++i) {
for (int i = 0; i <= window; ++i) {
code = oath_hotp(k->key, k->keylen, k->counter + i, k->digits);
if (code == response && !k->dummy) {
k->counter = k->counter + i + 1;

View File

@ -81,7 +81,7 @@ oath_totp_match(struct oath_key *k, unsigned int response, int window)
if (k == NULL)
return (-1);
if (window < 1)
if (window < 0)
return (-1);
if (k->mode != om_totp)
return (-1);