mirror of
https://github.com/Yubico/yubikey-val.git
synced 2025-02-21 15:54:15 +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
|
Send out requests
|
||||||
*/
|
*/
|
||||||
if (count($urls)>=$ans_req) $ans_arr=$this->retrieveURLasync($urls, $ans_req, $timeout);
|
$ans_arr=$this->retrieveURLasync($urls, $ans_req, $timeout);
|
||||||
else return false;
|
|
||||||
|
|
||||||
if (!is_array($ans_arr)) {
|
if (!is_array($ans_arr)) {
|
||||||
$this->log('warning', 'No responses from validation server pool');
|
$this->log('warning', 'No responses from validation server pool');
|
||||||
|
@ -33,13 +33,8 @@ $timestamp = getHttpVal('timestamp', 0);
|
|||||||
if ($protocol_version>=2.0) {
|
if ($protocol_version>=2.0) {
|
||||||
|
|
||||||
$sl = getHttpVal('sl', '');
|
$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', '');
|
$timeout = getHttpVal('timeout', '');
|
||||||
|
|
||||||
if (!$timeout) $timeout=$baseParams['__YKVAL_SYNC_DEFAULT_TIMEOUT__'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//// Get Client info from DB
|
//// Get Client info from DB
|
||||||
@ -71,6 +66,7 @@ if ($h != '') {
|
|||||||
if ($timestamp) $a['timestamp'] = $timestamp;
|
if ($timestamp) $a['timestamp'] = $timestamp;
|
||||||
if ($sl) $a['sl'] = $sl;
|
if ($sl) $a['sl'] = $sl;
|
||||||
if ($timeout) $a['timeout'] = $timeout;
|
if ($timeout) $a['timeout'] = $timeout;
|
||||||
|
|
||||||
$hmac = sign($a, $apiKey);
|
$hmac = sign($a, $apiKey);
|
||||||
// Compare it
|
// Compare it
|
||||||
if ($hmac != $h) {
|
if ($hmac != $h) {
|
||||||
@ -203,13 +199,19 @@ if (!$sync->queue($otpParams, $localParams)) {
|
|||||||
exit;
|
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();
|
$nr_servers=$sync->getNumberOfServers();
|
||||||
$req_answers=ceil($nr_servers*$sl/100);
|
$req_answers=ceil($nr_servers*$sl/100.0);
|
||||||
if ($req_answers>0) {
|
if ($req_answers>0) {
|
||||||
$syncres=$sync->sync($req_answers, $timeout);
|
$syncres=$sync->sync($req_answers, $timeout);
|
||||||
$nr_answers=$sync->getNumberOfAnswers();
|
$nr_answers=$sync->getNumberOfAnswers();
|
||||||
$nr_valid_answers=$sync->getNumberOfValidAnswers();
|
$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 {
|
} else {
|
||||||
$nr_answers=0;
|
$nr_answers=0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user