Zend Framework  1.12
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
Zend_Crypt_DiffieHellman Class Reference

Public Member Functions

 __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.
 
 generateKeys ()
 Generate own public key.
 
 setPublicKey ($number, $type=self::NUMBER)
 Setter for the value of the public number.
 
 getPublicKey ($type=self::NUMBER)
 Returns own public key for communication to the second party to this transaction.
 
 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.
 
 getSharedSecretKey ($type=self::NUMBER)
 Return the computed shared secret key from the DiffieHellman transaction.
 
 setPrime ($number)
 Setter for the value of the prime number.
 
 getPrime ()
 Getter for the value of the prime number.
 
 setGenerator ($number)
 Setter for the value of the generator number.
 
 getGenerator ()
 Getter for the value of the generator number.
 
 setPrivateKey ($number, $type=self::NUMBER)
 Setter for the value of the private number.
 
 getPrivateKey ($type=self::NUMBER)
 Getter for the value of the private number.
 
 hasPrivateKey ()
 Check whether a private key currently exists.
 
 setBigIntegerMath ($extension=null)
 Setter to pass an extension parameter which is used to create a specific BigInteger instance for a specific extension type.
 

Public Attributes

const BINARY = 'binary'
 Constants.
 
const NUMBER = 'number'
 
const BTWOC = 'btwoc'
 

Static Public Attributes

static $useOpenssl = true
 

Protected Member Functions

 _generatePrivateKey ()
 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.
 

Constructor & Destructor Documentation

__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.

Parameters
string$prime
string$generator
string$privateKey
string$privateKeyType
Returns
void

Member Function Documentation

_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.

Returns
string
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.

Parameters
string$publicKey
string$type
Returns
mixed
generateKeys ( )

Generate own public key.

If a private number has not already been set, one will be generated at this stage.

Returns
Zend_Crypt_DiffieHellman
getGenerator ( )

Getter for the value of the generator number.

Returns
string
getPrime ( )

Getter for the value of the prime number.

Returns
string
getPrivateKey (   $type = self::NUMBER)

Getter for the value of the private number.

Parameters
string$type
Returns
string
getPublicKey (   $type = self::NUMBER)

Returns own public key for communication to the second party to this transaction.

Parameters
string$type
Returns
string
getSharedSecretKey (   $type = self::NUMBER)

Return the computed shared secret key from the DiffieHellman transaction.

Parameters
string$type
Returns
string
hasPrivateKey ( )

Check whether a private key currently exists.

Returns
boolean
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.

Parameters
string$extension
Returns
void
See Also
Zend_Crypt_Math
setGenerator (   $number)

Setter for the value of the generator number.

Parameters
string$number
Returns
Zend_Crypt_DiffieHellman
setPrime (   $number)

Setter for the value of the prime number.

Parameters
string$number
Returns
Zend_Crypt_DiffieHellman
setPrivateKey (   $number,
  $type = self::NUMBER 
)

Setter for the value of the private number.

Parameters
string$number
string$type
Returns
Zend_Crypt_DiffieHellman
setPublicKey (   $number,
  $type = self::NUMBER 
)

Setter for the value of the public number.

Parameters
string$number
string$type
Returns
Zend_Crypt_DiffieHellman

Member Data Documentation

$useOpenssl = true
static
const BINARY = 'binary'

Constants.

const BTWOC = 'btwoc'
const NUMBER = 'number'