From b39d2597dde9ae656c051237fe9df26fbdf3f7ce Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Mon, 14 May 2012 01:21:21 +0000 Subject: [PATCH] - if the algorithm is not supported upon mcrypt's initial initialization use the internal implementation git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@220 21d32557-59b3-4da0-833f-c5933fad653e --- phpseclib/Crypt/AES.php | 5 +---- phpseclib/Crypt/DES.php | 5 +---- phpseclib/Crypt/RC4.php | 32 +------------------------------- phpseclib/Crypt/TripleDES.php | 5 +---- 4 files changed, 4 insertions(+), 43 deletions(-) diff --git a/phpseclib/Crypt/AES.php b/phpseclib/Crypt/AES.php index 07e975b8..94a08423 100644 --- a/phpseclib/Crypt/AES.php +++ b/phpseclib/Crypt/AES.php @@ -178,10 +178,7 @@ class Crypt_AES extends Crypt_Rijndael { { if ( !defined('CRYPT_AES_MODE') ) { switch (true) { - case extension_loaded('mcrypt'): - // i'd check to see if aes was supported, by doing in_array('des', mcrypt_list_algorithms('')), - // but since that can be changed after the object has been created, there doesn't seem to be - // a lot of point... + case extension_loaded('mcrypt') && in_array('rijndael-128', mcrypt_list_algorithms()): define('CRYPT_AES_MODE', CRYPT_AES_MODE_MCRYPT); break; default: diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index b8322507..c249d6b6 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -295,10 +295,7 @@ class Crypt_DES { { if ( !defined('CRYPT_DES_MODE') ) { switch (true) { - case extension_loaded('mcrypt'): - // i'd check to see if des was supported, by doing in_array('des', mcrypt_list_algorithms('')), - // but since that can be changed after the object has been created, there doesn't seem to be - // a lot of point... + case extension_loaded('mcrypt') && in_array('des', mcrypt_list_algorithms()): define('CRYPT_DES_MODE', CRYPT_DES_MODE_MCRYPT); break; default: diff --git a/phpseclib/Crypt/RC4.php b/phpseclib/Crypt/RC4.php index 0826362d..0eb1c2b5 100644 --- a/phpseclib/Crypt/RC4.php +++ b/phpseclib/Crypt/RC4.php @@ -142,15 +142,6 @@ class Crypt_RC4 { */ var $decryptIndex = 0; - /** - * MCrypt parameters - * - * @see Crypt_RC4::setMCrypt() - * @var Array - * @access private - */ - var $mcrypt = array('', ''); - /** * The Encryption Algorithm * @@ -184,10 +175,7 @@ class Crypt_RC4 { { if ( !defined('CRYPT_RC4_MODE') ) { switch (true) { - case extension_loaded('mcrypt') && (defined('MCRYPT_ARCFOUR') || defined('MCRYPT_RC4')): - // i'd check to see if rc4 was supported, by doing in_array('arcfour', mcrypt_list_algorithms('')), - // but since that can be changed after the object has been created, there doesn't seem to be - // a lot of point... + case extension_loaded('mcrypt') && (defined('MCRYPT_ARCFOUR') || defined('MCRYPT_RC4')) && in_array('arcfour', mcrypt_list_algorithms()): define('CRYPT_RC4_MODE', CRYPT_RC4_MODE_MCRYPT); break; default: @@ -323,24 +311,6 @@ class Crypt_RC4 { { } - /** - * Sets MCrypt parameters. (optional) - * - * If MCrypt is being used, empty strings will be used, unless otherwise specified. - * - * @link http://php.net/function.mcrypt-module-open#function.mcrypt-module-open - * @access public - * @param optional Integer $algorithm_directory - * @param optional Integer $mode_directory - */ - function setMCrypt($algorithm_directory = '', $mode_directory = '') - { - if ( CRYPT_RC4_MODE == CRYPT_RC4_MODE_MCRYPT ) { - $this->mcrypt = array($algorithm_directory, $mode_directory); - $this->_closeMCrypt(); - } - } - /** * Encrypts a message. * diff --git a/phpseclib/Crypt/TripleDES.php b/phpseclib/Crypt/TripleDES.php index adb2a309..9f4757ec 100644 --- a/phpseclib/Crypt/TripleDES.php +++ b/phpseclib/Crypt/TripleDES.php @@ -248,10 +248,7 @@ class Crypt_TripleDES { { if ( !defined('CRYPT_DES_MODE') ) { switch (true) { - case extension_loaded('mcrypt'): - // i'd check to see if des was supported, by doing in_array('des', mcrypt_list_algorithms('')), - // but since that can be changed after the object has been created, there doesn't seem to be - // a lot of point... + case extension_loaded('mcrypt') && in_array('tripledes', mcrypt_list_algorithms()): define('CRYPT_DES_MODE', CRYPT_DES_MODE_MCRYPT); break; default: