#37595 [Bgs->Csd]: last part of the string is lost at decoding
| From: | tony2001@php.net | Date: | Wed, 31 May 2006 12:08:25 +0000 |
| Subject: | #37595 [Bgs->Csd]: last part of the string is lost at decoding | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-97855@lists.php.net to get a copy of this message | ||
ID: 37595
Updated by: tony2001@php.net
Reported By: coditza at cluj dot astral dot ro
-Status: Bogus
+Status: Closed
Bug Type: mcrypt related
Operating System: windows
PHP Version: 4.4.2
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.
Thank you for your resistance.
Previous Comments:
------------------------------------------------------------------------
[2006-05-31 08:43:58] tony2001@php.net
Please, fix your code, there is nothing wrong neither with mcrypt
library nor with PHP.
------------------------------------------------------------------------
[2006-05-31 07:44:46] coditza at cluj dot astral dot ro
Indeed, your sugestion fixed the thing, but that's just a work around.
I added some debuing bits and here are 2 outputs:
string: 12345678qwertyui12345678g
0) Encoding: 12345678 - 7e0dc5b2ff23aca1
1) Encoding: qwertyui - eb3b6b54025c6347
2) Encoding: 12345678 - f258e8a6ab3003af
3) Encoding: g - 20d274568051c4e6
4) Encoding: - 43f92ddf945e42fc
string lenght is 25, ceil(25/8) = 4, the for loop you sugested is
"processing" an aditional empty part of the string.
Again, this is a workaround, not a fix/user error. Please fix the
library or point out in the docs that for a succesfull crypt you need
to use this thinghy.
Thanks
------------------------------------------------------------------------
[2006-05-30 23:35:29] tony2001@php.net
Change
for($i=0;$i<$max;$i++) {
to
for($i=0;$i<=$max;$i++) {
Not PHP problem, just a user error.
------------------------------------------------------------------------
[2006-05-29 13:07:08] coditza at cluj dot astral dot ro
The example is for freebsd 6.0 actually, but the beavior is the same
both on windows (with php4) and on freebsd (with php5)
------------------------------------------------------------------------
[2006-05-25 23:49:00] coditza at cluj dot astral dot ro
Description:
------------
If the lenght of the encoded string is a multiple of chipher block
size, the last blocksize part of the chipher is lost at decoding.
Reproduce code:
---------------
Use the script at: http://www.coada.net/develop/crypt.phps to
produce
an encoded file, then, from shell:
openssl bf-cbc -in out.dat -out out.dec -K
000102030405060708090a0b0c0d0e0f -iv 0102030405060708 -d
and
cat out.dec
Expected result:
----------------
coditza@keep$
12345678qwertyui12345678coditza@keep$
Actual result:
--------------
bad decrypt
31976:error:06065064:digital envelope routines:EVP_DecryptFinal:bad
decrypt:/usr/src/secure/lib/libcrypto/../../../crypto/openssl/crypto/evp/evp_enc.c:450:
coditza@keep$ cat out.dec
12345678qwertyuicoditza@keep$
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37595&edit=1