1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2025-03-21 13:29:38 +01:00
This commit is contained in:
Simon Josefsson 2009-03-11 01:42:23 +00:00
parent 9c93865799
commit 21178250da
2 changed files with 16 additions and 22 deletions

View File

@ -1,4 +1,5 @@
<?php
define('S_OK', 'OK');
define('S_BAD_OTP', 'BAD_OTP');
define('S_REPLAYED_OTP', 'REPLAYED_OTP');
@ -8,12 +9,12 @@ define('S_MISSING_PARAMETER', 'MISSING_PARAMETER');
define('S_NO_SUCH_CLIENT', 'NO_SUCH_CLIENT');
define('S_OPERATION_NOT_ALLOWED', 'OPERATION_NOT_ALLOWED');
define('S_BACKEND_ERROR', 'BACKEND_ERROR');
define('TS_SEC', 0.119);
define('TS_SEC', 1/8);
define('TS_REL_TOLERANCE', 0.3);
define('TS_ABS_TOLERANCE', 20);
define('DEVICE_ID_LEN', 12);
require_once 'config.php';
define('DEVICE_ID_LEN', 12);
function unescape($s) {
return str_replace('\\', "", $s);
@ -30,19 +31,6 @@ function getHttpVal($key, $defaultVal) {
return $v;
}
/////////////////////
//
// DB Related
//
///////////////////
$conn = mysql_connect($baseParams['__DB_HOST__'],
$baseParams['__DB_USER__'],
$baseParams['__DB_PW__'])
or die('Could not connect to database: ' . mysql_error());
mysql_select_db($baseParams['__DB_NAME__'], $conn)
or die('Could not select database');
function query($q) {
global $conn;
debug('Query: '.$q);
@ -117,11 +105,9 @@ function modhex2b64 ($modhex_str) {
return hex2b64($hex_str);
}
// decryptOTP using YK-KSM
function decryptOTP($otp) {
global $baseParams;
$url = $baseParams['__YKKMS_URL__'] . $otp;
// $otp: A yubikey OTP
function decryptOTP($otp, $base_url) {
$url = $base_url . $otp;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERAGENT, "YK-VAL");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

View File

@ -1,10 +1,18 @@
<?php
require_once 'common.php';
require_once 'config.php';
header("content-type: text/plain");
debug("Request: " . $_SERVER['QUERY_STRING']);
$conn = mysql_connect($baseParams['__DB_HOST__'],
$baseParams['__DB_USER__'],
$baseParams['__DB_PW__'])
or die('Could not connect to database: ' . mysql_error());
mysql_select_db($baseParams['__DB_NAME__'], $conn)
or die('Could not select database');
//// Extract values from HTTP request
//
$client = getHttpVal('id', 0);
@ -71,7 +79,7 @@ if ($ad == null) {
//// Decode OTP from input
//
$otpinfo = decryptOTP($otp);
$otpinfo = decryptOTP($otp, $baseParams['__YKKMS_URL__']);
if (!is_array($otpinfo)) {
sendResp(S_BACKEND_ERROR);
exit;