mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-28 12:10:59 +00:00
SymmetricKey: make $cipher_name_openssl_ecb static
This commit is contained in:
parent
49be6e5529
commit
a8d07e3dcb
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user