I am trying to create an open source library for OpenID that will be used as a Wordpress plugin. I have a problem when I try to calculate the secret value using the openssl function openssl_dh_compute_key . Curious if anyone has any steps that I could try, tips, etc.
Thank!
Constants ...
const DH_DEFAULT_PRIME = "dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61ef75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d2683705577d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e3826634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab";
const DH_DEFAULT_GENERATOR = '02';
Creating a Diffie-Hellman Key
private function createDHKey($priv_key = false) {
if (!$priv_key) {
$details = array();
$details['p'] = pack('H*', self::DH_DEFAULT_PRIME);
$details['g'] = pack('H*', self::DH_DEFAULT_GENERATOR);
$this->dh = openssl_pkey_new(array(
'dh' => $details,
));
if ($this->dh) {
return true;
} else {
error('OpenSSL failed to export your private key, ensure you have a valid configuration file, and PHP can find it.');
}
} else {
$this->dh = openssl_pkey_get_private($priv_key);
return false;
}
}


Ag == on the button of both images is the base64 encoded dh ['g'] value.
Then I save the generated private key to the database for saving, which allows me to re-create the key later through the openssl_pkey_get_private function.
, openid.dh_server_public , , , false
var_dump(openssl_dh_compute_key($this->op_pubkey, $this->dh));