AES: CFB mode fix

This commit is contained in:
terrafrost 2013-01-10 20:42:38 -06:00
parent 5ce9ad6a42
commit bbd62f6490

View File

@ -412,10 +412,10 @@ class Crypt_AES extends Crypt_Rijndael {
if ($last_pos) { if ($last_pos) {
$plaintext = mdecrypt_generic($this->demcrypt, substr($ciphertext, 0, $last_pos)); $plaintext = mdecrypt_generic($this->demcrypt, substr($ciphertext, 0, $last_pos));
$this->decryptIV = substr($ciphertext, $last_pos - 16, 16); $this->decryptIV = substr($ciphertext, $last_pos - 16, 16);
$this->decryptIV = mcrypt_generic($this->ecb, $this->decryptIV);
} }
if (strlen($ciphertext) & 0xF) { if (strlen($ciphertext) & 0xF) {
$this->decryptIV = mcrypt_generic($this->ecb, $this->decryptIV);
$buffer = substr($ciphertext, $last_pos); $buffer = substr($ciphertext, $last_pos);
$plaintext.= $buffer ^ $this->decryptIV; $plaintext.= $buffer ^ $this->decryptIV;
} }