diff --git a/add_key.php b/add_key.php
new file mode 100644
index 0000000..e535f96
--- /dev/null
+++ b/add_key.php
@@ -0,0 +1,101 @@
+ 0) {
+ debug('Key '.$keyid.' added');
+ reply(S_OK, $ci['secret'], $client, $nonce);
+} else {
+ reply(S_BACKEND_ERROR, $ci['secret'], $client, $nonce);
+ exit;
+}
+
+function reply($status, $apiKey, $client_id, $nonce, $info=null) {
+ global $tokenId;
+
+ if ($status == null) {
+ $status = S_BACKEND_ERROR;
+ }
+
+ date_default_timezone_set('UTC');
+ $timestamp = date('Y-m-d\TH:i:s\ZZ', time());
+
+ //// Prepare the response to the user
+ //
+ $respParams = 'status='.$status.'&t='.$timestamp;
+
+ // Generate the signature
+ debug('API key: '.$apiKey); // API key of the client
+ debug('Signing: '.$respParams);
+ // the TRUE at the end states we want the raw value, not hexadecimal form
+ $hmac = hash_hmac('sha1', utf8_encode($respParams), $apiKey, true);
+ //outputToFile('hmac', $hmac, "b");
+ // now take that byte value and base64 encode it
+ $hmac = base64_encode($hmac);
+
+ echo 'h='.$hmac.PHP_EOL;
+ if ($info != null) {
+ echo 'info='.$info.PHP_EOL;
+ }
+ echo 'nonce='.$nonce.PHP_EOL;
+ echo 'status='.$status.PHP_EOL;
+ echo 't='.$timestamp.PHP_EOL;
+ echo PHP_EOL;
+
+} // End reply
+
+?>
diff --git a/common.php b/common.php
new file mode 100644
index 0000000..f982ca6
--- /dev/null
+++ b/common.php
@@ -0,0 +1,39 @@
+ '.$msg;
+ }
+ echo "\n";
+ }
+ if ($exit) {
+ die ('Exit
');
+ }
+}
+
+function genRandB64($len) {
+ $r = hash('sha1', rand(999,99999999));
+ $r = substr(0,$len);
+ return base64_encode($r);
+}
+
+function outputToFile($outFname, $content, $mode, $append=false) {
+ $out = fopen($outFname, ($append ? "a" : "w"));
+ fwrite($out, $content);
+ fclose($out);
+}
+?>
diff --git a/verifyOTP.php b/verifyOTP.php
index fbb00d6..d574660 100644
--- a/verifyOTP.php
+++ b/verifyOTP.php
@@ -1,16 +1,7 @@
'.$msg;
- }
- echo "\n";
- }
- if ($exit) {
- die ('Exit
');
- }
-}
-
function updDB($keyid, $new) {
$stmt = 'UPDATE yubikeys SET '.
'accessed=NOW(),'.
@@ -237,9 +213,4 @@ function updDB($keyid, $new) {
return true;
}
-function outputToFile($outFname, $content, $mode, $append=false) {
- $out = fopen($outFname, ($append ? "a" : "w"));
- fwrite($out, $content);
- fclose($out);
-}
?>