function test_dh()
{
if (!defined('Auth_OpenID_NO_MATH_SUPPORT')) {
$dh = new Auth_OpenID_DiffieHellman();
$ml =& Auth_OpenID_getMathLib();
$cpub = $dh->public;
$session = new Auth_OpenID_DiffieHellmanServerSession(new Auth_OpenID_DiffieHellman(), $cpub);
$this->request = new Auth_OpenID_AssociateRequest($session);
$response = $this->request->answer($this->assoc);
$this->assertEquals(Auth_OpenID::arrayGet($response->fields, "assoc_type"), "HMAC-SHA1");
$this->assertEquals(Auth_OpenID::arrayGet($response->fields, "assoc_handle"), $this->assoc->handle);
$this->assertFalse(Auth_OpenID::arrayGet($response->fields, "mac_key"));
$this->assertEquals(Auth_OpenID::arrayGet($response->fields, "session_type"), "DH-SHA1");
$this->assertTrue(Auth_OpenID::arrayGet($response->fields, "enc_mac_key"));
$this->assertTrue(Auth_OpenID::arrayGet($response->fields, "dh_server_public"));
$enc_key = base64_decode(Auth_OpenID::arrayGet($response->fields, "enc_mac_key"));
$spub = $ml->base64ToLong(Auth_OpenID::arrayGet($response->fields, "dh_server_public"));
$secret = $dh->xorSecret($spub, $enc_key);
$this->assertEquals($secret, $this->assoc->secret);
}
}