From c46d13da17d24622a0b3cc2f5c827e7ce27493e5 Mon Sep 17 00:00:00 2001 From: Jean Paul Galea Date: Tue, 15 Sep 2015 18:29:55 +0000 Subject: [PATCH] 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. --- ykval-verify.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ykval-verify.php b/ykval-verify.php index b7d0c9a..a91e740 100644 --- a/ykval-verify.php +++ b/ykval-verify.php @@ -341,6 +341,7 @@ $otpParams = array( 'yk_high' => $otpinfo['high'], 'yk_low' => $otpinfo['low'] ); +unset($otpinfo); /* 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 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']; $tsDiff = $ts - $seenTs; $tsDelta = $tsDiff * TS_SEC; @@ -476,7 +477,7 @@ if ($protocol_version >= 2.0) 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['sessionuse'] = $otpParams['yk_use']; }