Bug #67707 [Opn->Csd]: IV not needed for ECB encryption mode. but it return an warning

From: Date: Tue, 10 Jan 2017 22:45:18 +0000
Subject: Bug #67707 [Opn->Csd]: IV not needed for ECB encryption mode. but it return an warning
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206480@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67707&edit=1 ID: 67707 Updated by: nikic@php.net Reported by: nirajtiwary at gmail dot com Summary: IV not needed for ECB encryption mode. but it return an warning -Status: Open +Status: Closed Type: Bug Package: mcrypt related Operating System: Windows 7 PHP Version: 5.5.15 Block user comment: N Private report: N New Comment: Automatic comment on behalf of php@mcq8.be Revision: http://git.php.net/?p=php-src.git;a=commit;h=d9cd2876d97d79029a980e7c89aa441fd46a4bf2 Log: Fixed bug #67707 IV not needed for ECB encryption mode, but it returns a warning Previous Comments: ------------------------------------------------------------------------ [2014-07-29 10:05:24] nirajtiwary at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=67707&edit=1

« previous php.bugs (#206480) next »