DES: Fix memory leak in OFB mode

This commit is contained in:
terrafrost 2013-03-03 11:30:03 -06:00
parent bf3ca6312e
commit 15817a416e

View File

@ -656,8 +656,10 @@ class Crypt_DES {
$xor = $this->encryptIV;
if (strlen($buffer['xor'])) {
for ($i = 0; $i < strlen($plaintext); $i+=8) {
$xor = $this->_processBlock($xor, CRYPT_DES_ENCRYPT);
$buffer['xor'].= $xor;
if (strlen($block) > strlen($buffer['xor'])) {
$xor = $this->_processBlock($xor, CRYPT_DES_ENCRYPT);
$buffer['xor'].= $xor;
}
$key = $this->_string_shift($buffer['xor'], 8);
$ciphertext.= substr($plaintext, $i, 8) ^ $key;
}
@ -843,8 +845,10 @@ class Crypt_DES {
$xor = $this->decryptIV;
if (strlen($buffer['xor'])) {
for ($i = 0; $i < strlen($ciphertext); $i+=8) {
$xor = $this->_processBlock($xor, CRYPT_DES_ENCRYPT);
$buffer['xor'].= $xor;
if (strlen($block) > strlen($buffer['xor'])) {
$xor = $this->_processBlock($xor, CRYPT_DES_ENCRYPT);
$buffer['xor'].= $xor;
}
$key = $this->_string_shift($buffer['xor'], 8);
$plaintext.= substr($ciphertext, $i, 8) ^ $key;
}