Bug #67707 [NEW]: IV not needed for ECB encryption mode. but it return an warning
| From: | nirajtiwary at gmail dot com | Date: | Tue, 29 Jul 2014 10:05:25 +0000 |
| Subject: | Bug #67707 [NEW]: IV not needed for ECB encryption mode. but it return an warning | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186859@lists.php.net to get a copy of this message | ||
From: nirajtiwary at gmail dot com
Operating system: Windows 7
PHP version: 5.5.15
Package: mcrypt related
Bug Type: Bug
Bug description:IV not needed for ECB encryption mode. but it return an warning
Description:
------------
Warning: mcrypt_generic_init(): Iv size incorrect; supplied length: 0,
needed: 16 in D:\xampp\htdocs\AES_Encryption.php on line 141
but as specified in PHP User manual it says IV is ignored for ECB.
http://php.net/manual/en/function.mcrypt-generic-init.php
on Passing 16 Byte string it gives Fatal Exception.
Fatal error: Uncaught exception 'Exception' with message 'The specified
encryption mode does not use an initialization vector. You should pass
an empty string, zero, FALSE, or NULL.' in
D:\xampp\htdocs\AES_Encryption.php:107 Stack trace: #0
D:\xampp\htdocs\test1.php(11):
AES_Encryption->__construct('123456789012345...', '123456789012345...',
'PKCS7', 'ecb') #1 {main} thrown in D:\xampp\htdocs\AES_Encryption.php
on line 107
I have tried with String zero FALSE and NULL. None works.
Test script:
---------------
<?php
include('padCrypt.php');
include('AES_Encryption.php');
$key = "12345678901234561234567890123456";
$iv = "1234567890123456";
$message = "The quick brown fox jumped over the lazy dog";
//$AES = new AES_Encryption($key, $iv);
$AES = new AES_Encryption($key, '', 'PKCS7', "ecb" );
$encrypted = $AES->encrypt($message);
$decrypted = $AES->decrypt($encrypted);
$base64_encrypted = base64_encode($encrypted);
echo $message;
echo "<BR>";
echo $encrypted;
echo "<BR>";
echo $decrypted;
echo "<BR>";
Expected result:
----------------
The warning should not be shown.
Actual result:
--------------
Encryption is done but it should not raise a warning.
--
Edit bug report at https://bugs.php.net/bug.php?id=67707&edit=1
--