#46010 [Opn->Csd]: warnings incorrectly generated for iv in ecb mode
| From: | felipe@php.net | Date: | Sun, 07 Sep 2008 23:10:31 +0000 |
| Subject: | #46010 [Opn->Csd]: warnings incorrectly generated for iv in ecb mode | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-128764@lists.php.net to get a copy of this message | ||
ID: 46010
Updated by: felipe@php.net
Reported By: d_kelsey at uk dot ibm dot com
-Status: Open
+Status: Closed
Bug Type: mcrypt related
Operating System: Windows XP
PHP Version: 5.2.6
New Comment:
This bug has been fixed in CVS.
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/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2008-09-06 15:36:45] d_kelsey at uk dot ibm dot com
Description:
------------
With the functions
mcrypt_encrypt, mcrypt_decrypt with MCRYPT_MODE_ECB and mcrypt_ecb, by
not providing an initial vector or providing one that isn't at the
correct block size results in a warning being generated.
ECB mode never uses the initial vector, so a warning is irrelevant.
Reproduce code:
---------------
<?php
// the same type of results can also be seen with mcrypt_ecb,
mcrypt_decrypt
var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, "key", "data",
MCRYPT_MODE_ECB)));
var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, "key", "data",
MCRYPT_MODE_ECB, "a")));
var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, "key", "data",
MCRYPT_MODE_ECB, "12345678")));
?>
Expected result:
----------------
string(16) "372eeb4a524b8d31"
string(16) "372eeb4a524b8d31"
string(16) "372eeb4a524b8d31"
Actual result:
--------------
Warning: mcrypt_encrypt(): Attempt to use an empty IV, which is NOT
recommend in C:\udata-eclipse\p8\a.phpcode\mcrypt_ecb.php on line 2
string(16) "372eeb4a524b8d31"
Warning: mcrypt_encrypt(): The IV parameter must be as long as the
blocksize in C:\udata-eclipse\p8\a.phpcode\mcrypt_ecb.php on line 3
string(16) "372eeb4a524b8d31"
string(16) "372eeb4a524b8d31"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46010&edit=1