Bug #17062 Updated: possible bad padding

From: Date: Tue, 07 May 2002 07:04:34 +0000
Subject: Bug #17062 Updated: possible bad padding
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-7121@lists.php.net to get a copy of this message
ID: 17062 Updated by: derick@php.net Reported By: veins@skreel.org -Status: Open +Status: Closed Bug Type: mcrypt related Operating System: Unix PHP Version: 4.2.0 New Comment: It's indeed intended, as you might want to encrypt/decrypt a range of \0's.. PHP should not trim the result. As most encrypt algorithms do not store the length of the original string in the output, there is no way for PHP to tell where the decrypted string should end. A workaround here would be to use trim() (www.php.net/trim) on the decrypted string to remove the trailing \0's. Derick Previous Comments: ------------------------------------------------------------------------ [2002-05-06 23:49:27] veins@skreel.org I noticed something quite strange when using the mcrypt library to encrypt data. say i would encrypt $data in mode ECB: $l = mcrypt_encrypt(MCRYPT_BLOWFISH, $key, $data, MCRYPT_MODE_ECB, $iv); then decrypt it: $l = mcrypt_decrypt(MCRYPT_BLOWFISH, $key, $data, MCRYPT_MODE_ECB, $iv); It seems like the padding prevents me from using the variable correctly in some conditions. As explained in the documentation, the padding is made of '\0' and in the following example: <? exec("echo.sh $l foobar", $value, $return); exec would actually stop at $l because of the '\0' and not pass the 'foobar' arg. I don't know if this is a known bug or a "supposed" behaviour, but it is surely annoying :) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17062&edit=1

« previous php.bugs (#7121) next »