Index: modules/openid/openid.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/openid/openid.inc,v
retrieving revision 1.14
diff -u -r1.14 openid.inc
--- modules/openid/openid.inc	29 Apr 2009 07:22:49 -0000	1.14
+++ modules/openid/openid.inc	29 Apr 2009 08:04:17 -0000
@@ -266,15 +266,21 @@
 }
 
 function _openid_hmac($key, $text) {
-  if (strlen($key) > OPENID_SHA1_BLOCKSIZE) {
-    $key = sha1($key, TRUE);
+  // If hash extension is available use it here for performance.
+  if (function_exists('hash_hmac')) {
+    $hmac = hash_hmac('sha1', $text, $key, TRUE);
+  }
+  else {
+    if (strlen($key) > OPENID_SHA1_BLOCKSIZE) {
+      $key = sha1($key, TRUE);
+    }
+  
+    $key = str_pad($key, OPENID_SHA1_BLOCKSIZE, chr(0x00));
+    $ipad = str_repeat(chr(0x36), OPENID_SHA1_BLOCKSIZE);
+    $opad = str_repeat(chr(0x5c), OPENID_SHA1_BLOCKSIZE);
+    $hash1 = sha1(($key ^ $ipad) . $text, TRUE);
+    $hmac = sha1(($key ^ $opad) . $hash1, TRUE);
   }
-
-  $key = str_pad($key, OPENID_SHA1_BLOCKSIZE, chr(0x00));
-  $ipad = str_repeat(chr(0x36), OPENID_SHA1_BLOCKSIZE);
-  $opad = str_repeat(chr(0x5c), OPENID_SHA1_BLOCKSIZE);
-  $hash1 = sha1(($key ^ $ipad) . $text, TRUE);
-  $hmac = sha1(($key ^ $opad) . $hash1, TRUE);
 
   return $hmac;
 }
