我试图创建一个状态库的OpenID用作一个WordPress插件的计算机共享机密问题,我运行到一个问题,当我尝试使用计算秘密值openssl函数openssl_dh_compute_key。好奇,如果任何人有一些步骤,我可以尝试,提示,等等......用的Diffie Hellman密钥对OpenID的
谢谢!
常数...
const DH_DEFAULT_PRIME = "dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61ef75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d2683705577d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e3826634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab";
const DH_DEFAULT_GENERATOR = '02';
创建我的Diffie-Hellman密钥
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;
}
}
在两个图像的按钮
银==是dh ['g']的base64编码值。
我然后保存生成的私钥到数据库中坚持,这让我以后重新创建通过openssl_pkey_get_private功能的关键。
然而,采取从关联请求返回openid.dh_server_public,并通过它,我的钥匙从私有密钥导致错误的重新创造了
var_dump(openssl_dh_compute_key($this->op_pubkey, $this->dh));
我真的希望这个功能被记录得更好! :\ –
现在是...查看http://php.net/manual/en/function.openssl-dh-compute-key.php – velcrow