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.
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.
Parameters: |
|
---|
Set whether to use openssl extension
Parameters: | bool – |
---|
Generate own public key. If a private number has not already been set, one will be generated at this stage.
Return type: | DiffieHellman |
---|---|
Throws : | ZendCryptExceptionRuntimeException |
Setter for the value of the public number
Parameters: |
|
---|---|
Return type: | DiffieHellman |
Throws : | ZendCryptExceptionInvalidArgumentException |
Returns own public key for communication to the second party to this transaction
Parameters: | string – |
---|---|
Return type: | string |
Throws : | ZendCryptExceptionInvalidArgumentException |
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.
Parameters: |
|
---|---|
Return type: | string |
Throws : | ZendCryptExceptionInvalidArgumentException |
Throws : | ZendCryptExceptionRuntimeException |
Setter for the value of the prime number
Parameters: | string – |
---|---|
Return type: | DiffieHellman |
Throws : | ZendCryptExceptionInvalidArgumentException |
Getter for the value of the prime number
Parameters: | string – |
---|---|
Return type: | string |
Throws : | ZendCryptExceptionInvalidArgumentException |
Setter for the value of the generator number
Parameters: | string – |
---|---|
Return type: | DiffieHellman |
Throws : | ZendCryptExceptionInvalidArgumentException |
Getter for the value of the generator number
Parameters: | string – |
---|---|
Return type: | string |
Throws : | ZendCryptExceptionInvalidArgumentException |
Setter for the value of the private number
Parameters: |
|
---|---|
Return type: | DiffieHellman |
Throws : | ZendCryptExceptionInvalidArgumentException |
Getter for the value of the private number
Parameters: | string – |
---|---|
Return type: | string |
Check whether a private key currently exists.
Return type: | bool |
---|
Convert number between formats
Parameters: |
|
---|---|
Return type: | string |
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.
Return type: | string |
---|