1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2025-03-05 15:29:20 +01:00

Refactor.

- simplify and avoid using different arrays with same values.

- build $otpParams from $otpinfo as soon as we have ksm result,
	then unset $otpinfo.

- futher down, only use $otpParams and $localParams.
This commit is contained in:
Jean Paul Galea 2015-09-15 18:29:55 +00:00
parent 8f8b8b8e8c
commit c46d13da17

View File

@ -341,6 +341,7 @@ $otpParams = array(
'yk_high' => $otpinfo['high'], 'yk_high' => $otpinfo['high'],
'yk_low' => $otpinfo['low'] 'yk_low' => $otpinfo['low']
); );
unset($otpinfo);
/* First check if OTP is seen with the same nonce, in such case we have an replayed request */ /* First check if OTP is seen with the same nonce, in such case we have an replayed request */
@ -422,7 +423,7 @@ if ($syncres == False)
// check the time stamp // check the time stamp
if ($otpParams['yk_counter'] == $localParams['yk_counter'] && $otpParams['yk_use'] > $localParams['yk_use']) if ($otpParams['yk_counter'] == $localParams['yk_counter'] && $otpParams['yk_use'] > $localParams['yk_use'])
{ {
$ts = ($otpinfo['high'] << 16) + $otpinfo['low']; $ts = ($otpParams['yk_high'] << 16) + $otpParams['yk_low'];
$seenTs = ($localParams['yk_high'] << 16) + $localParams['yk_low']; $seenTs = ($localParams['yk_high'] << 16) + $localParams['yk_low'];
$tsDiff = $ts - $seenTs; $tsDiff = $ts - $seenTs;
$tsDelta = $tsDiff * TS_SEC; $tsDelta = $tsDiff * TS_SEC;
@ -476,7 +477,7 @@ if ($protocol_version >= 2.0)
if ($timestamp == 1) if ($timestamp == 1)
{ {
$extra['timestamp'] = ($otpinfo['high'] << 16) + $otpinfo['low']; $extra['timestamp'] = ($otpParams['yk_high'] << 16) + $otpParams['yk_low'];
$extra['sessioncounter'] = $otpParams['yk_counter']; $extra['sessioncounter'] = $otpParams['yk_counter'];
$extra['sessionuse'] = $otpParams['yk_use']; $extra['sessionuse'] = $otpParams['yk_use'];
} }