summaryrefslogtreecommitdiffstats
path: root/Auth/OpenID/HMAC.php
diff options
context:
space:
mode:
Diffstat (limited to 'Auth/OpenID/HMAC.php')
-rw-r--r--Auth/OpenID/HMAC.php7
1 files changed, 7 insertions, 0 deletions
diff --git a/Auth/OpenID/HMAC.php b/Auth/OpenID/HMAC.php
index e9779bd..e6c4bdf 100644
--- a/Auth/OpenID/HMAC.php
+++ b/Auth/OpenID/HMAC.php
@@ -60,6 +60,13 @@ function Auth_OpenID_HMACSHA1($key, $text)
$key = Auth_OpenID_SHA1($key, true);
}
+ if (function_exists('hash_hmac') &&
+ function_exists('hash_algos') &&
+ (in_array('sha1', hash_algos()))) {
+ return hash_hmac('sha1', $text, $key, true);
+ }
+ // Home-made solution
+
$key = str_pad($key, Auth_OpenID_SHA1_BLOCKSIZE, chr(0x00));
$ipad = str_repeat(chr(0x36), Auth_OpenID_SHA1_BLOCKSIZE);
$opad = str_repeat(chr(0x5c), Auth_OpenID_SHA1_BLOCKSIZE);