mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-02-04 12:58:28 +00:00
Crypt/Base: more fixes to pre 5.4.0 padding adjustments
This commit is contained in:
parent
d9adb66609
commit
5d0cb1cee9
@ -994,15 +994,14 @@ class Crypt_Base
|
|||||||
break;
|
break;
|
||||||
case CRYPT_MODE_ECB:
|
case CRYPT_MODE_ECB:
|
||||||
if (!defined('OPENSSL_RAW_DATA')) {
|
if (!defined('OPENSSL_RAW_DATA')) {
|
||||||
$padding = str_repeat(chr($this->block_size), $this->block_size);
|
$ciphetext.= openssl_encrypt('', $this->cipher_name_openssl_ecb, $this->key, true);
|
||||||
$ciphetext.= openssl_encrypt($padding, $this->cipher_name_openssl_ecb, $this->key, true);
|
|
||||||
}
|
}
|
||||||
$plaintext = openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options);
|
$plaintext = openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options);
|
||||||
break;
|
break;
|
||||||
case CRYPT_MODE_CBC:
|
case CRYPT_MODE_CBC:
|
||||||
if (!defined('OPENSSL_RAW_DATA')) {
|
if (!defined('OPENSSL_RAW_DATA')) {
|
||||||
$padding = str_repeat(chr($this->block_size), $this->block_size) ^ substr($ciphertext, -$this->block_size);
|
$padding = str_repeat(chr($this->block_size), $this->block_size) ^ substr($ciphertext, -$this->block_size);
|
||||||
$ciphertext.= openssl_encrypt($padding, $this->cipher_name_openssl_ecb, $this->key, true);
|
$ciphertext.= substr(openssl_encrypt($padding, $this->cipher_name_openssl_ecb, $this->key, true), 0, $this->block_size);
|
||||||
}
|
}
|
||||||
$plaintext = openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options, $this->decryptIV);
|
$plaintext = openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options, $this->decryptIV);
|
||||||
if ($this->continuousBuffer) {
|
if ($this->continuousBuffer) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user