[ Index ]

PHP Cross Reference of DokuWiki




/vendor/phpseclib/phpseclib/phpseclib/Crypt/ -> DH.php (summary)

Pure-PHP (EC)DH implementation PHP version 5

Author: Jim Wigginton
Copyright: 2016 Jim Wigginton
License: http://www.opensource.org/licenses/mit-license.html MIT License
Link: http://phpseclib.sourceforge.net
File Size: 405 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 8 functions


Functions that are not part of a class:

createParameters(...$args)   X-Ref
Create DH parameters

This method is a bit polymorphic. It can take any of the following:
- two BigInteger's (prime and base)
- an integer representing the size of the prime in bits (the base is assumed to be 2)
- a string (eg. diffie-hellman-group14-sha1)

return: Parameters

createKey(Parameters $params, $length = 0)   X-Ref
Create public / private key pair.

The rationale for the second parameter is described in http://tools.ietf.org/html/rfc4419#section-6.2 :

"To increase the speed of the key exchange, both client and server may
reduce the size of their private exponents.  It should be at least
twice as long as the key material that is generated from the shared
secret.  For more details, see the paper by van Oorschot and Wiener

$length is in bits

return: DH\PrivateKey
param: Parameters $params
param: int $length optional

computeSecret($private, $public)   X-Ref
Compute Shared Secret

return: mixed
param: PrivateKey|EC $private
param: PublicKey|BigInteger|string $public

load($key, $password = false)   X-Ref
Load the key

return: AsymmetricKey
param: string $key
param: string $password optional

onLoad(array $components)   X-Ref
OnLoad Handler

return: bool

withHash($hash)   X-Ref
Determines which hashing function should be used

param: string $hash

getHash()   X-Ref
Returns the hash algorithm currently being used

getParameters()   X-Ref
Returns the parameters

A public / private key is only returned if the currently loaded "key" contains an x or y

see: self::getPublicKey()
return: mixed