phpseclib/phpseclib — pull request #45 by petrich (2013-01-07 10:21:40+00:00)
Title: Fixed broken CFB and disableContinuousBuffer()

Hi there,
as discussed yesterday, here the fixed for AES:

Fixed: Broken CFB in continuous mode when using CRYPT_AES_MODE_MCRYPT (related to: https://github.com/phpseclib/phpseclib/issues/39 )
Fixed: Multiple calls to enable/disableContinuousBuffer()
Fixed: Some PHP Notice/Warnings about strlen(array())

Example for broken CFB in continuous mode when using CRYPT_AES_MODE_MCRYPT:
```php
ini_set('error_reporting',E_ALL);
define('CRYPT_AES_MODE',CRYPT_AES_MODE_MCRYPT);

$aes = new Crypt_AES(CRYPT_AES_MODE_CFB);
$aes->enableContinuousBuffer();
$ciphertext = $aes->encrypt('1234567890123456').$aes->encrypt('7');

$aes = new Crypt_AES(CRYPT_AES_MODE_CFB);
$aes->setKey('1');
echo bin2hex($ciphertext)."\n";
echo bin2hex($aes->encrypt('12345678901234567'));
```

Output:
57db78e0dabc1b03b17ccb6bf9001e1851
57db78e0dabc1b03b17ccb6bf9001e18b2

Excpected:
57db78e0dabc1b03b17ccb6bf9001e18b2
57db78e0dabc1b03b17ccb6bf9001e18b2

Output after bugfix:
57db78e0dabc1b03b17ccb6bf9001e18b2
57db78e0dabc1b03b17ccb6bf9001e18b2

...
And the other issue regarding broken multiple calls to enable/disableContinuousBuffer() when using CRYPT_AES_MODE_MCRYPT :
```php
ini_set('error_reporting',E_ALL);
// ini_set('error_reporting',E_ALL & ~E_NOTICE);
define('CRYPT_AES_MODE',CRYPT_AES_MODE_MCRYPT);
$aes = new Crypt_AES(CRYPT_AES_MODE_OFB); // or CRYPT_AES_MODE_CTR
$aes->enableContinuousBuffer();
$aes->Encrypt('xx');
$aes->disableContinuousBuffer();
echo $aes->Decrypt($aes->Encrypt('xx'));
```

Output:
UE

Excpected:
xx

Output after bugfix:
xx

...
Can you confirm/check the bug(fixe)s?

I think after this, AES and Rijndael should be fine and we can goto DES/3DES.