Commit 4224556f authored by Franco Fichtner's avatar Franco Fichtner

src: style sweep

parent 44c26e6d
...@@ -85,7 +85,7 @@ class LocalTOTP extends Local ...@@ -85,7 +85,7 @@ class LocalTOTP extends Local
$start = -1 * $this->graceperiod; $start = -1 * $this->graceperiod;
} }
$now = time(); $now = time();
for ($count = $start ; $count <= $this->graceperiod ; $count += $step) { for ($count = $start; $count <= $this->graceperiod; $count += $step) {
$result[] = $now + $count; $result[] = $now + $count;
if ($this->graceperiod == 0) { if ($this->graceperiod == 0) {
// special case, we expect the clocks to match 100%, so step and target are both 0 // special case, we expect the clocks to match 100%, so step and target are both 0
...@@ -104,10 +104,10 @@ class LocalTOTP extends Local ...@@ -104,10 +104,10 @@ class LocalTOTP extends Local
{ {
// calculate binary 8 character time for provided window // calculate binary 8 character time for provided window
$binary_time = pack("N", (int)($moment/$this->timeWindow)); $binary_time = pack("N", (int)($moment/$this->timeWindow));
$binary_time = str_pad($binary_time,8, chr(0), STR_PAD_LEFT); $binary_time = str_pad($binary_time, 8, chr(0), STR_PAD_LEFT);
// Generate the hash using the SHA1 algorithm // Generate the hash using the SHA1 algorithm
$hash = hash_hmac ('sha1', $binary_time, $secret, true); $hash = hash_hmac('sha1', $binary_time, $secret, true);
$offset = ord($hash[19]) & 0xf; $offset = ord($hash[19]) & 0xf;
$otp = ( $otp = (
((ord($hash[$offset+0]) & 0x7f) << 24 ) | ((ord($hash[$offset+0]) & 0x7f) << 24 ) |
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment