summaryrefslogtreecommitdiffstats
path: root/Auth/OpenID/DiffieHellman.php
diff options
context:
space:
mode:
Diffstat (limited to 'Auth/OpenID/DiffieHellman.php')
-rw-r--r--Auth/OpenID/DiffieHellman.php55
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;