diff --git a/sign_demo.php b/sign_demo.php index 9797a88..732da8f 100644 --- a/sign_demo.php +++ b/sign_demo.php @@ -1,37 +1,76 @@ -

Generate a signature

- -'. - ''. - 'api key: (use your api key issued to you by Yubico in b64 format): ' . - '

'. - 'id (your client id):

'. - 'otp:

'. - ''. - ''; - exit; +if ($act == 'sign_req') { + $id = getHttpVal('id', ''); + $otp = getHttpVal('otp', ''); + $t = getHttpVal('t', ''); + $apiKey = base64_decode(getHttpVal('apikey', '')); + + $a['id'] = $id; + $a['otp'] = $otp; + + if ($t != '') { + $a['t'] = $t; + } + + $hmac = sign($a, $apiKey, true); + +// echo 'Test submit the request >> '; + +} else if ($act == 'sign_resp') { + $status = getHttpVal('status', ''); + $t = getHttpVal('t', ''); + $info = getHttpVal('info', ''); + $apiKey = base64_decode(getHttpVal('apikey', '')); + + $a['status'] = $status; + $a['t'] = $t; + + if ($info != '') { + $a['info'] = $info; + } + + $hmac = sign($a, $apiKey, true); } -$id = getHttpVal('id', ''); -$otp = getHttpVal('otp', ''); -$t = getHttpVal('t', ''); -$apiKey = base64_decode(getHttpVal('apikey', '')); +echo '


'; -$a['id']=$id; -$a['otp']=$otp; - -if ($t != '') { - $a['t']=$t; -} - -$hmac = sign($a, $apiKey, true); +echo '

Generate a request signature

'. + '
' . + '' . + 'api key: (use your api key issued to you by Yubico in b64 format): ' . + '

' . + 'id (your client id):

' . + 'otp:

' . + '' . + '

'. + '

Generate a response signature

'. + '
' . + '' . + 'api key: (put your api key here in b64 format): ' . + '

' . + 'Status:

'. + 'Time stamp:

' . + 'info:

' . + '' . + '

'. + '
'; ?>