|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22316 Crypt_RC4 destroys its sbox.
Submitted: 2003-02-19 22:52 UTC Modified: 2003-07-27 05:46 UTC
From: mike at graftonhall dot co dot nz Assigned: zyprexia (profile)
Status: Closed Package: PEAR related
PHP Version: 4CVS-2003-02-19 (stable) OS: Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: mike at graftonhall dot co dot nz
New email:
PHP Version: OS:


 [2003-02-19 22:52 UTC] 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:
$key = "pear";
$message = "PEAR rulez!";

$rc4 = new RC4;
echo "Original message: $message <br>\n";
echo "Encrypted message: $message <br>\n";
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:
$key = "pear";
$message = "PEAR rulez!";

$rc4 = new Crypt_RC4;
echo "Original message: $message <br>\n";
echo "Encrypted message: $message <br>\n";
echo "Decrypted message: $message <br>\n";

Note the extra key() call.

- Mike :-)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-27 05:46 UTC]
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
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 17 08:03:36 2021 UTC