mirror of
https://github.com/Yubico/yubikey-val.git
synced 2025-02-08 03:54:20 +01:00
Refactor sign function.
- this commit might affect LOG_DEBUG message, since now we log utf8_encode($qs) not $qs. - this is probably what we want though, since we run hash_hmac on the latter.
This commit is contained in:
parent
3414c15eb4
commit
2aa06ec0a3
@ -82,19 +82,22 @@ function log_format() {
|
||||
|
||||
// Sign a http query string in the array of key-value pairs
|
||||
// return b64 encoded hmac hash
|
||||
function sign($a, $apiKey, $logger) {
|
||||
function sign($a, $apiKey, $logger)
|
||||
{
|
||||
ksort($a);
|
||||
$qs = urldecode(http_build_query($a));
|
||||
|
||||
// the TRUE at the end states we want the raw value, not hexadecimal form
|
||||
$hmac = hash_hmac('sha1', utf8_encode($qs), $apiKey, true);
|
||||
$qs = http_build_query($a);
|
||||
$qs = urldecode($qs);
|
||||
$qs = utf8_encode($qs);
|
||||
|
||||
// base64 encoded binary digest
|
||||
$hmac = hash_hmac('sha1', $qs, $apiKey, TRUE);
|
||||
$hmac = base64_encode($hmac);
|
||||
|
||||
$logger->log(LOG_DEBUG, 'SIGN: ' . $qs . ' H=' . $hmac);
|
||||
$logger->log(LOG_DEBUG, "SIGN: $qs H=$hmac");
|
||||
|
||||
return $hmac;
|
||||
|
||||
} // sign an array of query string
|
||||
}
|
||||
|
||||
function curl_settings($logger, $ident, $handle, $url, $timeout, $curlopts)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user