ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
|
Public Member Functions | |
__construct ($mode=Base::MODE_CBC) | |
Default Constructor. More... | |
isValidEngine ($engine) | |
Test for engine validity. More... | |
setIV ($iv) | |
Sets the initialization vector. More... | |
setKeyLength ($length) | |
Sets the key length. More... | |
setKey ($key) | |
Sets the key. More... | |
encrypt ($plaintext) | |
Encrypts a message. More... | |
decrypt ($ciphertext) | |
Decrypts a message. More... | |
enableContinuousBuffer () | |
Treat consecutive "packets" as if they are a continuous buffer. More... | |
disableContinuousBuffer () | |
Treat consecutive packets as if they are a discontinuous buffer. More... | |
_setupKey () | |
Creates the key schedule. More... | |
setPreferredEngine ($engine) | |
Sets the internal crypt engine. More... | |
![]() | |
isValidEngine ($engine) | |
Test for engine validity. More... | |
setKey ($key) | |
Sets the key. More... | |
_encryptBlock ($in) | |
Encrypts a block. More... | |
_decryptBlock ($in) | |
Decrypts a block. More... | |
_processBlock ($block, $mode) | |
Encrypts or decrypts a 64-bit block. More... | |
_setupKey () | |
Creates the key schedule. More... | |
_setupInlineCrypt () | |
Setup the performance-optimized function for de/encrypt() More... | |
![]() | |
__construct ($mode=self::MODE_CBC) | |
Default Constructor. More... | |
setIV ($iv) | |
Sets the initialization vector. More... | |
setKeyLength ($length) | |
Sets the key length. More... | |
getKeyLength () | |
Returns the current key length in bits. More... | |
getBlockLength () | |
Returns the current block length in bits. More... | |
setKey ($key) | |
Sets the key. More... | |
setPassword ($password, $method='pbkdf2') | |
Sets the password. More... | |
encrypt ($plaintext) | |
Encrypts a message. More... | |
decrypt ($ciphertext) | |
Decrypts a message. More... | |
_openssl_ctr_process ($plaintext, &$encryptIV, &$buffer) | |
OpenSSL CTR Processor. More... | |
_openssl_ofb_process ($plaintext, &$encryptIV, &$buffer) | |
OpenSSL OFB Processor. More... | |
_openssl_translate_mode () | |
phpseclib <-> OpenSSL Mode Mapper More... | |
enablePadding () | |
Pad "packets". More... | |
disablePadding () | |
Do not pad packets. More... | |
enableContinuousBuffer () | |
Treat consecutive "packets" as if they are a continuous buffer. More... | |
disableContinuousBuffer () | |
Treat consecutive packets as if they are a discontinuous buffer. More... | |
isValidEngine ($engine) | |
Test for engine validity. More... | |
setPreferredEngine ($engine) | |
Sets the preferred crypt engine. More... | |
getEngine () | |
Returns the engine currently being utilized. More... | |
_setEngine () | |
Sets the engine as appropriate. More... | |
_encryptBlock ($in) | |
Encrypts a block. More... | |
_decryptBlock ($in) | |
Decrypts a block. More... | |
_setupKey () | |
Setup the key (expansion) More... | |
_setup () | |
Setup the self::ENGINE_INTERNAL $engine. More... | |
_setupMcrypt () | |
Setup the self::ENGINE_MCRYPT $engine. More... | |
_pad ($text) | |
Pads a string. More... | |
_unpad ($text) | |
Unpads a string. More... | |
_clearBuffers () | |
Clears internal buffers. More... | |
_string_shift (&$string, $index=1) | |
String Shift. More... | |
_string_pop (&$string, $index=1) | |
String Pop. More... | |
_increment_str (&$var) | |
Increment the current string. More... | |
_setupInlineCrypt () | |
Setup the performance-optimized function for de/encrypt() More... | |
_createInlineCryptFunction ($cipher_code) | |
Creates the performance-optimized function for en/decrypt() More... | |
& | _getLambdaFunctions () |
Holds the lambda_functions table (classwide) More... | |
_hashInlineCryptFunction ($bytes) | |
Generates a digest from $bytes. More... | |
Data Fields | |
const | MODE_3CBC = -2 |
Encrypt / decrypt using inner chaining. More... | |
const | MODE_CBC3 = Base::MODE_CBC |
Encrypt / decrypt using outer chaining. More... | |
$key_length = 24 | |
$password_default_salt = 'phpseclib' | |
$cipher_name_mcrypt = 'tripledes' | |
$cfb_init_len = 750 | |
$key_length_max = 24 | |
$mode_3cbc | |
$des | |
![]() | |
const | ENCRYPT = 0 |
#+ private More... | |
const | DECRYPT = 1 |
Contains $keys[self::DECRYPT]. More... | |
$block_size = 8 | |
$key_length = 8 | |
$cipher_name_mcrypt = 'des' | |
$openssl_mode_names | |
$cfb_init_len = 500 | |
$des_rounds = 1 | |
$key_length_max = 8 | |
$keys | |
$shuffle | |
$ipmap | |
$invipmap | |
$sbox1 | |
$sbox2 | |
$sbox3 | |
$sbox4 | |
$sbox5 | |
$sbox6 | |
$sbox7 | |
$sbox8 | |
![]() | |
const | MODE_CTR = -1 |
#+ public More... | |
const | MODE_ECB = 1 |
Encrypt / decrypt using the Electronic Code Book mode. More... | |
const | MODE_CBC = 2 |
Encrypt / decrypt using the Code Book Chaining mode. More... | |
const | MODE_CFB = 3 |
Encrypt / decrypt using the Cipher Feedback mode. More... | |
const | MODE_OFB = 4 |
Encrypt / decrypt using the Output Feedback mode. More... | |
const | MODE_STREAM = 5 |
Encrypt / decrypt using streaming mode. More... | |
const | ENGINE_INTERNAL = 1 |
#+ private More... | |
const | ENGINE_MCRYPT = 2 |
Base value for the mcrypt implementation $engine switch. More... | |
const | ENGINE_OPENSSL = 3 |
Base value for the mcrypt implementation $engine switch. More... | |
$mode | |
$block_size = 16 | |
$key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" | |
$iv | |
$encryptIV | |
$decryptIV | |
$continuousBuffer = false | |
$enbuffer | |
$debuffer | |
$enmcrypt | |
$demcrypt | |
$enchanged = true | |
$dechanged = true | |
$ecb | |
$cfb_init_len = 600 | |
$changed = true | |
$padding = true | |
$paddable = false | |
$engine | |
$preferredEngine | |
$cipher_name_mcrypt | |
$cipher_name_openssl | |
$cipher_name_openssl_ecb | |
$password_default_salt = 'phpseclib/salt' | |
$inline_crypt | |
$use_inline_crypt | |
$openssl_emulate_ctr = false | |
$openssl_options | |
$explicit_key_length = false | |
$skip_key_adjustment = false | |
Additional Inherited Members | |
![]() | |
static | $WHIRLPOOL_AVAILABLE |
Definition at line 49 of file TripleDES.php.
phpseclib\Crypt\TripleDES::__construct | ( | $mode = Base::MODE_CBC | ) |
Default Constructor.
Determines whether or not the mcrypt extension should be used.
$mode could be:
If not explicitly set, ::MODE_CBC will be used.
int | $mode | public |
Definition at line 157 of file TripleDES.php.
References phpseclib\Crypt\Base\$mode, and phpseclib\Crypt\Base\MODE_CBC.
phpseclib\Crypt\TripleDES::_setupKey | ( | ) |
Creates the key schedule.
Definition at line 416 of file TripleDES.php.
phpseclib\Crypt\TripleDES::decrypt | ( | $ciphertext | ) |
Decrypts a message.
string | $ciphertext |
Definition at line 325 of file TripleDES.php.
References phpseclib\Crypt\Base\_unpad(), and phpseclib\Crypt\TripleDES\encrypt().
Referenced by phpseclib\Crypt\TripleDES\encrypt().
phpseclib\Crypt\TripleDES::disableContinuousBuffer | ( | ) |
Treat consecutive packets as if they are a discontinuous buffer.
The default behavior.
Definition at line 399 of file TripleDES.php.
phpseclib\Crypt\TripleDES::enableContinuousBuffer | ( | ) |
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 () 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.
Definition at line 380 of file TripleDES.php.
phpseclib\Crypt\TripleDES::encrypt | ( | $plaintext | ) |
Encrypts a message.
string | $plaintext |
Definition at line 298 of file TripleDES.php.
References phpseclib\Crypt\Base\_pad(), and phpseclib\Crypt\TripleDES\decrypt().
Referenced by phpseclib\Crypt\TripleDES\decrypt().
phpseclib\Crypt\TripleDES::isValidEngine | ( | $engine | ) |
Test for engine validity.
This is mainly just a wrapper to set things up for ::isValidEngine()
int | $engine | public |
Definition at line 194 of file TripleDES.php.
References phpseclib\Crypt\Base\$engine, phpseclib\Crypt\Base\$mode, and phpseclib\Crypt\Base\_openssl_translate_mode().
phpseclib\Crypt\TripleDES::setIV | ( | $iv | ) |
Sets the initialization vector.
(optional)
SetIV is not required when ::MODE_ECB is being used. If not explicitly set, it'll be assumed to be all zero's.
string | $iv |
Definition at line 215 of file TripleDES.php.
References phpseclib\Crypt\Base\$iv.
phpseclib\Crypt\TripleDES::setKey | ( | $key | ) |
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 null bytes.
public
string | $key |
Definition at line 266 of file TripleDES.php.
References phpseclib\Crypt\Base\$key.
phpseclib\Crypt\TripleDES::setKeyLength | ( | $length | ) |
Sets the key length.
Valid key lengths are 64, 128 and 192
int | $length |
Definition at line 234 of file TripleDES.php.
phpseclib\Crypt\TripleDES::setPreferredEngine | ( | $engine | ) |
Sets the internal crypt engine.
int | $engine | public |
Definition at line 453 of file TripleDES.php.
References phpseclib\Crypt\Base\$engine.
phpseclib\Crypt\TripleDES::$cfb_init_len = 750 |
Definition at line 101 of file TripleDES.php.
phpseclib\Crypt\TripleDES::$cipher_name_mcrypt = 'tripledes' |
Definition at line 92 of file TripleDES.php.
phpseclib\Crypt\TripleDES::$des |
Definition at line 129 of file TripleDES.php.
phpseclib\Crypt\TripleDES::$key_length = 24 |
Definition at line 72 of file TripleDES.php.
phpseclib\Crypt\TripleDES::$key_length_max = 24 |
Definition at line 111 of file TripleDES.php.
phpseclib\Crypt\TripleDES::$mode_3cbc |
Definition at line 119 of file TripleDES.php.
phpseclib\Crypt\TripleDES::$password_default_salt = 'phpseclib' |
Definition at line 82 of file TripleDES.php.
const phpseclib\Crypt\TripleDES::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 (self::MODE_CBC3).
Definition at line 56 of file TripleDES.php.
Referenced by phpseclib\Net\SSH1\_connect().
const phpseclib\Crypt\TripleDES::MODE_CBC3 = Base::MODE_CBC |
Encrypt / decrypt using outer chaining.
Outer chaining is used by SSH-2 and when the mode is set to ::MODE_CBC.
Definition at line 63 of file TripleDES.php.