49 private $_prime =
null;
57 private $_generator =
null;
65 private $_privateKey =
null;
72 private $_math =
null;
79 private $_publicKey =
null;
87 private $_secretKey =
null;
110 if ($privateKey !==
null) {
124 if (
function_exists(
'openssl_dh_compute_key') && self::$useOpenssl !==
false) {
131 $opensslKeyResource = openssl_pkey_new( array(
'dh' =>
$details) );
132 $data = openssl_pkey_get_details($opensslKeyResource);
153 if (
$type == self::BINARY) {
156 if (!preg_match(
"/^\d+$/",
$number)) {
157 #require_once('Zend/Crypt/DiffieHellman/Exception.php'); 160 $this->_publicKey = (string)
$number;
174 if ($this->_publicKey ===
null) {
175 #require_once 'Zend/Crypt/DiffieHellman/Exception.php'; 178 if (
$type == self::BINARY) {
179 return $this->_math->toBinary($this->_publicKey);
181 return $this->_math->btwoc($this->_math->toBinary($this->_publicKey));
183 return $this->_publicKey;
205 if (
$type == self::BINARY) {
206 $publicKey = $this->_math->fromBinary($publicKey);
208 if (!preg_match(
"/^\d+$/", $publicKey)) {
209 #require_once('Zend/Crypt/DiffieHellman/Exception.php'); 212 if (
function_exists(
'openssl_dh_compute_key') && self::$useOpenssl !==
false) {
213 $this->_secretKey = openssl_dh_compute_key($publicKey, $this->
getPublicKey());
229 if (!isset($this->_secretKey)) {
230 #require_once('Zend/Crypt/DiffieHellman/Exception.php'); 233 if (
$type == self::BINARY) {
234 return $this->_math->toBinary($this->_secretKey);
236 return $this->_math->btwoc($this->_math->toBinary($this->_secretKey));
238 return $this->_secretKey;
251 #require_once('Zend/Crypt/DiffieHellman/Exception.php'); 254 $this->_prime = (string)
$number;
266 if (!isset($this->_prime)) {
267 #require_once('Zend/Crypt/DiffieHellman/Exception.php'); 270 return $this->_prime;
283 #require_once('Zend/Crypt/DiffieHellman/Exception.php'); 286 $this->_generator = (string)
$number;
298 if (!isset($this->_generator)) {
299 #require_once('Zend/Crypt/DiffieHellman/Exception.php'); 302 return $this->_generator;
315 if (
$type == self::BINARY) {
318 if (!preg_match(
"/^\d+$/",
$number)) {
319 #require_once('Zend/Crypt/DiffieHellman/Exception.php'); 322 $this->_privateKey = (string)
$number;
337 if (
$type == self::BINARY) {
338 return $this->_math->toBinary($this->_privateKey);
340 return $this->_math->btwoc($this->_math->toBinary($this->_privateKey));
342 return $this->_privateKey;
352 return isset($this->_privateKey);
369 #require_once 'Zend/Crypt/Math.php'; setBigIntegerMath($extension=null)
getPrivateKey($type=self::NUMBER)
elseif(isset( $params[ 'redirect_parent']))
getPublicKey($type=self::NUMBER)
computeSecretKey($publicKey, $type=self::NUMBER, $output=self::NUMBER)
setPrivateKey($number, $type=self::NUMBER)
__construct($prime, $generator, $privateKey=null, $privateKeyType=self::NUMBER)
setPublicKey($number, $type=self::NUMBER)
getSharedSecretKey($type=self::NUMBER)