#22316 [Asn->Csd]: Crypt_RC4 destroys its sbox.

From: Date: Sun, 27 Jul 2003 10:46:56 +0000
Subject: #22316 [Asn->Csd]: Crypt_RC4 destroys its sbox.
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-18777@lists.php.net to get a copy of this message
ID: 22316 Updated by: arnaud@php.net Reported By: mike at graftonhall dot co dot nz -Status: Assigned +Status: Closed Bug Type: PEAR related Operating System: Windows 2000 PHP Version: 4CVS-2003-02-19 (stable) Assigned To: zyprexia New Comment: This bug has been fixed in CVS. In case this was a PHP problem, snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites in short time. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2003-02-19 22:52:07] mike at graftonhall dot co dot nz The Crypt_RC4::crypt() routine (and Crypt_RC4::decrypt()) destroys the sbox created in Crypt_RC4::key() causes the example code to no work. So the code in the comment: Usage: $key = "pear"; $message = "PEAR rulez!"; $rc4 = new RC4; $rc4->key($key); echo "Original message: $message <br>\n"; $rc4->crypt($message); echo "Encrypted message: $message <br>\n"; $rc4->decrypt($message); echo "Decrypted message: $message <br>\n"; Does not work. For two reasons, first the class is nor Crypt_RC4 and second after crypt() has been called the sbox has been modified and so neither crypt nor decrypt will work correctly. The example code should currently read: Usage: $key = "pear"; $message = "PEAR rulez!"; $rc4 = new Crypt_RC4; $rc4->key($key); echo "Original message: $message <br>\n"; $rc4->crypt($message); echo "Encrypted message: $message <br>\n"; $rc4->key($key); $rc4->decrypt($message); echo "Decrypted message: $message <br>\n"; Note the extra key() call. - Mike :-) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22316&edit=1

« previous php.pear.dev (#18777) next »