From a8d07e3dcb4678ab9261cc16bf030b63e4b7346b Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 29 Dec 2018 23:21:18 -0600 Subject: [PATCH] SymmetricKey: make $cipher_name_openssl_ecb static --- phpseclib/Crypt/Blowfish.php | 2 +- phpseclib/Crypt/Common/SymmetricKey.php | 10 +++++----- phpseclib/Crypt/DES.php | 2 +- phpseclib/Crypt/RC2.php | 2 +- phpseclib/Crypt/Rijndael.php | 2 +- phpseclib/Crypt/TripleDES.php | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index 08c942ac..cc4fec21 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -339,7 +339,7 @@ class Blowfish extends BlockCipher if ($this->key_length < 16) { return false; } - $this->cipher_name_openssl_ecb = 'bf-ecb'; + self::$cipher_name_openssl_ecb = 'bf-ecb'; $this->cipher_name_openssl = 'bf-' . $this->openssl_translate_mode(); } diff --git a/phpseclib/Crypt/Common/SymmetricKey.php b/phpseclib/Crypt/Common/SymmetricKey.php index dd0a1372..34aeacfe 100644 --- a/phpseclib/Crypt/Common/SymmetricKey.php +++ b/phpseclib/Crypt/Common/SymmetricKey.php @@ -427,7 +427,7 @@ abstract class SymmetricKey * @var string * @access private */ - protected $cipher_name_openssl_ecb; + protected static $cipher_name_openssl_ecb; /** * The default salt used by setPassword() @@ -1805,7 +1805,7 @@ abstract class SymmetricKey for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { $block = substr($plaintext, $i, $block_size); if (strlen($block) > strlen($buffer['ciphertext'])) { - $buffer['ciphertext'].= openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING); + $buffer['ciphertext'].= openssl_encrypt($xor, static::$cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING); } Strings::increment_str($xor); $otp = Strings::shift($buffer['ciphertext'], $block_size); @@ -1814,7 +1814,7 @@ abstract class SymmetricKey } else { for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { $block = substr($plaintext, $i, $block_size); - $otp = openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING); + $otp = openssl_encrypt($xor, static::$cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING); Strings::increment_str($xor); $ciphertext.= $block ^ $otp; } @@ -1856,7 +1856,7 @@ abstract class SymmetricKey } } if ($this->continuousBuffer) { - $encryptIV = openssl_decrypt($encryptIV, $this->cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING); + $encryptIV = openssl_decrypt($encryptIV, static::$cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING); if ($overflow) { Strings::increment_str($encryptIV); } @@ -2083,7 +2083,7 @@ abstract class SymmetricKey // that don't we'll emulate it switch ($this->mode) { case self::MODE_CTR: - if (in_array($this->cipher_name_openssl_ecb, $methods)) { + if (in_array(static::$cipher_name_openssl_ecb, $methods)) { $this->openssl_emulate_ctr = true; return true; } diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index 665dc2e0..fc22d462 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -610,7 +610,7 @@ class DES extends BlockCipher { if ($this->key_length_max == 8) { if ($engine == self::ENGINE_OPENSSL) { - $this->cipher_name_openssl_ecb = 'des-ecb'; + self::$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 cdaa4ec7..f08dd525 100644 --- a/phpseclib/Crypt/RC2.php +++ b/phpseclib/Crypt/RC2.php @@ -294,7 +294,7 @@ class RC2 extends BlockCipher if ($this->current_key_length != 128 || strlen($this->orig_key) < 16) { return false; } - $this->cipher_name_openssl_ecb = 'rc2-ecb'; + self::$cipher_name_openssl_ecb = 'rc2-ecb'; $this->cipher_name_openssl = 'rc2-' . $this->openssl_translate_mode(); } diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index ffc9cdae..37c6472f 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -283,7 +283,7 @@ class Rijndael extends BlockCipher if ($this->block_size != 16) { return false; } - $this->cipher_name_openssl_ecb = 'aes-' . ($this->key_length << 3) . '-ecb'; + self::$cipher_name_openssl_ecb = 'aes-' . ($this->key_length << 3) . '-ecb'; $this->cipher_name_openssl = 'aes-' . ($this->key_length << 3) . '-' . $this->openssl_translate_mode(); break; case self::ENGINE_MCRYPT: diff --git a/phpseclib/Crypt/TripleDES.php b/phpseclib/Crypt/TripleDES.php index 3c665f29..f692c06a 100644 --- a/phpseclib/Crypt/TripleDES.php +++ b/phpseclib/Crypt/TripleDES.php @@ -184,7 +184,7 @@ class TripleDES extends DES protected function isValidEngineHelper($engine) { if ($engine == self::ENGINE_OPENSSL) { - $this->cipher_name_openssl_ecb = 'des-ede3'; + self::$cipher_name_openssl_ecb = 'des-ede3'; $mode = $this->openssl_translate_mode(); $this->cipher_name_openssl = $mode == 'ecb' ? 'des-ede3' : 'des-ede3-' . $mode; }