mirror of
https://github.com/danog/phpseclib.git
synced 2024-12-13 09:37:37 +01:00
cipher_name_openssl_ecb shouldn't be static because of AES
This commit is contained in:
parent
5b6024b409
commit
03e9060cbb
@ -339,7 +339,7 @@ class Blowfish extends BlockCipher
|
|||||||
if ($this->key_length < 16) {
|
if ($this->key_length < 16) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
self::$cipher_name_openssl_ecb = 'bf-ecb';
|
$this->cipher_name_openssl_ecb = 'bf-ecb';
|
||||||
$this->cipher_name_openssl = 'bf-' . $this->openssl_translate_mode();
|
$this->cipher_name_openssl = 'bf-' . $this->openssl_translate_mode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ abstract class SymmetricKey
|
|||||||
* @var string
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
protected static $cipher_name_openssl_ecb;
|
protected $cipher_name_openssl_ecb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default salt used by setPassword()
|
* The default salt used by setPassword()
|
||||||
@ -1915,7 +1915,7 @@ abstract class SymmetricKey
|
|||||||
for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
|
for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
|
||||||
$block = substr($plaintext, $i, $block_size);
|
$block = substr($plaintext, $i, $block_size);
|
||||||
if (strlen($block) > strlen($buffer['ciphertext'])) {
|
if (strlen($block) > strlen($buffer['ciphertext'])) {
|
||||||
$buffer['ciphertext'].= openssl_encrypt($xor, static::$cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
|
$buffer['ciphertext'].= openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
|
||||||
}
|
}
|
||||||
Strings::increment_str($xor);
|
Strings::increment_str($xor);
|
||||||
$otp = Strings::shift($buffer['ciphertext'], $block_size);
|
$otp = Strings::shift($buffer['ciphertext'], $block_size);
|
||||||
@ -1924,7 +1924,7 @@ abstract class SymmetricKey
|
|||||||
} else {
|
} else {
|
||||||
for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
|
for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
|
||||||
$block = substr($plaintext, $i, $block_size);
|
$block = substr($plaintext, $i, $block_size);
|
||||||
$otp = openssl_encrypt($xor, static::$cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
|
$otp = openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
|
||||||
Strings::increment_str($xor);
|
Strings::increment_str($xor);
|
||||||
$ciphertext.= $block ^ $otp;
|
$ciphertext.= $block ^ $otp;
|
||||||
}
|
}
|
||||||
@ -1966,7 +1966,7 @@ abstract class SymmetricKey
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->continuousBuffer) {
|
if ($this->continuousBuffer) {
|
||||||
$encryptIV = openssl_decrypt($encryptIV, static::$cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
|
$encryptIV = openssl_decrypt($encryptIV, $this->cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
|
||||||
if ($overflow) {
|
if ($overflow) {
|
||||||
Strings::increment_str($encryptIV);
|
Strings::increment_str($encryptIV);
|
||||||
}
|
}
|
||||||
@ -2191,7 +2191,7 @@ abstract class SymmetricKey
|
|||||||
// that don't we'll emulate it
|
// that don't we'll emulate it
|
||||||
switch ($this->mode) {
|
switch ($this->mode) {
|
||||||
case self::MODE_CTR:
|
case self::MODE_CTR:
|
||||||
if (in_array(static::$cipher_name_openssl_ecb, $methods)) {
|
if (in_array($this->cipher_name_openssl_ecb, $methods)) {
|
||||||
$this->openssl_emulate_ctr = true;
|
$this->openssl_emulate_ctr = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -613,7 +613,7 @@ class DES extends BlockCipher
|
|||||||
{
|
{
|
||||||
if ($this->key_length_max == 8) {
|
if ($this->key_length_max == 8) {
|
||||||
if ($engine == self::ENGINE_OPENSSL) {
|
if ($engine == self::ENGINE_OPENSSL) {
|
||||||
self::$cipher_name_openssl_ecb = 'des-ecb';
|
$this->cipher_name_openssl_ecb = 'des-ecb';
|
||||||
$this->cipher_name_openssl = 'des-' . $this->openssl_translate_mode();
|
$this->cipher_name_openssl = 'des-' . $this->openssl_translate_mode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ class RC2 extends BlockCipher
|
|||||||
if ($this->current_key_length != 128 || strlen($this->orig_key) < 16) {
|
if ($this->current_key_length != 128 || strlen($this->orig_key) < 16) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
self::$cipher_name_openssl_ecb = 'rc2-ecb';
|
$this->cipher_name_openssl_ecb = 'rc2-ecb';
|
||||||
$this->cipher_name_openssl = 'rc2-' . $this->openssl_translate_mode();
|
$this->cipher_name_openssl = 'rc2-' . $this->openssl_translate_mode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ class Rijndael extends BlockCipher
|
|||||||
if ($this->block_size != 16) {
|
if ($this->block_size != 16) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
self::$cipher_name_openssl_ecb = 'aes-' . ($this->key_length << 3) . '-ecb';
|
$this->cipher_name_openssl_ecb = 'aes-' . ($this->key_length << 3) . '-ecb';
|
||||||
$this->cipher_name_openssl = 'aes-' . ($this->key_length << 3) . '-' . $this->openssl_translate_mode();
|
$this->cipher_name_openssl = 'aes-' . ($this->key_length << 3) . '-' . $this->openssl_translate_mode();
|
||||||
break;
|
break;
|
||||||
case self::ENGINE_MCRYPT:
|
case self::ENGINE_MCRYPT:
|
||||||
|
@ -187,7 +187,7 @@ class TripleDES extends DES
|
|||||||
protected function isValidEngineHelper($engine)
|
protected function isValidEngineHelper($engine)
|
||||||
{
|
{
|
||||||
if ($engine == self::ENGINE_OPENSSL) {
|
if ($engine == self::ENGINE_OPENSSL) {
|
||||||
self::$cipher_name_openssl_ecb = 'des-ede3';
|
$this->cipher_name_openssl_ecb = 'des-ede3';
|
||||||
$mode = $this->openssl_translate_mode();
|
$mode = $this->openssl_translate_mode();
|
||||||
$this->cipher_name_openssl = $mode == 'ecb' ? 'des-ede3' : 'des-ede3-' . $mode;
|
$this->cipher_name_openssl = $mode == 'ecb' ? 'des-ede3' : 'des-ede3-' . $mode;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user