diff --git a/phpseclib/Crypt/AES.php b/phpseclib/Crypt/AES.php index 36364398..3a3a49f5 100644 --- a/phpseclib/Crypt/AES.php +++ b/phpseclib/Crypt/AES.php @@ -111,20 +111,6 @@ define('CRYPT_AES_MODE_CFB', CRYPT_MODE_CFB); define('CRYPT_AES_MODE_OFB', CRYPT_MODE_OFB); /**#@-*/ -/**#@+ - * @access private - * @see Crypt_Base::Crypt_Base() - */ -/** - * Toggles the internal implementation - */ -define('CRYPT_AES_MODE_INTERNAL', CRYPT_MODE_INTERNAL); -/** - * Toggles the mcrypt implementation - */ -define('CRYPT_AES_MODE_MCRYPT', CRYPT_MODE_MCRYPT); -/**#@-*/ - /** * Pure-PHP implementation of AES. * diff --git a/phpseclib/Crypt/Base.php b/phpseclib/Crypt/Base.php index 693c74f9..952ba070 100644 --- a/phpseclib/Crypt/Base.php +++ b/phpseclib/Crypt/Base.php @@ -105,15 +105,15 @@ define('CRYPT_MODE_STREAM', 5); /** * Base value for the internal implementation $engine switch */ -define('CRYPT_MODE_INTERNAL', 1); +define('CRYPT_ENGINE_INTERNAL', 1); /** * Base value for the mcrypt implementation $engine switch */ -define('CRYPT_MODE_MCRYPT', 2); +define('CRYPT_ENGINE_MCRYPT', 2); /** * Base value for the OpenSSL implementation $engine switch */ -define('CRYPT_MODE_OPENSSL', 3); +define('CRYPT_ENGINE_OPENSSL', 3); /**#@-*/ /** @@ -278,7 +278,7 @@ class Crypt_Base * Optimizing value while CFB-encrypting * * Only relevant if $continuousBuffer enabled - * and $engine == CRYPT_MODE_MCRYPT + * and $engine == CRYPT_ENGINE_MCRYPT * * It's faster to re-init $enmcrypt if * $buffer bytes > $cfb_init_len than @@ -330,9 +330,9 @@ class Crypt_Base * which will be determined automatically on __construct() * * Currently available $engines are: - * - CRYPT_MODE_OPENSSL (very fast, php-extension: openssl, extension_loaded('openssl') required) - * - CRYPT_MODE_MCRYPT (fast, php-extension: mcrypt, extension_loaded('mcrypt') required) - * - CRYPT_MODE_INTERNAL (slower, pure php-engine, no php-extension required) + * - CRYPT_ENGINE_OPENSSL (very fast, php-extension: openssl, extension_loaded('openssl') required) + * - CRYPT_ENGINE_MCRYPT (fast, php-extension: mcrypt, extension_loaded('mcrypt') required) + * - CRYPT_ENGINE_INTERNAL (slower, pure php-engine, no php-extension required) * * @see Crypt_Base::_setEngine() * @see Crypt_Base::encrypt() @@ -355,7 +355,7 @@ class Crypt_Base /** * The mcrypt specific name of the cipher * - * Only used if $engine == CRYPT_MODE_MCRYPT + * Only used if $engine == CRYPT_ENGINE_MCRYPT * * @link http://www.php.net/mcrypt_module_open * @link http://www.php.net/mcrypt_list_algorithms @@ -368,7 +368,7 @@ class Crypt_Base /** * The openssl specific name of the cipher * - * Only used if $engine == CRYPT_MODE_OPENSSL + * Only used if $engine == CRYPT_ENGINE_OPENSSL * * @link http://www.php.net/openssl-get-cipher-methods * @var String @@ -433,7 +433,7 @@ class Crypt_Base * The name of the performance-optimized callback function * * Used by encrypt() / decrypt() - * only if $engine == CRYPT_MODE_INTERNAL + * only if $engine == CRYPT_ENGINE_INTERNAL * * @see Crypt_Base::encrypt() * @see Crypt_Base::decrypt() @@ -685,7 +685,7 @@ class Crypt_Base $plaintext = $this->_pad($plaintext); } - if ($this->engine === CRYPT_MODE_OPENSSL) { + if ($this->engine === CRYPT_ENGINE_OPENSSL) { if ($this->changed) { $this->_clearBuffers(); $this->changed = false; @@ -757,7 +757,7 @@ class Crypt_Base } } - if ($this->engine === CRYPT_MODE_MCRYPT) { + if ($this->engine === CRYPT_ENGINE_MCRYPT) { if ($this->changed) { $this->_setupMcrypt(); $this->changed = false; @@ -984,7 +984,7 @@ class Crypt_Base $ciphertext = str_pad($ciphertext, strlen($ciphertext) + ($this->block_size - strlen($ciphertext) % $this->block_size) % $this->block_size, chr(0)); } - if ($this->engine === CRYPT_MODE_OPENSSL) { + if ($this->engine === CRYPT_ENGINE_OPENSSL) { if ($this->changed) { $this->_clearBuffers(); $this->changed = false; @@ -1055,7 +1055,7 @@ class Crypt_Base return $this->paddable ? $this->_unpad($plaintext) : $plaintext; } - if ($this->engine === CRYPT_MODE_MCRYPT) { + if ($this->engine === CRYPT_ENGINE_MCRYPT) { $block_size = $this->block_size; if ($this->changed) { $this->_setupMcrypt(); @@ -1525,7 +1525,7 @@ class Crypt_Base function isValidEngine($engine) { switch ($engine) { - case CRYPT_MODE_OPENSSL: + case CRYPT_ENGINE_OPENSSL: $this->openssl_emulate_ctr = false; $result = $this->cipher_name_openssl && extension_loaded('openssl') && @@ -1556,11 +1556,11 @@ class Crypt_Base } } return false; - case CRYPT_MODE_MCRYPT: + case CRYPT_ENGINE_MCRYPT: return $this->cipher_name_mcrypt && extension_loaded('mcrypt') && in_array($this->cipher_name_mcrypt, mcrypt_list_algorithms()); - case CRYPT_MODE_INTERNAL: + case CRYPT_ENGINE_INTERNAL: return true; } } @@ -1570,11 +1570,11 @@ class Crypt_Base * * Currently, $engine could be: * - * - CRYPT_MODE_OPENSSL [very fast] + * - CRYPT_ENGINE_OPENSSL [very fast] * - * - CRYPT_MODE_MCRYPT [fast] + * - CRYPT_ENGINE_MCRYPT [fast] * - * - CRYPT_MODE_INTERNAL [slow] + * - CRYPT_ENGINE_INTERNAL [slow] * * If the preferred crypt engine is not available the fastest available one will be used * @@ -1585,13 +1585,13 @@ class Crypt_Base function setPreferredEngine($engine) { switch ($engine) { - //case CRYPT_MODE_OPENSSL: - case CRYPT_MODE_MCRYPT: - case CRYPT_MODE_INTERNAL: + //case CRYPT_ENGINE_OPENSSL: + case CRYPT_ENGINE_MCRYPT: + case CRYPT_ENGINE_INTERNAL: $this->preferredEngine = $engine; break; default: - $this->preferredEngine = CRYPT_MODE_OPENSSL; + $this->preferredEngine = CRYPT_ENGINE_OPENSSL; } $this->_setEngine(); @@ -1620,17 +1620,17 @@ class Crypt_Base case $this->isValidEngine($this->preferredEngine): $this->engine = $this->preferredEngine; break; - case $this->isValidEngine(CRYPT_MODE_OPENSSL): - $this->engine = CRYPT_MODE_OPENSSL; + case $this->isValidEngine(CRYPT_ENGINE_OPENSSL): + $this->engine = CRYPT_ENGINE_OPENSSL; break; - case $this->isValidEngine(CRYPT_MODE_MCRYPT): - $this->engine = CRYPT_MODE_MCRYPT; + case $this->isValidEngine(CRYPT_ENGINE_MCRYPT): + $this->engine = CRYPT_ENGINE_MCRYPT; break; default: - $this->engine = CRYPT_MODE_INTERNAL; + $this->engine = CRYPT_ENGINE_INTERNAL; } - if ($this->engine != CRYPT_MODE_MCRYPT && $this->enmcrypt) { + if ($this->engine != CRYPT_ENGINE_MCRYPT && $this->enmcrypt) { // Closing the current mcrypt resource(s). _mcryptSetup() will, if needed, // (re)open them with the module named in $this->cipher_name_mcrypt mcrypt_module_close($this->enmcrypt); @@ -1676,7 +1676,7 @@ class Crypt_Base /** * Setup the key (expansion) * - * Only used if $engine == CRYPT_MODE_INTERNAL + * Only used if $engine == CRYPT_ENGINE_INTERNAL * * @see Crypt_Base::_setup() * @access private @@ -1688,10 +1688,10 @@ class Crypt_Base } /** - * Setup the CRYPT_MODE_INTERNAL $engine + * Setup the CRYPT_ENGINE_INTERNAL $engine * * (re)init, if necessary, the internal cipher $engine and flush all $buffers - * Used (only) if $engine == CRYPT_MODE_INTERNAL + * Used (only) if $engine == CRYPT_ENGINE_INTERNAL * * _setup() will be called each time if $changed === true * typically this happens when using one or more of following public methods: @@ -1722,10 +1722,10 @@ class Crypt_Base } /** - * Setup the CRYPT_MODE_MCRYPT $engine + * Setup the CRYPT_ENGINE_MCRYPT $engine * * (re)init, if necessary, the (ext)mcrypt resources and flush all $buffers - * Used (only) if $engine = CRYPT_MODE_MCRYPT + * Used (only) if $engine = CRYPT_ENGINE_MCRYPT * * _setupMcrypt() will be called each time if $changed === true * typically this happens when using one or more of following public methods: @@ -1935,7 +1935,7 @@ class Crypt_Base * * _setupInlineCrypt() would be called only if: * - * - $engine == CRYPT_MODE_INTERNAL and + * - $engine == CRYPT_ENGINE_INTERNAL and * * - $use_inline_crypt === true * diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index 9b41cca3..a8788470 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -394,7 +394,7 @@ class Crypt_Blowfish extends Crypt_Base */ function isValidEngine($engine) { - if ($engine == CRYPT_MODE_OPENSSL) { + if ($engine == CRYPT_ENGINE_OPENSSL) { if (strlen($this->key) != 16) { return false; } diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index 395f9d30..792a3350 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -675,7 +675,7 @@ class Crypt_DES extends Crypt_Base */ function isValidEngine($engine) { - if ($engine == CRYPT_MODE_OPENSSL) { + if ($engine == CRYPT_ENGINE_OPENSSL) { $this->cipher_name_openssl_ecb = 'des-ecb'; $this->cipher_name_openssl = 'des-' . $this->_openssl_translate_mode(); } diff --git a/phpseclib/Crypt/RC2.php b/phpseclib/Crypt/RC2.php index f6857c7e..8fe34b68 100644 --- a/phpseclib/Crypt/RC2.php +++ b/phpseclib/Crypt/RC2.php @@ -366,7 +366,7 @@ class Crypt_RC2 extends Crypt_Base function isValidEngine($engine) { switch ($engine) { - case CRYPT_MODE_OPENSSL: + case CRYPT_ENGINE_OPENSSL: if ($this->current_key_length != 128 && strlen($this->orig_key) != 16) { return false; } @@ -464,7 +464,7 @@ class Crypt_RC2 extends Crypt_Base */ function encrypt($plaintext) { - if ($this->engine == CRYPT_MODE_OPENSSL) { + if ($this->engine == CRYPT_ENGINE_OPENSSL) { $temp = $this->key; $this->key = $this->orig_key; $result = parent::encrypt($plaintext); @@ -487,7 +487,7 @@ class Crypt_RC2 extends Crypt_Base */ function decrypt($ciphertext) { - if ($this->engine == CRYPT_MODE_OPENSSL) { + if ($this->engine == CRYPT_ENGINE_OPENSSL) { $temp = $this->key; $this->key = $this->orig_key; $result = parent::decrypt($ciphertext); @@ -589,7 +589,7 @@ class Crypt_RC2 extends Crypt_Base } /** - * Setup the CRYPT_MODE_MCRYPT $engine + * Setup the CRYPT_ENGINE_MCRYPT $engine * * @see Crypt_Base::_setupMcrypt() * @access private diff --git a/phpseclib/Crypt/RC4.php b/phpseclib/Crypt/RC4.php index 4c473a01..7d9e1f05 100644 --- a/phpseclib/Crypt/RC4.php +++ b/phpseclib/Crypt/RC4.php @@ -181,7 +181,7 @@ class Crypt_RC4 extends Crypt_Base function isValidEngine($engine) { switch ($engine) { - case CRYPT_MODE_OPENSSL: + case CRYPT_ENGINE_OPENSSL: switch (strlen($this->key)) { case 5: $this->cipher_name_openssl = 'rc4-40'; @@ -249,7 +249,7 @@ class Crypt_RC4 extends Crypt_Base */ function encrypt($plaintext) { - if ($this->engine == CRYPT_MODE_MCRYPT) { + if ($this->engine == CRYPT_ENGINE_MCRYPT) { return parent::encrypt($plaintext); } return $this->_crypt($plaintext, CRYPT_RC4_ENCRYPT); @@ -269,7 +269,7 @@ class Crypt_RC4 extends Crypt_Base */ function decrypt($ciphertext) { - if ($this->engine == CRYPT_MODE_MCRYPT) { + if ($this->engine == CRYPT_ENGINE_MCRYPT) { return parent::decrypt($ciphertext); } return $this->_crypt($ciphertext, CRYPT_RC4_DECRYPT); diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index ae34d615..be6b9a59 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -411,14 +411,14 @@ class Crypt_Rijndael extends Crypt_Base function isValidEngine($engine) { switch ($engine) { - case CRYPT_MODE_OPENSSL: + case CRYPT_ENGINE_OPENSSL: if ($this->block_size != 16) { return false; } $this->cipher_name_openssl_ecb = 'aes-' . ($this->key_size << 3) . '-ecb'; $this->cipher_name_openssl = 'aes-' . ($this->key_size << 3) . '-' . $this->_openssl_translate_mode(); break; - case CRYPT_MODE_MCRYPT: + case CRYPT_ENGINE_MCRYPT: $this->cipher_name_mcrypt = 'rijndael-' . ($this->block_size << 3); if ($this->key_size % 8) { // is it a 160/224-bit key? // mcrypt is not usable for them, only for 128/192/256-bit keys @@ -430,7 +430,7 @@ class Crypt_Rijndael extends Crypt_Base } /** - * Setup the CRYPT_MODE_MCRYPT $engine + * Setup the CRYPT_ENGINE_MCRYPT $engine * * @see Crypt_Base::_setupMcrypt() * @access private diff --git a/phpseclib/Crypt/TripleDES.php b/phpseclib/Crypt/TripleDES.php index c75000ac..5a3f23c2 100644 --- a/phpseclib/Crypt/TripleDES.php +++ b/phpseclib/Crypt/TripleDES.php @@ -230,7 +230,7 @@ class Crypt_TripleDES extends Crypt_DES */ function isValidEngine($engine) { - if ($engine == CRYPT_MODE_OPENSSL) { + if ($engine == CRYPT_ENGINE_OPENSSL) { $this->cipher_name_openssl_ecb = 'des-ede3'; $mode = $this->_openssl_translate_mode(); $this->cipher_name_openssl = $mode == 'ecb' ? 'des-ede3' : 'des-ede3-' . $mode;