phpseclib/phpseclib — pull request #94 by petrich (2013-04-25 07:47:54+00:00)
Title: DES/3DES performance update

Hi Terra and Patrick... and all :-)

based on Patrick's performance-DES-Commit yesterday, here comes the inline-en/decrypt patch (same as we did it for Rijndael/AES)
which will give additional ~25% performance for DES and 3DES

Benchmarkscript:
```php
define('CRYPT_DES_MODE',CRYPT_DES_MODE_INTERNAL);

$s=microtime(true);
$DES = new Crypt_DES();
$DES->decrypt($DES->encrypt(str_repeat('a',1024*1024)));
echo "[DES] Time used de/encrypting 1MB: ". round(microtime(true) - $s, 2)."\n";

$s=microtime(true);
$TribleDES = new Crypt_TripleDES();
$TribleDES->setKey('123456789012345678901234');
$TribleDES->decrypt($TribleDES->encrypt(str_repeat('a',1024*1024)));
echo "[3DES] Time used de/encrypting 1MB: ". round(microtime(true) - $s, 2)."\n";
```

Results for DES and 3DES on my dev-Linux-Kisterl (php5.4.9 / 32bit):

```
Current DES/3DES:
[DES] Time used de/encrypting 1MB: 9.91
[3DES] Time used de/encrypting 1MB: 29.24

New DES/3DES:
[DES] Time used de/encrypting 1MB: 7.43
[3DES] Time used de/encrypting 1MB: 23.16
```

I had to restructure some class vars on DES.php and TribleDES.php and of course implementing the inline en/decrypting code.

I think the diffed-code is self-describing (hopefully :-) ) ... i also made some comments.

The patch is 100% compatible with the phpseclib suite.

Also strong testet on Win and Linux, 32 and 64bit, php4 and 5.0/5.1/5.2/5.3/5.4
All works fine.

Maybe you can test it in your dev-environment also.

If you like it... it's ready to merge from my side.

Greetings :-)