1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2025-02-27 06:54:16 +01:00

Cosmetic changes.

This commit is contained in:
Jean Paul Galea 2015-07-17 21:16:40 +02:00
parent f3fc957431
commit be27f62236

View File

@ -261,44 +261,49 @@ if ($localParams['active'] != 1) {
/* Build OTP params */ /* Build OTP params */
$otpParams=array('modified'=>time(), $otpParams = array(
'otp'=>$otp, 'modified' => time(),
'nonce'=>$nonce, 'otp' => $otp,
'yk_publicname'=>$devId, 'nonce' => $nonce,
'yk_counter'=>$otpinfo['session_counter'], 'yk_publicname' => $devId,
'yk_use'=>$otpinfo['session_use'], 'yk_counter' => $otpinfo['session_counter'],
'yk_high'=>$otpinfo['high'], 'yk_use' => $otpinfo['session_use'],
'yk_low'=>$otpinfo['low']); 'yk_high' => $otpinfo['high'],
'yk_low' => $otpinfo['low']
);
/* 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 */
if ($sync->countersEqual($localParams, $otpParams) && if ($sync->countersEqual($localParams, $otpParams) && $localParams['nonce']==$otpParams['nonce'])
$localParams['nonce']==$otpParams['nonce']) { {
$myLog->log(LOG_WARNING, 'Replayed request'); $myLog->log(LOG_WARNING, 'Replayed request');
sendResp(S_REPLAYED_REQUEST, $myLog, $apiKey, $extra); sendResp(S_REPLAYED_REQUEST, $myLog, $apiKey, $extra);
} }
/* Check the OTP counters against local db */ /* Check the OTP counters against local db */
if ($sync->countersHigherThanOrEqual($localParams, $otpParams)) { if ($sync->countersHigherThanOrEqual($localParams, $otpParams))
{
$sync->log(LOG_WARNING, 'replayed OTP: Local counters higher'); $sync->log(LOG_WARNING, 'replayed OTP: Local counters higher');
$sync->log(LOG_WARNING, 'replayed OTP: Local counters ', $localParams); $sync->log(LOG_WARNING, 'replayed OTP: Local counters ', $localParams);
$sync->log(LOG_WARNING, 'replayed OTP: Otp counters ', $otpParams); $sync->log(LOG_WARNING, 'replayed OTP: Otp counters ', $otpParams);
sendResp(S_REPLAYED_OTP, $myLog, $apiKey, $extra); sendResp(S_REPLAYED_OTP, $myLog, $apiKey, $extra);
} }
/* Valid OTP, update database. */ /* Valid OTP, update database. */
if(!$sync->updateDbCounters($otpParams)) { if (!$sync->updateDbCounters($otpParams))
{
$myLog->log(LOG_CRIT, "Failed to update yubikey counters in database"); $myLog->log(LOG_CRIT, "Failed to update yubikey counters in database");
sendResp(S_BACKEND_ERROR, $myLog, $apiKey); sendResp(S_BACKEND_ERROR, $myLog, $apiKey);
} }
/* Queue sync requests */ /* Queue sync requests */
if (!$sync->queue($otpParams, $localParams)) { if (!$sync->queue($otpParams, $localParams))
{
$myLog->log(LOG_CRIT, "ykval-verify:critical:failed to queue sync requests"); $myLog->log(LOG_CRIT, "ykval-verify:critical:failed to queue sync requests");
sendResp(S_BACKEND_ERROR, $myLog, $apiKey); sendResp(S_BACKEND_ERROR, $myLog, $apiKey);
} }
$nr_servers=$sync->getNumberOfServers(); $nr_servers=$sync->getNumberOfServers();
$req_answers=ceil($nr_servers*$sl/100.0); $req_answers=ceil($nr_servers*$sl/100.0);
@ -384,13 +389,16 @@ if ($sessionCounter == $seenSessionCounter && $sessionUse > $seenSessionUse) {
} }
/* Fill up with more respone parameters */ /* Fill up with more respone parameters */
if ($protocol_version>=2.0) { if ($protocol_version >= 2.0)
{
$extra['sl'] = $sl_success_rate; $extra['sl'] = $sl_success_rate;
} }
if ($timestamp==1){
if ($timestamp == 1)
{
$extra['timestamp'] = ($otpinfo['high'] << 16) + $otpinfo['low']; $extra['timestamp'] = ($otpinfo['high'] << 16) + $otpinfo['low'];
$extra['sessioncounter'] = $sessionCounter; $extra['sessioncounter'] = $sessionCounter;
$extra['sessionuse'] = $sessionUse; $extra['sessionuse'] = $sessionUse;
} }
sendResp(S_OK, $myLog, $apiKey, $extra); sendResp(S_OK, $myLog, $apiKey, $extra);