From 8f31e59efaaa0de31449d97e4470cb5d3bc09c81 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 20 Mar 2021 06:00:23 -0500 Subject: [PATCH 1/2] ... --- phpseclib/Crypt/Common/SymmetricKey.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpseclib/Crypt/Common/SymmetricKey.php b/phpseclib/Crypt/Common/SymmetricKey.php index c56d44b3..7281d00f 100644 --- a/phpseclib/Crypt/Common/SymmetricKey.php +++ b/phpseclib/Crypt/Common/SymmetricKey.php @@ -2447,6 +2447,8 @@ abstract class SymmetricKey self::MODE_STREAM => MCRYPT_MODE_STREAM, ]; + set_error_handler(function() {}); + $this->demcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); $this->enmcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); @@ -2456,6 +2458,8 @@ abstract class SymmetricKey if ($this->mode == self::MODE_CFB) { $this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, ''); } + + restore_error_handler(); } // else should mcrypt_generic_deinit be called? if ($this->mode == self::MODE_CFB) { From 78364b0127ae773e220ddd23d2f99ff6c35faee5 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 20 Mar 2021 06:09:38 -0500 Subject: [PATCH 2/2] ... --- phpseclib/Crypt/Common/SymmetricKey.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/phpseclib/Crypt/Common/SymmetricKey.php b/phpseclib/Crypt/Common/SymmetricKey.php index 7281d00f..605458e0 100644 --- a/phpseclib/Crypt/Common/SymmetricKey.php +++ b/phpseclib/Crypt/Common/SymmetricKey.php @@ -2436,6 +2436,8 @@ abstract class SymmetricKey case self::ENGINE_MCRYPT: $this->enchanged = $this->dechanged = true; + set_error_handler(function() {}); + if (!isset($this->enmcrypt)) { static $mcrypt_modes = [ self::MODE_CTR => 'ctr', @@ -2447,8 +2449,6 @@ abstract class SymmetricKey self::MODE_STREAM => MCRYPT_MODE_STREAM, ]; - set_error_handler(function() {}); - $this->demcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); $this->enmcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); @@ -2459,12 +2459,14 @@ abstract class SymmetricKey $this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, ''); } - restore_error_handler(); } // else should mcrypt_generic_deinit be called? if ($this->mode == self::MODE_CFB) { mcrypt_generic_init($this->ecb, $this->key, str_repeat("\0", $this->block_size)); } + + restore_error_handler(); + break; case self::ENGINE_INTERNAL: $this->setupKey();