From 38c048b833a89d0dc500a19bc70b146d34ef5826 Mon Sep 17 00:00:00 2001 From: Jean Paul Galea Date: Fri, 17 Jul 2015 21:17:29 +0200 Subject: [PATCH] Cosmetic changes. --- ykval-verify.php | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/ykval-verify.php b/ykval-verify.php index ecf5afa..b30b967 100644 --- a/ykval-verify.php +++ b/ykval-verify.php @@ -218,45 +218,51 @@ if ($h != '') { /* We need to add necessary parameters not available at earlier protocols after signature is computed. */ -if ($protocol_version<2.0) { - /* We need to create a nonce manually here */ - $nonce = md5(uniqid(rand())); - $myLog->log(LOG_INFO, 'protocol version below 2.0. Created nonce ' . $nonce); - } +if ($protocol_version < 2.0) +{ + /* We need to create a nonce manually here */ + $nonce = md5(uniqid(rand())); + $myLog->log(LOG_INFO, 'protocol version below 2.0. Created nonce ' . $nonce); +} //// Which YK-KSM should we talk to? // $urls = otp2ksmurls ($otp, $client); -if (!is_array($urls)) { - sendResp(S_BACKEND_ERROR, $myLog, $apiKey); +if (!is_array($urls)) +{ + sendResp(S_BACKEND_ERROR, $myLog, $apiKey); } //// Decode OTP from input // $curlopts = array(); -if (array_key_exists('__YKVAL_KSM_CURL_OPTS__', $baseParams)) { - $curlopts = $baseParams['__YKVAL_KSM_CURL_OPTS__']; +if (array_key_exists('__YKVAL_KSM_CURL_OPTS__', $baseParams)) +{ + $curlopts = $baseParams['__YKVAL_KSM_CURL_OPTS__']; } $otpinfo = KSMdecryptOTP($urls, $myLog, $curlopts); -if (!is_array($otpinfo)) { - sendResp(S_BAD_OTP, $myLog, $apiKey); +if (!is_array($otpinfo)) +{ + sendResp(S_BAD_OTP, $myLog, $apiKey); } $myLog->log(LOG_DEBUG, "Decrypted OTP:", $otpinfo); //// Get Yubikey from DB // $devId = substr($otp, 0, strlen ($otp) - TOKEN_LEN); -$yk_publicname=$devId; +$yk_publicname = $devId; $localParams = $sync->getLocalParams($yk_publicname); -if (!$localParams) { - $myLog->log(LOG_NOTICE, 'Invalid Yubikey ' . $yk_publicname); - sendResp(S_BACKEND_ERROR, $myLog, $apiKey); - } +if (!$localParams) +{ + $myLog->log(LOG_NOTICE, 'Invalid Yubikey ' . $yk_publicname); + sendResp(S_BACKEND_ERROR, $myLog, $apiKey); +} $myLog->log(LOG_DEBUG, "Auth data:", $localParams); -if ($localParams['active'] != 1) { - $myLog->log(LOG_NOTICE, 'De-activated Yubikey ' . $devId); - sendResp(S_BAD_OTP, $myLog, $apiKey); +if ($localParams['active'] != 1) +{ + $myLog->log(LOG_NOTICE, 'De-activated Yubikey ' . $devId); + sendResp(S_BAD_OTP, $myLog, $apiKey); } /* Build OTP params */