mirror of
https://github.com/Yubico/yubikey-val.git
synced 2025-02-20 21:54:20 +01:00
Corrected calculation of hmac with extra parameters (protocol v. 2). Corrected calculation of sl return value (use float inside)
This commit is contained in:
parent
8a22c88648
commit
7be831db12
@ -321,8 +321,7 @@ class SyncLib
|
||||
/*
|
||||
Send out requests
|
||||
*/
|
||||
if (count($urls)>=$ans_req) $ans_arr=$this->retrieveURLasync($urls, $ans_req, $timeout);
|
||||
else return false;
|
||||
$ans_arr=$this->retrieveURLasync($urls, $ans_req, $timeout);
|
||||
|
||||
if (!is_array($ans_arr)) {
|
||||
$this->log('warning', 'No responses from validation server pool');
|
||||
|
@ -33,13 +33,8 @@ $timestamp = getHttpVal('timestamp', 0);
|
||||
if ($protocol_version>=2.0) {
|
||||
|
||||
$sl = getHttpVal('sl', '');
|
||||
if (strcasecmp($sl, 'fast')==0) $sl=$baseParams['__YKVAL_SYNC_FAST_LEVEL__'];
|
||||
if (strcasecmp($sl, 'secure')==0) $sl=$baseParams['__YKVAL_SYNC_SECURE_LEVEL__'];
|
||||
if (!$sl) $sl=$baseParams['__YKVAL_SYNC_DEFAULT_LEVEL__'];
|
||||
|
||||
$timeout = getHttpVal('timeout', '');
|
||||
|
||||
if (!$timeout) $timeout=$baseParams['__YKVAL_SYNC_DEFAULT_TIMEOUT__'];
|
||||
}
|
||||
|
||||
//// Get Client info from DB
|
||||
@ -71,6 +66,7 @@ if ($h != '') {
|
||||
if ($timestamp) $a['timestamp'] = $timestamp;
|
||||
if ($sl) $a['sl'] = $sl;
|
||||
if ($timeout) $a['timeout'] = $timeout;
|
||||
|
||||
$hmac = sign($a, $apiKey);
|
||||
// Compare it
|
||||
if ($hmac != $h) {
|
||||
@ -203,13 +199,19 @@ if (!$sync->queue($otpParams, $localParams)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Change default protocol "strings" to numeric values */
|
||||
if (strcasecmp($sl, 'fast')==0) $sl=$baseParams['__YKVAL_SYNC_FAST_LEVEL__'];
|
||||
if (strcasecmp($sl, 'secure')==0) $sl=$baseParams['__YKVAL_SYNC_SECURE_LEVEL__'];
|
||||
if (!$sl) $sl=$baseParams['__YKVAL_SYNC_DEFAULT_LEVEL__'];
|
||||
if (!$timeout) $timeout=$baseParams['__YKVAL_SYNC_DEFAULT_TIMEOUT__'];
|
||||
|
||||
$nr_servers=$sync->getNumberOfServers();
|
||||
$req_answers=ceil($nr_servers*$sl/100);
|
||||
$req_answers=ceil($nr_servers*$sl/100.0);
|
||||
if ($req_answers>0) {
|
||||
$syncres=$sync->sync($req_answers, $timeout);
|
||||
$nr_answers=$sync->getNumberOfAnswers();
|
||||
$nr_valid_answers=$sync->getNumberOfValidAnswers();
|
||||
$sl_success_rate=floor($nr_valid_answers / $nr_servers * 100);
|
||||
$sl_success_rate=floor(100.0 * $nr_valid_answers / $nr_servers);
|
||||
|
||||
} else {
|
||||
$nr_answers=0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user