#27062 [Asn->Opn]: mdecrypt_generic() doesn't decrypt anything

From: Date: Tue, 27 Jan 2004 21:16:17 +0000
Subject: #27062 [Asn->Opn]: mdecrypt_generic() doesn't decrypt anything
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-54004@lists.php.net to get a copy of this message
 ID:               27062
 Updated by:       derick@php.net
 Reported By:      yu at csh dot dp dot ua
-Status:           Assigned
+Status:           Open
 Bug Type:         mcrypt related
 Operating System: Windows 2000
 PHP Version:      4.3.4
 Assigned To:      derick
 New Comment:

But there is no ZTS specific code at all; and I just tested, it works
fine on Linux with ZTS enabled.


Previous Comments:
------------------------------------------------------------------------

[2004-01-27 15:56:23] sniper@php.net

It's ZTS issue, I bet. Try a bit harder, Derick..


------------------------------------------------------------------------

[2004-01-27 15:47:42] derick@php.net

Works fine for me on Linux.

------------------------------------------------------------------------

[2004-01-27 13:16:58] yu at csh dot dp dot ua

Description:
------------
Server is localhost.
Function mdecrypt_generic() doesn't decrypt anything.
Instead it returns value of the encrypted string without changing.
Crypt-library loaded from
http://ftp.emini.dk/pub/php/win32/mcrypt/libmcrypt.dll
, as specified
in the php_manual for mcrypt functions.

Same problem reports other users:
http://bugs.php.net/bug.php?id=3165&edit=2
- Bug #3165: encrypt/decrypt
not a function?
http://www.forbiddenweb.org/viewtopic.php?t=4556

here is another link to crypt-libraries, that point as functional:
http://ftp.proventum.net/pub/php/win32/misc/mcrypt/

, but i don't check it functionality.


Additionaly mcrypt_create_iv() produces same iv for every time script
is runing. But this not problem when, for example, 
<? 
...
$iv=substr(pack('h*',sha1(uniqid(rand())), 0,
mcrypt_enc_get_iv_size($td)); 
...
?>


Reproduce code:
---------------
<?php 
#Example to mcrypt_module_open() from php_manual_ru.html
#almost without changes
srand();
$td = mcrypt_module_open('rijndael-256', '', 'cbc', '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
$ks = mcrypt_enc_get_key_size($td);
$key = substr(md5('very secret key'), 0, $ks);
mcrypt_generic_init($td, $key, $iv);
$encrypted = mcrypt_generic($td, 'This is my data');
mcrypt_generic_deinit($td);
mcrypt_generic_init($td, $key, $iv);
$decrypted = mdecrypt_generic($td, $encrypted);
mcrypt_generic_deinit($td);    
mcrypt_module_close($td);   
echo trim($decrypted) . "\n";?>

Expected result:
----------------
"This is my data"

Actual result:
--------------
$encrypted value


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=27062&edit=1


Thread (15 messages)

« previous php.bugs (#54004) next »