Public Member Functions | |
__construct ($prime, $generator, $privateKey=null, $privateKeyType=self::NUMBER) | |
generateKeys () | |
setPublicKey ($number, $type=self::NUMBER) | |
getPublicKey ($type=self::NUMBER) | |
computeSecretKey ($publicKey, $type=self::NUMBER, $output=self::NUMBER) | |
getSharedSecretKey ($type=self::NUMBER) | |
setPrime ($number) | |
getPrime () | |
setGenerator ($number) | |
getGenerator () | |
setPrivateKey ($number, $type=self::NUMBER) | |
getPrivateKey ($type=self::NUMBER) | |
hasPrivateKey () | |
setBigIntegerMath ($extension=null) | |
Data Fields | |
const | BINARY = 'binary' |
const | NUMBER = 'number' |
const | BTWOC = 'btwoc' |
Static Public Attributes | |
static | $useOpenssl = true |
Protected Member Functions | |
_generatePrivateKey () |
Definition at line 33 of file DiffieHellman.php.
__construct | ( | $ | prime, |
$ | generator, | ||
$ | privateKey = null , |
||
$ | privateKeyType = self::NUMBER |
||
) |
Constructor; if set construct the object using the parameter array to set values for Prime, Generator and Private. If a Private Key is not set, one will be generated at random.
string | $prime | |
string | $generator | |
string | $privateKey | |
string | $privateKeyType |
Definition at line 107 of file DiffieHellman.php.
_generatePrivateKey | ( | ) | [protected] |
In the event a private number/key has not been set by the user, or generated by ext/openssl, a best attempt will be made to generate a random key. Having a random number generator installed on linux/bsd is highly recommended! The alternative is not recommended for production unless without any other option.
Definition at line 374 of file DiffieHellman.php.
computeSecretKey | ( | $ | publicKey, |
$ | type = self::NUMBER , |
||
$ | output = self::NUMBER |
||
) |
Compute the shared secret key based on the public key received from the the second party to this transaction. This should agree to the secret key the second party computes on our own public key. Once in agreement, the key is known to only to both parties. By default, the function expects the public key to be in binary form which is the typical format when being transmitted.
If you need the binary form of the shared secret key, call getSharedSecretKey() with the optional parameter for Binary output.
string | $publicKey | |
string | $type |
Definition at line 200 of file DiffieHellman.php.
generateKeys | ( | ) |
Generate own public key. If a private number has not already been set, one will be generated at this stage.
Definition at line 123 of file DiffieHellman.php.
getGenerator | ( | ) |
Getter for the value of the generator number
Definition at line 289 of file DiffieHellman.php.
getPrime | ( | ) |
Getter for the value of the prime number
Definition at line 258 of file DiffieHellman.php.
getPrivateKey | ( | $ | type = self::NUMBER ) |
Getter for the value of the private number
string | $type |
Definition at line 324 of file DiffieHellman.php.
getPublicKey | ( | $ | type = self::NUMBER ) |
Returns own public key for communication to the second party to this transaction.
string | $type |
Definition at line 171 of file DiffieHellman.php.
getSharedSecretKey | ( | $ | type = self::NUMBER ) |
Return the computed shared secret key from the DiffieHellman transaction
string | $type |
Definition at line 223 of file DiffieHellman.php.
hasPrivateKey | ( | ) |
Check whether a private key currently exists.
Definition at line 342 of file DiffieHellman.php.
setBigIntegerMath | ( | $ | extension = null ) |
Setter to pass an extension parameter which is used to create a specific BigInteger instance for a specific extension type. Allows manual setting of the class in case of an extension problem or bug.
string | $extension |
Definition at line 356 of file DiffieHellman.php.
setGenerator | ( | $ | number ) |
Setter for the value of the generator number
string | $number |
Definition at line 274 of file DiffieHellman.php.
setPrime | ( | $ | number ) |
Setter for the value of the prime number
string | $number |
Definition at line 243 of file DiffieHellman.php.
setPrivateKey | ( | $ | number, |
$ | type = self::NUMBER |
||
) |
Setter for the value of the private number
string | $number | |
string | $type |
Definition at line 305 of file DiffieHellman.php.
setPublicKey | ( | $ | number, |
$ | type = self::NUMBER |
||
) |
Setter for the value of the public number
string | $number | |
string | $type |
Definition at line 151 of file DiffieHellman.php.
const BINARY = 'binary' |
Constants
Definition at line 92 of file DiffieHellman.php.