Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
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.
BINARY = 'binary'
Constants
Details NUMBER = 'number'
Details BTWOC = 'btwoc'
Detailsstring $_generator = 'null'The default generator number. This number must be greater than 0 but less than the prime number set.
DetailsZend_Crypt_Math_BigInteger $_math = 'null'BigInteger support object courtesy of Zend_Crypt_Math
Detailsstring $_prime = 'null'Default large prime number; required by the algorithm.
Detailsstring $_privateKey = 'null'A private number set by the local user. It's optional and will be generated if not set.
Detailsstring $_publicKey = 'null'The public key generated by this instance after calling generateKeys().
Detailsstring $_secretKey = 'null'The shared secret key resulting from a completed Diffie Hellman exchange
Detailsboolean $useOpenssl = 'true'Static flag to select whether to use PHP5.3's openssl extension if available.
Details__construct(
string $prime, string $generator, string $privateKey
=
null, string $privateKeyType
=
self
)
:
voidConstructor; 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.
Details_generatePrivateKey(
)
:
stringIn 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.
DetailscomputeSecretKey(
string $publicKey, string $type
=
self, $output
=
self
)
:
mixedCompute 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.
DetailsgenerateKeys(
)
:
Zend_Crypt_DiffieHellmanGenerate own public key. If a private number has not already been set, one will be generated at this stage.
DetailsgetGenerator(
)
:
stringGetter for the value of the generator number
DetailsgetPrime(
)
:
stringGetter for the value of the prime number
DetailsgetPrivateKey(
string $type
=
self
)
:
stringGetter for the value of the private number
DetailsgetPublicKey(
string $type
=
self
)
:
stringReturns own public key for communication to the second party to this transaction.
DetailsgetSharedSecretKey(
string $type
=
self
)
:
stringReturn the computed shared secret key from the DiffieHellman transaction
DetailshasPrivateKey(
)
:
booleanCheck whether a private key currently exists.
DetailssetBigIntegerMath(
string $extension
=
null
)
:
voidSetter 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.
DetailssetGenerator(
string $number
)
:
Zend_Crypt_DiffieHellmanSetter for the value of the generator number
DetailssetPrime(
string $number
)
:
Zend_Crypt_DiffieHellmanSetter for the value of the prime number
DetailssetPrivateKey(
string $number, string $type
=
self
)
:
Zend_Crypt_DiffieHellmanSetter for the value of the private number
DetailssetPublicKey(
string $number, string $type
=
self
)
:
Zend_Crypt_DiffieHellmanSetter for the value of the public number
Details