diff options
author | tailor <cygnus@janrain.com> | 2007-01-15 19:06:01 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2007-01-15 19:06:01 +0000 |
commit | 03634c658cb7451a8d14935e70a8fdeec8c0364c (patch) | |
tree | 281501e34770692cc7f2bae2f17388ce2d888206 /Auth/OpenID/DiffieHellman.php | |
parent | e7115c7b642f6916939fa5dfce40a16750e5366a (diff) | |
download | php-openid-03634c658cb7451a8d14935e70a8fdeec8c0364c.zip php-openid-03634c658cb7451a8d14935e70a8fdeec8c0364c.tar.gz php-openid-03634c658cb7451a8d14935e70a8fdeec8c0364c.tar.bz2 |
[project @ Refactor Consumer, add session negotiator, update session type classes]
Diffstat (limited to 'Auth/OpenID/DiffieHellman.php')
-rw-r--r-- | Auth/OpenID/DiffieHellman.php | 55 |
1 files changed, 3 insertions, 52 deletions
diff --git a/Auth/OpenID/DiffieHellman.php b/Auth/OpenID/DiffieHellman.php index 2b845b7..0551390 100644 --- a/Auth/OpenID/DiffieHellman.php +++ b/Auth/OpenID/DiffieHellman.php @@ -116,64 +116,15 @@ class Auth_OpenID_DiffieHellman { $this->gen == Auth_OpenID_getDefaultGen()); } - /** - * Perform the server side of the OpenID Diffie-Hellman association - */ - function serverAssociate($consumer_args, $assoc_secret) - { - $lib =& Auth_OpenID_getMathLib(); - - if (isset($consumer_args['openid.dh_modulus'])) { - $mod = $lib->base64ToLong($consumer_args['openid.dh_modulus']); - } else { - $mod = null; - } - - if (isset($consumer_args['openid.dh_gen'])) { - $gen = $lib->base64ToLong($consumer_args['openid.dh_gen']); - } else { - $gen = null; - } - - $cpub64 = @$consumer_args['openid.dh_consumer_public']; - if (!isset($cpub64)) { - return false; - } - - $dh = new Auth_OpenID_DiffieHellman($mod, $gen); - $cpub = $lib->base64ToLong($cpub64); - $mac_key = $dh->xorSecret($cpub, $assoc_secret); - $enc_mac_key = base64_encode($mac_key); - $spub64 = $lib->longToBase64($dh->getPublicKey()); - - $server_args = array( - 'session_type' => 'DH-SHA1', - 'dh_server_public' => $spub64, - 'enc_mac_key' => $enc_mac_key - ); - - return $server_args; - } - - function consumerFinish($reply) - { - $spub = $this->lib->base64ToLong($reply['dh_server_public']); - if ($this->lib->cmp($spub, 0) <= 0) { - return false; - } - $enc_mac_key = base64_decode($reply['enc_mac_key']); - return $this->xorSecret($spub, $enc_mac_key); - } - - function xorSecret($composite, $secret) + function xorSecret($composite, $secret, $hash_func) { $dh_shared = $this->getSharedSecret($composite); $dh_shared_str = $this->lib->longToBinary($dh_shared); - $sha1_dh_shared = Auth_OpenID_SHA1($dh_shared_str); + $hash_dh_shared = $hash_func($dh_shared_str); $xsecret = ""; for ($i = 0; $i < strlen($secret); $i++) { - $xsecret .= chr(ord($secret[$i]) ^ ord($sha1_dh_shared[$i])); + $xsecret .= chr(ord($secret[$i]) ^ ord($hash_dh_shared[$i])); } return $xsecret; |