Skip to content

Commit

Permalink
support for mhash
Browse files Browse the repository at this point in the history
Ignore-this: 8e4cd22de2fd3c1f265ef2b0ead7e64

darcs-hash:20091103190404-7ad00-0a973b0d893ffaf5beb80008d6eab5520a0a542b.gz
  • Loading branch information
splitbrain committed Nov 3, 2009
1 parent 40f6afc commit df603a1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions syntax.php
Expand Up @@ -27,7 +27,7 @@ function getInfo(){
return array(
'author' => 'Andreas Gohr',
'email' => 'andi@splitbrain.org',
'date' => '2008-12-07',
'date' => '2009-11-03',
'name' => 'Amazon Plugin',
'desc' => 'Pull bookinfo from Amazon',
'url' => 'http://wiki.splitbrain.org/plugin:amazon',
Expand Down Expand Up @@ -281,7 +281,13 @@ function _signedRequestURI($region, $params, $public_key, $private_key){
$string_to_sign = $method."\n".$host."\n".$uri."\n".$canonicalized_query;

// calculate HMAC with SHA256 and base64-encoding
$signature = base64_encode(hash_hmac("sha256", $string_to_sign, $private_key, True));
if(function_exists('hash_hmac')){
$signature = base64_encode(hash_hmac("sha256", $string_to_sign, $private_key, true));
}elseif(function_exists('mhash')){
$signature = base64_encode(mhash(MHASH_SHA256, $string_to_sign, $private_key));
}else{
msg('missing crypto function, can\'t sign request',-1);
}

// encode the signature for the request
$signature = str_replace("%7E", "~", rawurlencode($signature));
Expand Down

0 comments on commit df603a1

Please sign in to comment.