# LDAP Account Manager

# lib/3rdParty/phpseclib/Crypt/RSA.php

# Properties

author
category
copyright
license
link
package
version

## Description

Pure-PHP PKCS#1 (v2.1) compliant implementation of RSA.
PHP versions 4 and 5 Here's an example of how to encrypt and decrypt text with this library: `createKey()); $plaintext = 'terrafrost'; $rsa->loadKey($privatekey); $ciphertext = $rsa->encrypt($plaintext); $rsa->loadKey($publickey); echo $rsa->decrypt($ciphertext); ?>` Here's an example of how to create signatures and verify signatures with this library: `createKey()); $plaintext = 'terrafrost'; $rsa->loadKey($privatekey); $signature = $rsa->sign($plaintext); $rsa->loadKey($publickey); echo $rsa->verify($plaintext, $signature) ? 'verified' : 'unverified'; ?>` LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

## Constants

### CRYPT_RSA_ENCRYPTION_OAEP = 1

Use {@link http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding Optimal Asymmetric Encryption Padding} (OAEP) for encryption / decryption.
Uses sha1 by default.

### CRYPT_RSA_ENCRYPTION_PKCS1 = 2

Use PKCS#1 padding.
Although CRYPT_RSA_ENCRYPTION_OAEP offers more security, including PKCS#1 padding is necessary for purposes of backwards compatability with protocols (like SSH-1) written before OAEP's introduction.

### CRYPT_RSA_SIGNATURE_PSS = 1

Use the Probabilistic Signature Scheme for signing
Uses sha1 by default.

### CRYPT_RSA_SIGNATURE_PKCS1 = 2

Use the PKCS#1 scheme by default.
Although CRYPT_RSA_SIGNATURE_PSS offers more security, including PKCS#1 signing is necessary for purposes of backwards compatability with protocols (like SSH-2) written before PSS's introduction.

### CRYPT_RSA_ASN1_INTEGER = 2

ASN1 Integer

### CRYPT_RSA_ASN1_SEQUENCE = 48

ASN1 Sequence (with the constucted bit set)

### CRYPT_RSA_MODE_INTERNAL = 1

To use the pure-PHP implementation

### CRYPT_RSA_MODE_OPENSSL = 2

To use the OpenSSL library
(if enabled; otherwise, the internal implementation will be used)

### CRYPT_RSA_PRIVATE_FORMAT_PKCS1 = 0

PKCS#1 formatted private key
Used by OpenSSH

### CRYPT_RSA_PRIVATE_FORMAT_PUTTY = 1

PuTTY formatted private key

### CRYPT_RSA_PRIVATE_FORMAT_XML = 2

XML formatted private key

### CRYPT_RSA_PUBLIC_FORMAT_RAW = 3

Raw public key
An array containing two Math_BigInteger objects. The exponent can be indexed with any of the following: 0, e, exponent, publicExponent The modulus can be indexed with any of the following: 1, n, modulo, modulus

### CRYPT_RSA_PUBLIC_FORMAT_PKCS1 = 4

PKCS#1 formatted public key

### CRYPT_RSA_PUBLIC_FORMAT_XML = 5

XML formatted public key

### CRYPT_RSA_PUBLIC_FORMAT_OPENSSH = 6

OpenSSH formatted public key
Place in $HOME/.ssh/authorized_keys

### CRYPT_RSA_MODE = CRYPT_RSA_MODE_INTERNAL

### CRYPT_RSA_EXPONENT = '65537'

### CRYPT_RSA_COMMENT = 'phpseclib-generated-key'

### CRYPT_RSA_SMALLEST_PRIME = 4096

## Classes

### Crypt_RSA

# Properties

Extends
Implements
access
public
author
Jim Wigginton
package
Crypt_RSA
version
0.1.0
Abstract
No
Final
No

#### Description

Pure-PHP PKCS#1 compliant implementation of RSA.

#### Methods

Crypt_RSA, _blind, _convertPrivateKey, _convertPublicKey, _data_handler, _decodeLength, _emsa_pkcs1_v1_5_encode, _emsa_pss_encode, _emsa_pss_verify, _encodeLength, _exponentiate, _generateMinMax, _i2osp, _mgf1, _os2ip, _parseKey, _random, _rsadp, _rsaep, _rsaes_oaep_decrypt, _rsaes_oaep_encrypt, _rsaes_pkcs1_v1_5_decrypt, _rsaes_pkcs1_v1_5_encrypt, _rsasp1, _rsassa_pkcs1_v1_5_sign, _rsassa_pkcs1_v1_5_verify, _rsassa_pss_sign, _rsassa_pss_verify, _rsavp1, _start_element_handler, _stop_element_handler, _string_shift, createKey, decrypt, encrypt, getPublicKey, loadKey, setEncryptionMode, setHash, setMGFHash, setPassword, setPrivateKeyFormat, setPublicKey, setPublicKeyFormat, setSaltLength, setSignatureMode, sign, verify,

### Crypt_RSA( ) : \Crypt_RSA

#### Description

The constructor
If you want to make use of the openssl extension, you'll need to set the mode manually, yourself. The reason Crypt_RSA doesn't do it is because OpenSSL doesn't fail gracefully. openssl_pkey_new(), in particular, requires openssl.cnf be present somewhere and, unfortunately, the only real way to find out is too late.

#### Return value

Type | Description
--- | ---
\Crypt_RSA |

#### Tags

Name | Description
--- | ---
access | public

### _blind( \Math_BigInteger $x, \Math_BigInteger $r, Integer $i, ) : \Math_BigInteger

#### Description

Performs RSA Blinding
Protects against timing attacks by employing RSA Blinding. Returns $x->modPow($this->exponents[$i], $this->primes[$i])

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$x | \Math_BigInteger |  |
$r | \Math_BigInteger |  |
$i | Integer |  |

#### Return value

Type | Description
--- | ---
\Math_BigInteger |

#### Tags

Name | Description
--- | ---
access | private

### _convertPrivateKey( $n, $e, $d, $primes, $exponents, $coefficients, ) : String

#### Description

Convert a private key to the appropriate format.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$n | n/a |  |
$e | n/a |  |
$d | n/a |  |
$primes | n/a |  |
$exponents | n/a |  |
$coefficients | n/a |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private
see |

### _convertPublicKey( $n, $e, ) : String

#### Description

Convert a public key to the appropriate format

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$n | n/a |  |
$e | n/a |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private
see |

### _data_handler( Resource $parser, String $data, ) : n/a

#### Description

Data Handler
Called by xml_set_character_data_handler()

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$parser | Resource |  |
$data | String |  |

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
access | private

### _decodeLength( $string, ) : n/a

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$string | n/a |  |

#### Return value

Type | Description
--- | ---
n/a | n/a

### _emsa_pkcs1_v1_5_encode( String $m, Integer $emLen, ) : String

#### Description

EMSA-PKCS1-V1_5-ENCODE
See {@link http://tools.ietf.org/html/rfc3447#section-9.2 RFC3447#section-9.2}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$m | String |  |
$emLen | Integer |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private

### _emsa_pss_encode( String $m, Integer $emBits, ) : n/a

#### Description

EMSA-PSS-ENCODE
See {@link http://tools.ietf.org/html/rfc3447#section-9.1.1 RFC3447#section-9.1.1}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$m | String |  |
$emBits | Integer |  |

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
access | private

### _emsa_pss_verify( String $m, String $em, Integer $emBits, ) : String

#### Description

EMSA-PSS-VERIFY
See {@link http://tools.ietf.org/html/rfc3447#section-9.1.2 RFC3447#section-9.1.2}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$m | String |  |
$em | String |  |
$emBits | Integer |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private

### _encodeLength( $length, ) : n/a

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$length | n/a |  |

#### Return value

Type | Description
--- | ---
n/a | n/a

### _exponentiate( \Math_BigInteger $x, ) : \Math_BigInteger

#### Description

Exponentiate with or without Chinese Remainder Theorem
See {@link http://tools.ietf.org/html/rfc3447#section-5.1.1 RFC3447#section-5.1.2}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$x | \Math_BigInteger |  |

#### Return value

Type | Description
--- | ---
\Math_BigInteger |

#### Tags

Name | Description
--- | ---
access | private

### _generateMinMax( Integer $bits, ) : Array

#### Description

Generates the smallest and largest numbers requiring $bits bits

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$bits | Integer |  |

#### Return value

Type | Description
--- | ---
Array |

#### Tags

Name | Description
--- | ---
access | private

### _i2osp( \Math_BigInteger $x, Integer $xLen, ) : String

#### Description

Integer-to-Octet-String primitive
See {@link http://tools.ietf.org/html/rfc3447#section-4.1 RFC3447#section-4.1}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$x | \Math_BigInteger |  |
$xLen | Integer |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private

### _mgf1( String $mgfSeed, $maskLen, ) : String

#### Description

MGF1
See {@link http://tools.ietf.org/html/rfc3447#appendix-B.2.1 RFC3447#appendix-B.2.1}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$mgfSeed | String |  |
$maskLen | n/a |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private

### _os2ip( String $x, ) : \Math_BigInteger

#### Description

Octet-String-to-Integer primitive
See {@link http://tools.ietf.org/html/rfc3447#section-4.2 RFC3447#section-4.2}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$x | String |  |

#### Return value

Type | Description
--- | ---
\Math_BigInteger |

#### Tags

Name | Description
--- | ---
access | private

### _parseKey( String $key, Integer $type, ) : Array

#### Description

Break a public or private key down into its constituant components

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$key | String |  |
$type | Integer |  |

#### Return value

Type | Description
--- | ---
Array |

#### Tags

Name | Description
--- | ---
access | private
see |
see |

### _random( Integer $bytes, $nonzero = false, ) : String

#### Description

Generates a random string x bytes long

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$bytes | Integer |  |
$nonzero | n/a |  | false

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | public

### _rsadp( \Math_BigInteger $c, ) : \Math_BigInteger

#### Description

RSADP
See {@link http://tools.ietf.org/html/rfc3447#section-5.1.2 RFC3447#section-5.1.2}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$c | \Math_BigInteger |  |

#### Return value

Type | Description
--- | ---
\Math_BigInteger |

#### Tags

Name | Description
--- | ---
access | private

### _rsaep( \Math_BigInteger $m, ) : \Math_BigInteger

#### Description

RSAEP
See {@link http://tools.ietf.org/html/rfc3447#section-5.1.1 RFC3447#section-5.1.1}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$m | \Math_BigInteger |  |

#### Return value

Type | Description
--- | ---
\Math_BigInteger |

#### Tags

Name | Description
--- | ---
access | private

### _rsaes_oaep_decrypt( String $c, String $l = '', ) : String

#### Description

RSAES-OAEP-DECRYPT
See {@link http://tools.ietf.org/html/rfc3447#section-7.1.2 RFC3447#section-7.1.2}. The fact that the error messages aren't distinguishable from one another hinders debugging, but, to quote from RFC3447#section-7.1.2: Note. Care must be taken to ensure that an opponent cannot distinguish the different error conditions in Step 3.g, whether by error message or timing, or, more generally, learn partial information about the encoded message EM. Otherwise an opponent may be able to obtain useful information about the decryption of the ciphertext C, leading to a chosen-ciphertext attack such as the one observed by Manger [36]. As for $l... to quote from {@link http://tools.ietf.org/html/rfc3447#page-17 RFC3447#page-17}: Both the encryption and the decryption operations of RSAES-OAEP take the value of a label L as input. In this version of PKCS #1, L is the empty string; other uses of the label are outside the scope of this document.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$c | String |  |
$l | String |  | ''

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private

### _rsaes_oaep_encrypt( String $m, String $l = '', ) : String

#### Description

RSAES-OAEP-ENCRYPT
See {@link http://tools.ietf.org/html/rfc3447#section-7.1.1 RFC3447#section-7.1.1} and {http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding OAES}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$m | String |  |
$l | String |  | ''

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private

### _rsaes_pkcs1_v1_5_decrypt( String $c, ) : String

#### Description

RSAES-PKCS1-V1_5-DECRYPT
See {@link http://tools.ietf.org/html/rfc3447#section-7.2.2 RFC3447#section-7.2.2}. For compatability purposes, this function departs slightly from the description given in RFC3447. The reason being that RFC2313#section-8.1 (PKCS#1 v1.5) states that ciphertext's encrypted by the private key should have the second byte set to either 0 or 1 and that ciphertext's encrypted by the public key should have the second byte set to 2. In RFC3447 (PKCS#1 v2.1), the second byte is supposed to be 2 regardless of which key is used. for compatability purposes, we'll just check to make sure the second byte is 2 or less. If it is, we'll accept the decrypted string as valid. As a consequence of this, a private key encrypted ciphertext produced with Crypt_RSA may not decrypt with a strictly PKCS#1 v1.5 compliant RSA implementation. Public key encrypted ciphertext's should but not private key encrypted ciphertext's.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$c | String |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private

### _rsaes_pkcs1_v1_5_encrypt( String $m, ) : String

#### Description

RSAES-PKCS1-V1_5-ENCRYPT
See {@link http://tools.ietf.org/html/rfc3447#section-7.2.1 RFC3447#section-7.2.1}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$m | String |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private

### _rsasp1( \Math_BigInteger $m, ) : \Math_BigInteger

#### Description

RSASP1
See {@link http://tools.ietf.org/html/rfc3447#section-5.2.1 RFC3447#section-5.2.1}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$m | \Math_BigInteger |  |

#### Return value

Type | Description
--- | ---
\Math_BigInteger |

#### Tags

Name | Description
--- | ---
access | private

### _rsassa_pkcs1_v1_5_sign( String $m, ) : String

#### Description

RSASSA-PKCS1-V1_5-SIGN
See {@link http://tools.ietf.org/html/rfc3447#section-8.2.1 RFC3447#section-8.2.1}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$m | String |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private

### _rsassa_pkcs1_v1_5_verify( String $m, $s, ) : String

#### Description

RSASSA-PKCS1-V1_5-VERIFY
See {@link http://tools.ietf.org/html/rfc3447#section-8.2.2 RFC3447#section-8.2.2}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$m | String |  |
$s | n/a |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private

### _rsassa_pss_sign( String $m, ) : String

#### Description

RSASSA-PSS-SIGN
See {@link http://tools.ietf.org/html/rfc3447#section-8.1.1 RFC3447#section-8.1.1}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$m | String |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private

### _rsassa_pss_verify( String $m, String $s, ) : String

#### Description

RSASSA-PSS-VERIFY
See {@link http://tools.ietf.org/html/rfc3447#section-8.1.2 RFC3447#section-8.1.2}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$m | String |  |
$s | String |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private

### _rsavp1( \Math_BigInteger $s, ) : \Math_BigInteger

#### Description

RSAVP1
See {@link http://tools.ietf.org/html/rfc3447#section-5.2.2 RFC3447#section-5.2.2}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$s | \Math_BigInteger |  |

#### Return value

Type | Description
--- | ---
\Math_BigInteger |

#### Tags

Name | Description
--- | ---
access | private

### _start_element_handler( Resource $parser, String $name, Array $attribs, ) : n/a

#### Description

Start Element Handler
Called by xml_set_element_handler()

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$parser | Resource |  |
$name | String |  |
$attribs | Array |  |

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
access | private

### _stop_element_handler( Resource $parser, String $name, ) : n/a

#### Description

Stop Element Handler
Called by xml_set_element_handler()

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$parser | Resource |  |
$name | String |  |

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
access | private

### _string_shift( String $string, $index = 1, ) : String

#### Description

String Shift
Inspired by array_shift

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$string | String |  |
$index | n/a |  | 1

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
access | private

### createKey( $bits = 1024, $timeout = false, $partial = array(), ) : n/a

#### Description

Create public / private key pair
Returns an array with the following three elements: - 'privatekey': The private key. - 'publickey': The public key. - 'partialkey': A partially computed key (if the execution time exceeded $timeout). Will need to be passed back to Crypt_RSA::createKey() as the third parameter for further processing.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$bits | n/a |  | 1024
$timeout | n/a |  | false
$partial | n/a |  | array()

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
access | public

### decrypt( $ciphertext, ) : String

#### Description

Decryption

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$ciphertext | n/a |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
see |
access | public

### encrypt( String $plaintext, ) : String

#### Description

Encryption
Both CRYPT_RSA_ENCRYPTION_OAEP and CRYPT_RSA_ENCRYPTION_PKCS1 both place limits on how long $plaintext can be. If $plaintext exceeds those limits it will be broken up so that it does and the resultant ciphertext's will be concatenated together.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$plaintext | String |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
see |
access | public

### getPublicKey( Integer $type = CRYPT_RSA_PUBLIC_FORMAT_PKCS1, ) : n/a

#### Description

Returns the public key
The public key is only returned under two circumstances - if the private key had the public key embedded within it or if the public key was set via setPublicKey(). If the currently loaded key is supposed to be the public key this function won't return it since this library, for the most part, doesn't distinguish between public and private keys.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$type | Integer | optional | CRYPT_RSA_PUBLIC_FORMAT_PKCS1

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
see |
access | public

### loadKey( String $key, Integer $type = false, ) : n/a

#### Description

Loads a public or private key
Returns true on success and false on failure (ie. an incorrect password was provided or the key was malformed)

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$key | String |  |
$type | Integer | optional | false

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
access | public

### setEncryptionMode( Integer $mode, ) : n/a

#### Description

Set Encryption Mode
Valid values include CRYPT_RSA_ENCRYPTION_OAEP and CRYPT_RSA_ENCRYPTION_PKCS1.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$mode | Integer |  |

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
access | public

### setHash( String $hash, ) : n/a

#### Description

Determines which hashing function should be used
Used with signature production / verification and (if the encryption mode is CRYPT_RSA_ENCRYPTION_OAEP) encryption and decryption. If $hash isn't supported, sha1 is used.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$hash | String |  |

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
access | public

### setMGFHash( String $hash, ) : n/a

#### Description

Determines which hashing function should be used for the mask generation function
The mask generation function is used by CRYPT_RSA_ENCRYPTION_OAEP and CRYPT_RSA_SIGNATURE_PSS and although it's best if Hash and MGFHash are set to the same thing this is not a requirement.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$hash | String |  |

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
access | public

### setPassword( String $password, ) : n/a

#### Description

Sets the password
Private keys can be encrypted with a password. To unset the password, pass in the empty string or false. Or rather, pass in $password such that empty($password) is true.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$password | String |  |

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
see |
see |
access | public

### setPrivateKeyFormat( Integer $format, ) : n/a

#### Description

Determines the private key format

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$format | Integer |  |

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
see |
access | public

### setPublicKey( String $key, Integer $type = CRYPT_RSA_PUBLIC_FORMAT_PKCS1, ) : Boolean

#### Description

Defines the public key
Some private key formats define the public exponent and some don't. Those that don't define it are problematic when used in certain contexts. For example, in SSH-2, RSA authentication works by sending the public key along with a message signed by the private key to the server. The SSH-2 server looks the public key up in an index of public keys and if it's present then proceeds to verify the signature. Problem is, if your private key doesn't include the public exponent this won't work unless you manually add the public exponent. Do note that when a new key is loaded the index will be cleared. Returns true on success, false on failure

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$key | String |  |
$type | Integer | optional | CRYPT_RSA_PUBLIC_FORMAT_PKCS1

#### Return value

Type | Description
--- | ---
Boolean |

#### Tags

Name | Description
--- | ---
see |
access | public

### setPublicKeyFormat( Integer $format, ) : n/a

#### Description

Determines the public key format

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$format | Integer |  |

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
see |
access | public

### setSaltLength( $sLen, ) : n/a

#### Description

Determines the salt length
To quote from {@link http://tools.ietf.org/html/rfc3447#page-38 RFC3447#page-38}: Typical salt lengths in octets are hLen (the length of the output of the hash function Hash) and 0.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$sLen | n/a |  |

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
access | public

### setSignatureMode( Integer $mode, ) : n/a

#### Description

Set Signature Mode
Valid values include CRYPT_RSA_SIGNATURE_PSS and CRYPT_RSA_SIGNATURE_PKCS1

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$mode | Integer |  |

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
access | public

### sign( String $message, ) : String

#### Description

Create a signature

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$message | String |  |

#### Return value

Type | Description
--- | ---
String |

#### Tags

Name | Description
--- | ---
see |
access | public

### verify( String $message, String $signature, ) : Boolean

#### Description

Verifies a signature

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$message | String |  |
$signature | String |  |

#### Return value

Type | Description
--- | ---
Boolean |

#### Tags

Name | Description
--- | ---
see |
access | public

#### Properties

$coefficients, $components, $current, $encryptionMode, $exponent, $exponents, $hLen, $hash, $hashName, $k, $mgfHLen, $mgfHash, $modulus, $one, $password, $primes, $privateKeyFormat, $publicExponent, $publicKeyFormat, $sLen, $signatureMode, $zero,

### Array public $coefficients =

Coefficients for Chinese Remainder Theorem (ie. qInv)

### Array public $components = array()

Components
For use with parsing XML formatted keys. PHP's XML Parser functions use utilized - instead of PHP's DOM functions - because PHP's XML Parser functions work on PHP4 whereas PHP's DOM functions - although surperior - don't.

### Mixed public $current =

Current String
For use with parsing XML formatted keys.

### Integer public $encryptionMode = CRYPT_RSA_ENCRYPTION_OAEP

Encryption mode

### \Math_BigInteger public $exponent =

Exponent (ie. e or d)

### Array public $exponents =

Exponents for Chinese Remainder Theorem (ie. dP and dQ)

### Integer public $hLen =

Length of hash function output

### \Crypt_Hash public $hash =

Hash function

### String public $hashName =

Hash name

### \Math_BigInteger public $k =

Modulus length

### Integer public $mgfHLen =

Length of MGF hash function output

### \Crypt_Hash public $mgfHash =

Hash function for the Mask Generation Function

### \Math_BigInteger public $modulus =

Modulus (ie. n)

### Array public $one =

Precomputed One

### String public $password = ''

Password

### Array public $primes =

Primes for Chinese Remainder Theorem (ie. p and q)

### Integer public $privateKeyFormat = CRYPT_RSA_PRIVATE_FORMAT_PKCS1

Private Key Format

### Mixed public $publicExponent = false

Public Exponent

### Integer public $publicKeyFormat = CRYPT_RSA_PUBLIC_FORMAT_PKCS1

Public Key Format

### Integer public $sLen =

Length of salt

### Integer public $signatureMode = CRYPT_RSA_SIGNATURE_PSS

Signature mode

### Array public $zero =

Precomputed Zero
Documentation was generated by phpDocumentor 2.1.0 .

# Namespaces

- global

# Packages

- Crypt_AES
  - Crypt_AES
    Pure-PHP implementation of AES.
- Crypt_DES
  - Crypt_DES
    Pure-PHP implementation of DES.
- Crypt_Hash
  - Crypt_Hash
    Pure-PHP implementations of keyed-hash message authentication codes (HMACs) and various cryptographic hashing functions.
- Crypt_RC4
  - Crypt_RC4
    Pure-PHP implementation of RC4.
- Crypt_RSA
  - Crypt_RSA
    Pure-PHP PKCS#1 compliant implementation of RSA.
- Crypt_Random
- Crypt_Rijndael
  - Crypt_Rijndael
    Pure-PHP implementation of Rijndael.
- Crypt_TerraDES
  - Crypt_TripleDES
    Pure-PHP implementation of Triple DES.
- Crypt_TripleDES
- Help
- LDAP
  - Ldap
    Ldap manages connection to LDAP and includes several helper functions.
- Math_BigInteger
  - Math_BigInteger
    Pure-PHP arbitrary precision integer arithmetic library. Supports base-2, base-10, base-16, and base-256 numbers.
- Net_SFTP
  - Net_SFTP
    Pure-PHP implementations of SFTP.
- Net_SSH1
  - Net_SSH1
    Pure-PHP implementation of SSHv1.
- Net_SSH2
  - Net_SSH2
    Pure-PHP implementation of SSHv2.
- PDF
  - UFPDF
    Main UFPDF class for creating Unicode PDF documents
  - lamPDF
    Creates a LAM information page in PDF format.
  - xmlParser
    Simple XML parser.
- PHP_Compat
- configuration
  - LAMCfgMain
    This class manages config.cfg.
  - LAMConfig
    This class manages .conf files.
- horde.cipher
  - Horde_Cipher_blowfish
- lam
  - smbHash
    Calculates NT and LM hashes.
- lib
  - AttributeType
    Represents an LDAP AttributeType
  - MatchingRule
    Represents an LDAP MatchingRule
  - MatchingRuleUse
    Represents an LDAP schema matchingRuleUse entry
  - ObjectClass
    Represents an LDAP objectClass
  - ObjectClassAttribute
    A simple class for representing AttributeTypes used only by the ObjectClass class.
  - SchemaItem
    Generic parent class for all schema items. A schema item is an ObjectClass, an AttributeBype, a MatchingRule, or a Syntax.
  - Syntax
    Represents an LDAP Syntax
- lists
  - kolabSharedFolderTypeList
    Generates the list view.
  - lamAsteriskExtList
    Generates the list view.
  - lamBooleanListOption
    Boolean option for list configuration.
  - lamDHCPList
    Generates the list view.
  - lamGroupList
    Generates the list view.
  - lamHostList
    Generates the list view.
  - lamList
    Generates the list view.
  - lamListOption
    Represents a list configuration option.
  - lamListTool
    Represents a tool which can be included in the account lists.
  - lamMailAliasList
    Generates the list view.
  - lamNetgroupList
    Generates the list view.
  - lamPykotaBillingCodeTypeList
    Generates the list view.
  - lamPykotaPrinterTypeList
    Generates the list view.
  - lamSelectListOption
    Boolean option for list configuration.
  - lamSmbDomainList
    Generates the list view.
  - lamUserList
    Generates the list view.
- main
- metaHTML
  - htmlAccountPageButton
    Prints a button for the account pages.
  - htmlButton
    Simple button.
  - htmlDiv
    Creates a simple DIV element.
  - htmlElement
    Represents a HTML element.
  - htmlEqualHeight
    Sets all given elements to the same height.
  - htmlEqualWidth
    Sets all given elements to the same width.
  - htmlFieldset
    Generates a fieldset.
  - htmlGroup
    Groups multiple htmlElements.
  - htmlHelpLink
    Renders a help link.
  - htmlHiddenInput
    Generates a hidden input field.
  - htmlHorizontalLine
    Prints a horizontal line.
  - htmlImage
    Prints the HTML code for an image.
  - htmlInputCheckbox
    Prints the HTML code for a checkbox.
  - htmlInputField
    A standard input field.
  - htmlInputFileUpload
    Prints the HTML code for a file upload field.
  - htmlInputTextarea
    Prints the HTML code for a textarea.
  - htmlJavaScript
    Creates a JavaScript element.
  - htmlLink
    Generates a link.
  - htmlOutputText
    Prints the text and escapes contained HTML code by default.
  - htmlRadio
    Represents a radio selection.
  - htmlSelect
    Represents a select box.
  - htmlSortableList
    Creates a list of elements that can be sorted by the user via drag'n'drop.
  - htmlSpacer
    Adds an empty space with given width and height.
  - htmlStatusMessage
    Prints a status message (e.g. error message).
  - htmlSubTitle
    Generates a subtitle line. This is used to group multiple fields.
  - htmlTable
    Structures elements using a table.
  - htmlTableExtendedInputCheckbox
    Checkbox with descriptive label and help link.
  - htmlTableExtendedInputField
    An extended input field that combines label, input field and help.
  - htmlTableExtendedInputFileUpload
    File upload with descriptive label and help link.
  - htmlTableExtendedInputTextarea
    Text area with label and help link.
  - htmlTableExtendedRadio
    Radio list with descriptive label and help link.
  - htmlTableExtendedSelect
    Select with label and help link.
  - htmlTableRow
    A row inside a htmlTable.
  - htmlTitle
    Generates a title line. This is used for page titles.
- modules
  - account
    Manages the object class "account" for users and hosts.
  - accountContainer
    This class includes all modules and attributes of an account.
  - asteriskAccount
    Manages the Asterisk extension of user accounts.
  - asteriskExtension
    Manages Asterisk extensions.
  - asteriskVoicemail
    Manages the Asterisk extension of user accounts.
  - authorizedServiceObject
    Provides Authorized Service for accounts.
  - baseModule
    Parent class of all account modules.
  - ddns
    Manages DDNS entries.
  - dhcp_settings
    Manages DHCP entries.
  - eduPerson
    Manages the eduPerson extension for user accounts.
  - fixed_ip
    Manages DHCP host entries.
  - freeRadius
    Manages FreeRadius accounts.
  - generalInformation
    Shows general information like the creation time of an account.
  - hostObject
    Manages the hosts to which a user may login.
  - ieee802device
    Provides MAC addresses for hosts.
  - imapAccess
    Manages mailboxes on an IMAP server.
  - inetLocalMailRecipient
    Provides mail routing for users.
  - inetOrgPerson
    This module manages LDAP attributes of the object class inetOrgPerson (e.g. name and address).
  - kolabGroup
    Manages Kolab group accounts.
  - kolabSharedFolder
    Manages Kolab shared folders.
  - kolabUser
    Manages Kolab user accounts.
  - ldapPublicKey
    Manages SSH public keys.
  - nisMailAlias
    Provides NIS mail alias management.
  - nisnetgroup
    Manages entries based on the object class nisNetgroup.
  - passwordService
    This interface needs to be implemented by all account modules which manage passwords.
  - posixAccount
    Manages the object class "posixAccount" for users and hosts.
  - posixGroup
    Manages the object class "posixGroup" for groups.
  - puppetClient
    Manages Puppet configuration options.
  - pykotaBillingCode
    Manages PyKota billing codes.
  - pykotaGroup
    Manages PyKota group accounts.
  - pykotaGroupStructural
    Manages PyKota group accounts.
  - pykotaPrinter
    Manages PyKota printers.
  - pykotaUser
    Manages PyKota user accounts.
  - pykotaUserStructural
    Manages PyKota user accounts.
  - quota
    Manages quotas for users and groups.
  - range
    Manages DHCP ranges for DHCP server.
  - samba3domain
    Represents a Samba 3 domain entry
  - sambaDomain
    Manages Samba 3 domain entries.
  - sambaGroupMapping
    Manages the object class "sambaGroupMapping" for groups.
  - sambaMungedDial
    Manages terminal server settings for Samba 3.
  - sambaSamAccount
    Manages the object class "sambaSamAccount" for users and hosts.
  - shadowAccount
    Manages the object class "shadowAccount" for users.
  - smbHash
    Calculates NT and LM hashes.
  - systemQuotas
    Manages user quotas with the object class systemQuotas.
  - windowsGroup
    Manages Windows AD (e.g. Samba 4) groups.
  - windowsHost
    Manages Windows AD (e.g. Samba 4) hosts.
  - windowsPosixGroup
    Manages Unix groups in Windows LDAP schema.
  - windowsUser
    Manages Windows AD (e.g. Samba 4) users.
- phpLDAPadmin
- profiles
- selfService
  - selfServiceProfile
    Includes all settings of a self service profile.
- tools
  - LAMSubTool
    Represents a subtool.
  - LAMTool
    Represents a tool.
  - toolFileUpload
    File upload
  - toolMultiEdit
    Multi edit tool that allows LDAP operations on multiple entries.
  - toolOUEditor
    OU editor
  - toolPDFEditor
    PDF editor
  - toolProfileEditor
    Profile editor
  - toolSchemaBrowser
    Schema browser
  - toolServerInformation
    Server information
  - toolTests
    Tests page
- types
  - asteriskExt
    The account type for Asterisk extensions.
  - baseType
    This is the parent class of all account types.
  - dhcp
    The account type for DHCP
  - group
    The account type for group accounts (e.g. Unix and Samba).
  - host
    The account type for host accounts (e.g. Samba).
  - kolabSharedFolderType
    The account type for Kolab shared folders.
  - mailAlias
    The account type for mail aliases.
  - netgroup
    The account type for NIS netgroups.
  - pykotaBillingCodeType
    The account type for PyKota billing codes.
  - pykotaPrinterType
    The account type for PyKota printers.
  - smbDomain
    The account type for Samba domains.
  - user
    The account type for user accounts (e.g. Unix, Samba and Kolab).