TripleDES
extends DES
in package
Pure-PHP implementation of Triple DES.
Tags
Table of Contents
- DECRYPT = 1
- Contains $keys[self::DECRYPT]
- ENCRYPT = 0
- Contains $keys[self::ENCRYPT]
- ENGINE_INTERNAL = 1
- Base value for the internal implementation $engine switch
- ENGINE_MCRYPT = 2
- Base value for the mcrypt implementation $engine switch
- ENGINE_OPENSSL = 3
- Base value for the mcrypt implementation $engine switch
- MODE_3CBC = -2
- Encrypt / decrypt using inner chaining
- MODE_CBC = 2
- Encrypt / decrypt using the Code Book Chaining mode.
- MODE_CBC3 = phpseclibCryptBase::MODE_CBC
- Encrypt / decrypt using outer chaining
- MODE_CFB = 3
- Encrypt / decrypt using the Cipher Feedback mode.
- MODE_CFB8 = 38
- Encrypt / decrypt using the Cipher Feedback mode (8bit)
- MODE_CTR = -1
- Encrypt / decrypt using the Counter mode.
- MODE_ECB = 1
- Encrypt / decrypt using the Electronic Code Book mode.
- MODE_OFB = 4
- Encrypt / decrypt using the Output Feedback mode.
- MODE_STREAM = 5
- Encrypt / decrypt using streaming mode.
- $block_size : int
- The Block Length of the block cipher
- $cfb_init_len : int
- Optimizing value while CFB-encrypting
- $changed : bool
- Does internal cipher state need to be (re)initialized?
- $cipher_name_mcrypt : string
- The mcrypt specific name of the cipher
- $cipher_name_openssl : string
- The openssl specific name of the cipher
- $cipher_name_openssl_ecb : string
- The openssl specific name of the cipher in ECB mode
- $continuousBuffer : bool
- Continuous Buffer status
- $debuffer : array<string|int, mixed>
- Decryption buffer for CTR, OFB and CFB modes
- $dechanged : bool
- Does the demcrypt resource need to be (re)initialized?
- $decryptIV : string
- A "sliding" Initialization Vector
- $demcrypt : resource
- mcrypt resource for decryption
- $des : array<string|int, mixed>
- The \phpseclib\Crypt\DES objects
- $des_rounds : int
- Switch for DES/3DES encryption
- $ecb : resource
- mcrypt resource for CFB mode
- $enbuffer : array<string|int, mixed>
- Encryption buffer for CTR, OFB and CFB modes
- $enchanged : bool
- Does the enmcrypt resource need to be (re)initialized?
- $encryptIV : string
- A "sliding" Initialization Vector
- $engine : int
- Holds which crypt engine internaly should be use, which will be determined automatically on __construct()
- $enmcrypt : resource
- mcrypt resource for encryption
- $explicit_key_length : bool
- Has the key length explicitly been set or should it be derived from the key, itself?
- $inline_crypt : callable
- The name of the performance-optimized callback function
- $invipmap : array<string|int, mixed>
- Inverse IP mapping helper table.
- $ipmap : array<string|int, mixed>
- IP mapping helper table.
- $iv : string
- The Initialization Vector
- $key : string
- The Key
- $key_length : int
- Key Length (in bytes)
- $key_length_max : string
- max possible size of $key
- $keys : array<string|int, mixed>
- The Key Schedule
- $mode : int
- The Encryption Mode
- $mode_3cbc : bool
- Internal flag whether using self::MODE_3CBC or not
- $openssl_emulate_ctr : bool
- If OpenSSL can be used in ECB but not in CTR we can emulate CTR
- $openssl_mode_names : array<string|int, mixed>
- The OpenSSL names of the cipher / modes
- $openssl_options : mixed
- Determines what options are passed to openssl_encrypt/decrypt
- $paddable : bool
- Is the mode one that is paddable?
- $padding : bool
- Padding status
- $password_default_salt : string
- The default salt used by setPassword()
- $preferredEngine : int
- Holds the preferred crypt engine
- $sbox1 : array<string|int, mixed>
- Pre-permuted S-box1
- $sbox2 : array<string|int, mixed>
- Pre-permuted S-box2
- $sbox3 : array<string|int, mixed>
- Pre-permuted S-box3
- $sbox4 : array<string|int, mixed>
- Pre-permuted S-box4
- $sbox5 : array<string|int, mixed>
- Pre-permuted S-box5
- $sbox6 : array<string|int, mixed>
- Pre-permuted S-box6
- $sbox7 : array<string|int, mixed>
- Pre-permuted S-box7
- $sbox8 : array<string|int, mixed>
- Pre-permuted S-box8
- $shuffle : array<string|int, mixed>
- Shuffle table.
- $skip_key_adjustment : bool
- Don't truncate / null pad key
- $use_inline_crypt : mixed
- Holds whether performance-optimized $inline_crypt() can/should be used.
- $WHIRLPOOL_AVAILABLE : bool
- Whirlpool available flag
- __construct() : mixed
- Default Constructor.
- _createInlineCryptFunction() : string
- Creates the performance-optimized function for en/decrypt()
- _decryptBlock() : string
- Decrypts a block
- _encryptBlock() : string
- Encrypts a block
- _getLambdaFunctions() : array<string|int, mixed>
- Holds the lambda_functions table (classwide)
- _hashInlineCryptFunction() : string
- Generates a digest from $bytes
- _increment_str() : mixed
- Increment the current string
- _openssl_ctr_process() : string
- OpenSSL CTR Processor
- _openssl_ofb_process() : string
- OpenSSL OFB Processor
- _openssl_translate_mode() : int
- phpseclib <-> OpenSSL Mode Mapper
- _pad() : string
- Pads a string
- _processBlock() : string
- Encrypts or decrypts a 64-bit block
- _setEngine() : mixed
- Sets the engine as appropriate
- _setupInlineCrypt() : mixed
- Setup the performance-optimized function for de/encrypt()
- _setupKey() : mixed
- Creates the key schedule
- _string_pop() : string
- String Pop
- _string_shift() : string
- String Shift
- _unpad() : string
- Unpads a string.
- decrypt() : string
- Decrypts a message.
- disableContinuousBuffer() : mixed
- Treat consecutive packets as if they are a discontinuous buffer.
- disablePadding() : mixed
- Do not pad packets.
- enableContinuousBuffer() : mixed
- Treat consecutive "packets" as if they are a continuous buffer.
- enablePadding() : mixed
- Pad "packets".
- encrypt() : string
- Encrypts a message.
- getBlockLength() : int
- Returns the current block length in bits
- getEngine() : mixed
- Returns the engine currently being utilized
- getKeyLength() : int
- Returns the current key length in bits
- isValidEngine() : bool
- Test for engine validity
- safe_intval() : int
- Convert float to int
- safe_intval_inline() : string
- eval()'able string for in-line float to int
- setIV() : mixed
- Sets the initialization vector. (optional)
- setKey() : mixed
- Sets the key.
- setKeyLength() : mixed
- Sets the key length.
- setPreferredEngine() : int
- Sets the internal crypt engine
Constants
DECRYPT
Contains $keys[self::DECRYPT]
public
mixed
DECRYPT
= 1
ENCRYPT
Contains $keys[self::ENCRYPT]
public
mixed
ENCRYPT
= 0
ENGINE_INTERNAL
Base value for the internal implementation $engine switch
public
mixed
ENGINE_INTERNAL
= 1
ENGINE_MCRYPT
Base value for the mcrypt implementation $engine switch
public
mixed
ENGINE_MCRYPT
= 2
ENGINE_OPENSSL
Base value for the mcrypt implementation $engine switch
public
mixed
ENGINE_OPENSSL
= 3
MODE_3CBC
Encrypt / decrypt using inner chaining
public
mixed
MODE_3CBC
= -2
Inner chaining is used by SSH-1 and is generally considered to be less secure then outer chaining (self::MODE_CBC3).
MODE_CBC
Encrypt / decrypt using the Code Book Chaining mode.
public
mixed
MODE_CBC
= 2
Tags
MODE_CBC3
Encrypt / decrypt using outer chaining
public
mixed
MODE_CBC3
= phpseclibCryptBase::MODE_CBC
Outer chaining is used by SSH-2 and when the mode is set to \phpseclib\Crypt\Base::MODE_CBC.
MODE_CFB
Encrypt / decrypt using the Cipher Feedback mode.
public
mixed
MODE_CFB
= 3
Tags
MODE_CFB8
Encrypt / decrypt using the Cipher Feedback mode (8bit)
public
mixed
MODE_CFB8
= 38
MODE_CTR
Encrypt / decrypt using the Counter mode.
public
mixed
MODE_CTR
= -1
Set to -1 since that's what Crypt/Random.php uses to index the CTR mode.
Tags
MODE_ECB
Encrypt / decrypt using the Electronic Code Book mode.
public
mixed
MODE_ECB
= 1
Tags
MODE_OFB
Encrypt / decrypt using the Output Feedback mode.
public
mixed
MODE_OFB
= 4
Tags
MODE_STREAM
Encrypt / decrypt using streaming mode.
public
mixed
MODE_STREAM
= 5
Properties
$block_size
The Block Length of the block cipher
public
int
$block_size
= 16
Tags
$cfb_init_len
Optimizing value while CFB-encrypting
public
int
$cfb_init_len
= 750
Tags
$changed
Does internal cipher state need to be (re)initialized?
public
bool
$changed
= true
Tags
$cipher_name_mcrypt
The mcrypt specific name of the cipher
public
string
$cipher_name_mcrypt
= 'tripledes'
Tags
$cipher_name_openssl
The openssl specific name of the cipher
public
string
$cipher_name_openssl
Only used if $engine == self::ENGINE_OPENSSL
Tags
$cipher_name_openssl_ecb
The openssl specific name of the cipher in ECB mode
public
string
$cipher_name_openssl_ecb
If OpenSSL does not support the mode we're trying to use (CTR) it can still be emulated with ECB mode.
Tags
$continuousBuffer
Continuous Buffer status
public
bool
$continuousBuffer
= false
Tags
$debuffer
Decryption buffer for CTR, OFB and CFB modes
public
array<string|int, mixed>
$debuffer
Tags
$dechanged
Does the demcrypt resource need to be (re)initialized?
public
bool
$dechanged
= true
Tags
$decryptIV
A "sliding" Initialization Vector
public
string
$decryptIV
Tags
$demcrypt
mcrypt resource for decryption
public
resource
$demcrypt
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.
Tags
$des
The \phpseclib\Crypt\DES objects
public
array<string|int, mixed>
$des
Used only if $mode_3cbc === true
Tags
$des_rounds
Switch for DES/3DES encryption
public
int
$des_rounds
= 1
Used only if $engine == self::ENGINE_INTERNAL
Tags
$ecb
mcrypt resource for CFB mode
public
resource
$ecb
mcrypt's CFB mode, in (and only in) buffered context, is broken, so phpseclib implements the CFB mode by it self, even when the mcrypt php extension is available.
In order to do the CFB-mode work (fast) phpseclib use a separate ECB-mode mcrypt resource.
Tags
$enbuffer
Encryption buffer for CTR, OFB and CFB modes
public
array<string|int, mixed>
$enbuffer
Tags
$enchanged
Does the enmcrypt resource need to be (re)initialized?
public
bool
$enchanged
= true
Tags
$encryptIV
A "sliding" Initialization Vector
public
string
$encryptIV
Tags
$engine
Holds which crypt engine internaly should be use, which will be determined automatically on __construct()
public
int
$engine
Currently available $engines are:
- self::ENGINE_OPENSSL (very fast, php-extension: openssl, extension_loaded('openssl') required)
- self::ENGINE_MCRYPT (fast, php-extension: mcrypt, extension_loaded('mcrypt') required)
- self::ENGINE_INTERNAL (slower, pure php-engine, no php-extension required)
Tags
$enmcrypt
mcrypt resource for encryption
public
resource
$enmcrypt
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.
Tags
$explicit_key_length
Has the key length explicitly been set or should it be derived from the key, itself?
public
bool
$explicit_key_length
= false
Tags
$inline_crypt
The name of the performance-optimized callback function
public
callable
$inline_crypt
Used by encrypt() / decrypt() only if $engine == self::ENGINE_INTERNAL
Tags
$invipmap
Inverse IP mapping helper table.
public
array<string|int, mixed>
$invipmap
= array(0x0, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 0x8, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x4, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 0xc, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x2, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0xa, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x6, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 0xe, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x1, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 0x9, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 0x5, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0xd, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x3, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 0xb, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x7, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0xf, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff)
Indexing this table with a byte value reverses the bit order.
Tags
$ipmap
IP mapping helper table.
public
array<string|int, mixed>
$ipmap
= array(0x0, 0x10, 0x1, 0x11, 0x20, 0x30, 0x21, 0x31, 0x2, 0x12, 0x3, 0x13, 0x22, 0x32, 0x23, 0x33, 0x40, 0x50, 0x41, 0x51, 0x60, 0x70, 0x61, 0x71, 0x42, 0x52, 0x43, 0x53, 0x62, 0x72, 0x63, 0x73, 0x4, 0x14, 0x5, 0x15, 0x24, 0x34, 0x25, 0x35, 0x6, 0x16, 0x7, 0x17, 0x26, 0x36, 0x27, 0x37, 0x44, 0x54, 0x45, 0x55, 0x64, 0x74, 0x65, 0x75, 0x46, 0x56, 0x47, 0x57, 0x66, 0x76, 0x67, 0x77, 0x80, 0x90, 0x81, 0x91, 0xa0, 0xb0, 0xa1, 0xb1, 0x82, 0x92, 0x83, 0x93, 0xa2, 0xb2, 0xa3, 0xb3, 0xc0, 0xd0, 0xc1, 0xd1, 0xe0, 0xf0, 0xe1, 0xf1, 0xc2, 0xd2, 0xc3, 0xd3, 0xe2, 0xf2, 0xe3, 0xf3, 0x84, 0x94, 0x85, 0x95, 0xa4, 0xb4, 0xa5, 0xb5, 0x86, 0x96, 0x87, 0x97, 0xa6, 0xb6, 0xa7, 0xb7, 0xc4, 0xd4, 0xc5, 0xd5, 0xe4, 0xf4, 0xe5, 0xf5, 0xc6, 0xd6, 0xc7, 0xd7, 0xe6, 0xf6, 0xe7, 0xf7, 0x8, 0x18, 0x9, 0x19, 0x28, 0x38, 0x29, 0x39, 0xa, 0x1a, 0xb, 0x1b, 0x2a, 0x3a, 0x2b, 0x3b, 0x48, 0x58, 0x49, 0x59, 0x68, 0x78, 0x69, 0x79, 0x4a, 0x5a, 0x4b, 0x5b, 0x6a, 0x7a, 0x6b, 0x7b, 0xc, 0x1c, 0xd, 0x1d, 0x2c, 0x3c, 0x2d, 0x3d, 0xe, 0x1e, 0xf, 0x1f, 0x2e, 0x3e, 0x2f, 0x3f, 0x4c, 0x5c, 0x4d, 0x5d, 0x6c, 0x7c, 0x6d, 0x7d, 0x4e, 0x5e, 0x4f, 0x5f, 0x6e, 0x7e, 0x6f, 0x7f, 0x88, 0x98, 0x89, 0x99, 0xa8, 0xb8, 0xa9, 0xb9, 0x8a, 0x9a, 0x8b, 0x9b, 0xaa, 0xba, 0xab, 0xbb, 0xc8, 0xd8, 0xc9, 0xd9, 0xe8, 0xf8, 0xe9, 0xf9, 0xca, 0xda, 0xcb, 0xdb, 0xea, 0xfa, 0xeb, 0xfb, 0x8c, 0x9c, 0x8d, 0x9d, 0xac, 0xbc, 0xad, 0xbd, 0x8e, 0x9e, 0x8f, 0x9f, 0xae, 0xbe, 0xaf, 0xbf, 0xcc, 0xdc, 0xcd, 0xdd, 0xec, 0xfc, 0xed, 0xfd, 0xce, 0xde, 0xcf, 0xdf, 0xee, 0xfe, 0xef, 0xff)
Indexing this table with each source byte performs the initial bit permutation.
Tags
$iv
The Initialization Vector
public
string
$iv
Tags
$key
The Key
public
string
$key
= "