API Documentation

Crypt/DiffieHellman.php

Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Crypt
subpackage
DiffieHellman
version
$Id: DiffieHellman.php 22053 2010-04-29 14:29:52Z padraic $
Classes
Zend_Crypt_DiffieHellman

Description

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.

Zend_Crypt_DiffieHellman

category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Crypt
Constants
BINARY
NUMBER
BTWOC
Properties
$useOpenssl
$_prime
$_generator
$_privateKey
$_math
$_publicKey
$_secretKey
Methods
__construct
generateKeys
setPublicKey
getPublicKey
computeSecretKey
getSharedSecretKey
setPrime
getPrime
setGenerator
getGenerator
setPrivateKey
getPrivateKey
hasPrivateKey
setBigIntegerMath
_generatePrivateKey

Description

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.

Constants

BINARY

 BINARY = 'binary'

Constants

Details

value
binary

NUMBER

 NUMBER = 'number'

Details

value
number

BTWOC

 BTWOC = 'btwoc'

Details

value
btwoc

Properties

$_generator

string $_generator = 'null'

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

Details

$_generator
string
visibility
private
default
null
final
false
static
false

$_math

Zend_Crypt_Math_BigInteger $_math = 'null'

BigInteger support object courtesy of Zend_Crypt_Math

Details

$_math
Zend_Crypt_Math_BigInteger
visibility
private
default
null
final
false
static
false

$_prime

string $_prime = 'null'

Default large prime number; required by the algorithm.

Details

$_prime
string
visibility
private
default
null
final
false
static
false

$_privateKey

string $_privateKey = 'null'

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

Details

$_privateKey
string
visibility
private
default
null
final
false
static
false

$_publicKey

string $_publicKey = 'null'

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

Details

$_publicKey
string
visibility
private
default
null
final
false
static
false

$_secretKey

string $_secretKey = 'null'

The shared secret key resulting from a completed Diffie Hellman exchange

Details

$_secretKey
string
visibility
private
default
null
final
false
static
false

$useOpenssl

boolean $useOpenssl = 'true'

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

Details

$useOpenssl
boolean
visibility
public
default
true
final
false
static
true

Methods

__construct

__construct( string $prime, string $generator, string $privateKey = null, string $privateKeyType = self ) : 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.

Arguments
$prime
string
$generator
string
$privateKey
string
$privateKeyType
string
Details
visibility
public
final
false
static
false

_generatePrivateKey

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

Output
string
Details
visibility
protected
final
false
static
false

computeSecretKey

computeSecretKey( string $publicKey, string $type = self,  $output = self ) : 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.

Arguments
$publicKey
string
$type
string
$output
Output
mixed
Details
visibility
public
final
false
static
false

generateKeys

generateKeys( ) : Zend_Crypt_DiffieHellman

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

Details
visibility
public
final
false
static
false

getGenerator

getGenerator( ) : string

Getter for the value of the generator number

Output
string
Details
visibility
public
final
false
static
false

getPrime

getPrime( ) : string

Getter for the value of the prime number

Output
string
Details
visibility
public
final
false
static
false

getPrivateKey

getPrivateKey( string $type = self ) : string

Getter for the value of the private number

Arguments
$type
string
Output
string
Details
visibility
public
final
false
static
false

getPublicKey

getPublicKey( string $type = self ) : string

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

Arguments
$type
string
Output
string
Details
visibility
public
final
false
static
false

getSharedSecretKey

getSharedSecretKey( string $type = self ) : string

Return the computed shared secret key from the DiffieHellman transaction

Arguments
$type
string
Output
string
Details
visibility
public
final
false
static
false

hasPrivateKey

hasPrivateKey( ) : boolean

Check whether a private key currently exists.

Output
boolean
Details
visibility
public
final
false
static
false

setBigIntegerMath

setBigIntegerMath( 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.

Arguments
$extension
string
Details
visibility
public
final
false
static
false

setGenerator

setGenerator( string $number ) : Zend_Crypt_DiffieHellman

Setter for the value of the generator number

Arguments
$number
string
Details
visibility
public
final
false
static
false

setPrime

setPrime( string $number ) : Zend_Crypt_DiffieHellman

Setter for the value of the prime number

Arguments
$number
string
Details
visibility
public
final
false
static
false

setPrivateKey

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

Setter for the value of the private number

Arguments
$number
string
$type
string
Details
visibility
public
final
false
static
false

setPublicKey

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

Setter for the value of the public number

Arguments
$number
string
$type
string
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox.