API Documentation

Zend/Crypt/DiffieHellman.php

Show: inherited
Table of Contents

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.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Crypt  
Subpackage
DiffieHellman  
Version
$Id: DiffieHellman.php 24594 2012-01-05 21:27:01Z matthew $  

\Zend_Crypt_DiffieHellman

Package: Zend\Crypt

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.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

Constant  BINARY = 'binary'

Constants

Constant  NUMBER = 'number'
Constant  BTWOC = 'btwoc'

Properties

Propertyprivatestring  $_generator= 'null'

The default generator number. This number must be greater than 0 but less than the prime number set.

Default valuenullDetails
Type
string
Propertyprivate\Zend_Crypt_Math_BigInteger  $_math= 'null'

BigInteger support object courtesy of Zend_Crypt_Math

Default valuenullDetails
Type
\Zend_Crypt_Math_BigInteger
Propertyprivatestring  $_prime= 'null'

Default large prime number; required by the algorithm.

Default valuenullDetails
Type
string
Propertyprivatestring  $_privateKey= 'null'

A private number set by the local user. It's optional and will be generated if not set.

Default valuenullDetails
Type
string
Propertyprivatestring  $_publicKey= 'null'

The public key generated by this instance after calling generateKeys().

Default valuenullDetails
Type
string
Propertyprivatestring  $_secretKey= 'null'

The shared secret key resulting from a completed Diffie Hellman exchange

Default valuenullDetails
Type
string
Propertypublicboolean  $useOpenssl= 'true'
static

Static flag to select whether to use PHP5.3's openssl extension if available.

Default valuetrueDetails
Type
boolean

Methods

methodpublic__construct( string $prime, string $generator, string $privateKey = null, string $privateKeyType = self::NUMBER ) : void

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
Name Type Description
$prime string
$generator string
$privateKey string
$privateKeyType string
methodprotected_generatePrivateKey( ) : 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.

Returns
Type Description
string
methodpubliccomputeSecretKey( string $publicKey, string $type = self::NUMBER,  $output = self::NUMBER ) : mixed

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
Name Type Description
$publicKey string
$type string
$output
Returns
Type Description
mixed
methodpublicgenerateKeys( ) : \Zend_Crypt_DiffieHellman

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

Returns
Type Description
\Zend_Crypt_DiffieHellman
methodpublicgetGenerator( ) : string

Getter for the value of the generator number

Returns
Type Description
string
methodpublicgetPrime( ) : string

Getter for the value of the prime number

Returns
Type Description
string
methodpublicgetPrivateKey( string $type = self::NUMBER ) : string

Getter for the value of the private number

Parameters
Name Type Description
$type string
Returns
Type Description
string
methodpublicgetPublicKey( string $type = self::NUMBER ) : string

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

Parameters
Name Type Description
$type string
Returns
Type Description
string
methodpublicgetSharedSecretKey( string $type = self::NUMBER ) : string

Return the computed shared secret key from the DiffieHellman transaction

Parameters
Name Type Description
$type string
Returns
Type Description
string
methodpublichasPrivateKey( ) : boolean

Check whether a private key currently exists.

Returns
Type Description
boolean
methodpublicsetBigIntegerMath( string $extension = null ) : void

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
Name Type Description
$extension string
methodpublicsetGenerator( string $number ) : \Zend_Crypt_DiffieHellman

Setter for the value of the generator number

Parameters
Name Type Description
$number string
Returns
Type Description
\Zend_Crypt_DiffieHellman
methodpublicsetPrime( string $number ) : \Zend_Crypt_DiffieHellman

Setter for the value of the prime number

Parameters
Name Type Description
$number string
Returns
Type Description
\Zend_Crypt_DiffieHellman
methodpublicsetPrivateKey( string $number, string $type = self::NUMBER ) : \Zend_Crypt_DiffieHellman

Setter for the value of the private number

Parameters
Name Type Description
$number string
$type string
Returns
Type Description
\Zend_Crypt_DiffieHellman
methodpublicsetPublicKey( string $number, string $type = self::NUMBER ) : \Zend_Crypt_DiffieHellman

Setter for the value of the public number

Parameters
Name Type Description
$number string
$type string
Returns
Type Description
\Zend_Crypt_DiffieHellman
Documentation was generated by DocBlox 0.15.1.