Fully Qualified Name: | Zend\Crypt\PublicKey\DiffieHellman |
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.
Name | Description | Defined By |
---|---|---|
__construct() | Constructor; if set construct the object using the parameter array to set values for Prime, Generator and Private. | DiffieHellman |
computeSecretKey() | 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. | DiffieHellman |
generateKeys() | Generate own public key. If a private number has not already been set, one will be generated at this stage. | DiffieHellman |
getGenerator() | Getter for the value of the generator number | DiffieHellman |
getPrime() | Getter for the value of the prime number | DiffieHellman |
getPrivateKey() | Getter for the value of the private number | DiffieHellman |
getPublicKey() | Returns own public key for communication to the second party to this transaction | DiffieHellman |
getSharedSecretKey() | Return the computed shared secret key from the DiffieHellman transaction | DiffieHellman |
hasPrivateKey() | Check whether a private key currently exists. | DiffieHellman |
setGenerator() | Setter for the value of the generator number | DiffieHellman |
setPrime() | Setter for the value of the prime number | DiffieHellman |
setPrivateKey() | Setter for the value of the private number | DiffieHellman |
setPublicKey() | Setter for the value of the public number | DiffieHellman |
useOpensslExtension() | Set whether to use openssl extension | DiffieHellman |
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.
Parameter Name | Type | Description |
---|---|---|
$prime | string | |
$generator | string | |
$privateKey | string | |
$privateKeyFormat | string |
Returns:
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.
Parameter Name | Type | Description |
---|---|---|
$publicKey | string | |
$publicKeyFormat | string | |
$secretKeyFormat | string |
Returns: string
Generate own public key. If a private number has not already been set, one will be generated at this stage.
Returns: \DiffieHellman Provides a fluent interface
Getter for the value of the generator number
Parameter Name | Type | Description |
---|---|---|
$format | string |
Returns: string
Getter for the value of the prime number
Parameter Name | Type | Description |
---|---|---|
$format | string |
Returns: string
Getter for the value of the private number
Parameter Name | Type | Description |
---|---|---|
$format | string |
Returns: string
Returns own public key for communication to the second party to this transaction
Parameter Name | Type | Description |
---|---|---|
$format | string |
Returns: string
Return the computed shared secret key from the DiffieHellman transaction
Parameter Name | Type | Description |
---|---|---|
$format | string |
Returns: string
Check whether a private key currently exists.
Returns: bool
Setter for the value of the generator number
Parameter Name | Type | Description |
---|---|---|
$number | string |
Returns: \DiffieHellman Provides a fluent interface
Setter for the value of the prime number
Parameter Name | Type | Description |
---|---|---|
$number | string |
Returns: \DiffieHellman Provides a fluent interface
Setter for the value of the private number
Parameter Name | Type | Description |
---|---|---|
$number | string | |
$format | string |
Returns: \DiffieHellman Provides a fluent interface
Setter for the value of the public number
Parameter Name | Type | Description |
---|---|---|
$number | string | |
$format | string |
Returns: \DiffieHellman Provides a fluent interface
Set whether to use openssl extension
Parameter Name | Type | Description |
---|---|---|
$flag | bool |
Returns: