# LDAP Account Manager

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

# Properties

author
category
copyright
license
link
package
version

## Description

Pure-PHP implementation of Triple DES.
Uses mcrypt, if available, and an internal implementation, otherwise. Operates in the EDE3 mode (encrypt-decrypt-encrypt). PHP versions 4 and 5 Here's a short example of how to use this library: `setKey('abcdefghijklmnopqrstuvwx'); $size = 10 * 1024; $plaintext = ''; for ($i = 0; $i < $size; $i++) { $plaintext.= 'a'; } echo $des->decrypt($des->encrypt($plaintext)); ?>` 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_DES_MODE_3CBC = -2

Encrypt / decrypt using inner chaining
Inner chaining is used by SSH-1 and is generally considered to be less secure then outer chaining (CRYPT_DES_MODE_CBC3).

### CRYPT_DES_MODE_CBC3 = CRYPT_DES_MODE_CBC

Encrypt / decrypt using outer chaining
Outer chaining is used by SSH-2 and when the mode is set to CRYPT_DES_MODE_CBC.

### CRYPT_DES_MODE = CRYPT_DES_MODE_INTERNAL

## Classes

### Crypt_TripleDES

# Properties

Extends
Implements
access
public
author
Jim Wigginton <terrafrost@php.net>
package
Crypt_TerraDES
version
Abstract
No
Final
No

#### Description

Pure-PHP implementation of Triple DES.

#### Methods

Crypt_TripleDES, _generate_xor, _pad, _string_shift, _unpad, decrypt, disableContinuousBuffer, disablePadding, enableContinuousBuffer, enablePadding, encrypt, setIV, setKey,

### Crypt_TripleDES( $mode = CRYPT_DES_MODE_CBC, ) : \Crypt_TripleDES

#### Description

Default Constructor.
Determines whether or not the mcrypt extension should be used. $mode should only, at present, be CRYPT_DES_MODE_ECB or CRYPT_DES_MODE_CBC. If not explictly set, CRYPT_DES_MODE_CBC will be used.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$mode | n/a |  | CRYPT_DES_MODE_CBC

#### Return value

Type | Description
--- | ---
\Crypt_TripleDES |

#### Tags

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

### _generate_xor( Integer $length, String $iv, ) : n/a

#### Description

Generate CTR XOR encryption key
Encrypt the output of this and XOR it against the ciphertext / plaintext to get the plaintext / ciphertext in CTR mode.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$length | Integer |  |
$iv | String |  |

#### Return value

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

#### Tags

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

### _pad( $text, ) : n/a

#### Description

Pads a string
Pads a string using the RSA PKCS padding standards so that its length is a multiple of the blocksize (8). 8 - (strlen($text) & 7) bytes are added, each of which is equal to chr(8 - (strlen($text) & 7) If padding is disabled and $text is not a multiple of the blocksize, the string will be padded regardless and padding will, hence forth, be enabled.

#### Arguments

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

#### Return value

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

#### Tags

Name | Description
--- | ---
see |
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

### _unpad( $text, ) : n/a

#### Description

Unpads a string
If padding is enabled and the reported padding length is invalid the encryption key will be assumed to be wrong and false will be returned.

#### Arguments

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

#### Return value

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

#### Tags

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

### decrypt( String $ciphertext, ) : n/a

#### Description

Decrypts a message.

#### Arguments

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

#### Return value

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

#### Tags

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

### disableContinuousBuffer( ) : n/a

#### Description

Treat consecutive packets as if they are a discontinuous buffer.
The default behavior.

#### Return value

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

#### Tags

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

### disablePadding( ) : n/a

#### Description

Do not pad packets.

#### Return value

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

#### Tags

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

### enableContinuousBuffer( ) : n/a

#### Description

Treat consecutive "packets" as if they are a continuous buffer.
Say you have a 16-byte plaintext $plaintext. Using the default behavior, the two following code snippets will yield different outputs: `echo $des->encrypt(substr($plaintext, 0, 8)); echo $des->encrypt(substr($plaintext, 8, 8));` `echo $des->encrypt($plaintext);` The solution is to enable the continuous buffer. Although this will resolve the above discrepancy, it creates another, as demonstrated with the following: `$des->encrypt(substr($plaintext, 0, 8)); echo $des->decrypt($des->encrypt(substr($plaintext, 8, 8)));` `echo $des->decrypt($des->encrypt(substr($plaintext, 8, 8)));` With the continuous buffer disabled, these would yield the same output. With it enabled, they yield different outputs. The reason is due to the fact that the initialization vector's change after every encryption / decryption round when the continuous buffer is enabled. When it's disabled, they remain constant. Put another way, when the continuous buffer is enabled, the state of the Crypt_DES() object changes after each encryption / decryption round, whereas otherwise, it'd remain constant. For this reason, it's recommended that continuous buffers not be used. They do offer better security and are, in fact, sometimes required (SSH uses them), however, they are also less intuitive and more likely to cause you problems.

#### Return value

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

#### Tags

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

### enablePadding( ) : n/a

#### Description

Pad "packets".
DES works by encrypting eight bytes at a time. If you ever need to encrypt or decrypt something that's not a multiple of eight, it becomes necessary to pad the input so that it's length is a multiple of eight. Padding is enabled by default. Sometimes, however, it is undesirable to pad strings. Such is the case in SSH1, where "packets" are padded with random bytes before being encrypted. Unpad these packets and you risk stripping away characters that shouldn't be stripped away. (SSH knows how many bytes are added because the length is transmitted separately)

#### Return value

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

#### Tags

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

### encrypt( String $plaintext, ) : n/a

#### Description

Encrypts a message.

#### Arguments

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

#### Return value

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

#### Tags

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

### setIV( String $iv, ) : n/a

#### Description

Sets the initialization vector. (optional)
SetIV is not required when CRYPT_DES_MODE_ECB is being used. If not explictly set, it'll be assumed to be all zero's.

#### Arguments

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

#### Return value

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

#### Tags

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

### setKey( String $key, ) : n/a

#### Description

Sets the key.
Keys can be of any length. Triple DES, itself, can use 128-bit (eg. strlen($key) == 16) or 192-bit (eg. strlen($key) == 24) keys. This function pads and truncates $key as appropriate. DES also requires that every eighth bit be a parity bit, however, we'll ignore that. If the key is not explicitly set, it'll be assumed to be all zero's.

#### Arguments

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

#### Return value

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

#### Tags

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

#### Properties

$continuousBuffer, $debuffer, $dechanged, $decryptIV, $demcrypt, $des, $ecb, $enbuffer, $enchanged, $encryptIV, $enmcrypt, $iv, $key, $mode, $paddable, $padding,

### Boolean public $continuousBuffer = false

Continuous Buffer status

### String public $debuffer = ''

Decryption buffer for CTR, OFB and CFB modes

### Boolean public $dechanged = true

Does the demcrypt resource need to be (re)initialized?

### String public $decryptIV = "\0\0\0\0\0\0\0\0"

A "sliding" Initialization Vector

### String public $demcrypt =

mcrypt resource for decryption
The mcrypt resource can be recreated every time something needs to be created or it can be created just once. Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode.

### Array public $des =

The Crypt_DES objects

### String public $ecb =

mcrypt resource for CFB mode

### String public $enbuffer = ''

Encryption buffer for CTR, OFB and CFB modes

### Boolean public $enchanged = true

Does the enmcrypt resource need to be (re)initialized?

### String public $encryptIV = "\0\0\0\0\0\0\0\0"

A "sliding" Initialization Vector

### String public $enmcrypt =

mcrypt resource for encryption
The mcrypt resource can be recreated every time something needs to be created or it can be created just once. Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode.

### String public $iv = "\0\0\0\0\0\0\0\0"

The Initialization Vector

### String public $key = "\0\0\0\0\0\0\0\0"

The Three Keys

### Integer public $mode = CRYPT_DES_MODE_CBC

The Encryption Mode

### Boolean public $paddable = false

Is the mode one that is paddable?

### Boolean public $padding = true

Padding status
Documentation was generated by phpDocumentor 2.0.1 .

# 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
  - 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.
  - 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.
  - 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.
  - 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
  - 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).
  - mailAlias
    The account type for mail aliases.
  - netgroup
    The account type for NIS netgroups.
  - smbDomain
    The account type for Samba domains.
  - user
    The account type for user accounts (e.g. Unix, Samba and Kolab).