Merge branch '3.0'

This commit is contained in:
terrafrost 2021-04-14 05:33:02 -05:00
commit a3f8999eac
6 changed files with 10 additions and 10 deletions

View File

@ -339,7 +339,7 @@ class Blowfish extends BlockCipher
if ($this->key_length < 16) {
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();
}

View File

@ -475,7 +475,7 @@ abstract class SymmetricKey
* @var string
* @access private
*/
protected static $cipher_name_openssl_ecb;
protected $cipher_name_openssl_ecb;
/**
* The default salt used by setPassword()
@ -1915,7 +1915,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, 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);
$otp = Strings::shift($buffer['ciphertext'], $block_size);
@ -1924,7 +1924,7 @@ abstract class SymmetricKey
} else {
for ($i = 0; $i < strlen($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);
$ciphertext.= $block ^ $otp;
}
@ -1966,7 +1966,7 @@ abstract class SymmetricKey
}
}
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) {
Strings::increment_str($encryptIV);
}
@ -2191,7 +2191,7 @@ abstract class SymmetricKey
// that don't we'll emulate it
switch ($this->mode) {
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;
return true;
}

View File

@ -613,7 +613,7 @@ class DES extends BlockCipher
{
if ($this->key_length_max == 8) {
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();
}
}

View File

@ -298,7 +298,7 @@ class RC2 extends BlockCipher
if ($this->current_key_length != 128 || strlen($this->orig_key) < 16) {
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();
}

View File

@ -308,7 +308,7 @@ class Rijndael extends BlockCipher
if ($this->block_size != 16) {
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();
break;
case self::ENGINE_MCRYPT:

View File

@ -187,7 +187,7 @@ class TripleDES extends DES
protected function isValidEngineHelper($engine)
{
if ($engine == self::ENGINE_OPENSSL) {
self::$cipher_name_openssl_ecb = 'des-ede3';
$this->cipher_name_openssl_ecb = 'des-ede3';
$mode = $this->openssl_translate_mode();
$this->cipher_name_openssl = $mode == 'ecb' ? 'des-ede3' : 'des-ede3-' . $mode;
}