__construct()
computeSecretKey()
generateKeys()
getGenerator()
getPrime()
getPrivateKey()
getPublicKey()
getSharedSecretKey()
hasPrivateKey()
setGenerator()
setPrime()
setPrivateKey()
setPublicKey()
useOpensslExtension()
convert()
generatePrivateKey()
$useOpenssl
$opensslKeyResource
$generator
$math
$prime
$privateKey
$publicKey
$secretKey
DEFAULT_KEY_SIZE
FORMAT_BINARY
FORMAT_BTWOC
FORMAT_NUMBER
PHP implementation of the Diffie-Hellman public key encryption algorithm.
Allows two unassociated parties to establish a joint shared secret key to be used in encrypting subsequent communications.
__construct(string $prime, string $generator, string $privateKey, string $privateKeyFormat)
If a Private Key is not set, one will be generated at random.
string
string
string
string
computeSecretKey(string $publicKey, string $publicKeyFormat, string $secretKeyFormat) : string
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
string
string
\Zend\Crypt\Exception\InvalidArgumentException |
|
---|---|
\Zend\Crypt\Exception\RuntimeException |
string
generateKeys() : \Zend\Crypt\PublicKey\DiffieHellman
If a private number has not already been set, one will be generated at this stage.
\Zend\Crypt\Exception\RuntimeException |
---|
getGenerator(string $format) : string
getPrime(string $format) : string
getPrivateKey(string $format) : string
string
string
getPublicKey(string $format) : string
getSharedSecretKey(string $format) : string
hasPrivateKey() : bool
bool
setGenerator(string $number) : \Zend\Crypt\PublicKey\DiffieHellman
setPrime(string $number) : \Zend\Crypt\PublicKey\DiffieHellman
setPrivateKey(string $number, string $format) : \Zend\Crypt\PublicKey\DiffieHellman
string
string
\Zend\Crypt\Exception\InvalidArgumentException |
---|
setPublicKey(string $number, string $format) : \Zend\Crypt\PublicKey\DiffieHellman
string
string
\Zend\Crypt\Exception\InvalidArgumentException |
---|
useOpensslExtension(bool $flag)
static |
---|
bool
convert(string $number, string $inputFormat, string $outputFormat) : string
string
string
string
string
generatePrivateKey() : string
Having a random number generator installed on linux/bsd is highly recommended! The alternative is not recommended for production unless without any other option.
string
$useOpenssl : bool
$opensslKeyResource : resource
$generator : string
This number must be greater than 0 but less than the prime number set.
$math : \Zend\Math\BigInteger\Adapter\AdapterInterface
$prime : string
$privateKey : string
It's optional and will be generated if not set.
$publicKey : string
$secretKey : string
DEFAULT_KEY_SIZE
FORMAT_BINARY
FORMAT_BTWOC
FORMAT_NUMBER