mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-13 18:02:58 +00:00
fixed corrupted decrypt() in CTR mode
$buffer['encrypted'] (which is always empty) should be $buffer['ciphertext'] or buffered stream will get corrupt... Example: define('CRYPT_AES_MODE',CRYPT_AES_MODE_INTERNAL);//in MODE_MCRYPT all is fine $aes = new Crypt_AES(CRYPT_AES_MODE_CTR); $aes->setKey(':-8'); $aes->enableContinuousBuffer(); $plaintext = ':-):-):-):-):-):-)'; for($i=0; $i<strlen($plaintext); $i++) { echo $aes->Decrypt($aes->Encrypt($plaintext[$i])); } Output: :-):-):-):-):-):-( Expected: :-):-):-):-):-):-) After Bugfix, output is: :-):-):-):-):-):-)
This commit is contained in:
parent
61ad80fd64
commit
359e38b4d4
@ -879,7 +879,7 @@ class Crypt_Rijndael {
|
|||||||
if ($this->continuousBuffer) {
|
if ($this->continuousBuffer) {
|
||||||
$this->decryptIV = $xor;
|
$this->decryptIV = $xor;
|
||||||
if ($start = strlen($ciphertext) % $block_size) {
|
if ($start = strlen($ciphertext) % $block_size) {
|
||||||
$buffer['ciphertext'] = substr($key, $start) . $buffer['encrypted'];
|
$buffer['ciphertext'] = substr($key, $start) . $buffer['ciphertext'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1493,4 +1493,4 @@ class Crypt_Rijndael {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// vim: ts=4:sw=4:et:
|
// vim: ts=4:sw=4:et:
|
||||||
// vim6: fdl=1:
|
// vim6: fdl=1:
|
||||||
|
Loading…
Reference in New Issue
Block a user