php.net |  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
 [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:
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 :-)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-27 05:46 UTC] arnaud@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC