diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-04-29 07:22:49 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-04-29 07:22:49 +0000 |
commit | 2e709fe3cddb9c17ce8ac3642d78f9f0e1698a02 (patch) | |
tree | 5ae34648c76cfe7a02c8e7c3e4fd34549b6f6e35 | |
parent | f918903428742febe2a690484d13b0ad4fa2310f (diff) | |
download | brdo-2e709fe3cddb9c17ce8ac3642d78f9f0e1698a02.tar.gz brdo-2e709fe3cddb9c17ce8ac3642d78f9f0e1698a02.tar.bz2 |
- Patch #302632 by recidive, c960657: use PHP5 functionality for _openid_sha1(). Simplified some code.
-rw-r--r-- | modules/openid/openid.inc | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/modules/openid/openid.inc b/modules/openid/openid.inc index 959a95a9f..c0ed8a936 100644 --- a/modules/openid/openid.inc +++ b/modules/openid/openid.inc @@ -267,29 +267,18 @@ function _openid_signature($association, $message_array, $keys_to_sign) { function _openid_hmac($key, $text) { if (strlen($key) > OPENID_SHA1_BLOCKSIZE) { - $key = _openid_sha1($key, TRUE); + $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 = _openid_sha1(($key ^ $ipad) . $text, TRUE); - $hmac = _openid_sha1(($key ^ $opad) . $hash1, TRUE); + $hash1 = sha1(($key ^ $ipad) . $text, TRUE); + $hmac = sha1(($key ^ $opad) . $hash1, TRUE); return $hmac; } -function _openid_sha1($text) { - $hex = sha1($text); - $raw = ''; - for ($i = 0; $i < 40; $i += 2) { - $hexcode = substr($hex, $i, 2); - $charcode = (int)base_convert($hexcode, 16, 10); - $raw .= chr($charcode); - } - return $raw; -} - function _openid_dh_base64_to_long($str) { $b64 = base64_decode($str); @@ -343,7 +332,7 @@ function _openid_dh_long_to_binary($long) { function _openid_dh_xorsecret($shared, $secret) { $dh_shared_str = _openid_dh_long_to_binary($shared); - $sha1_dh_shared = _openid_sha1($dh_shared_str); + $sha1_dh_shared = sha1($dh_shared_str, TRUE); $xsecret = ""; for ($i = 0; $i < strlen($secret); $i++) { $xsecret .= chr(ord($secret[$i]) ^ ord($sha1_dh_shared[$i])); |