note 51067 deleted from ref.mcrypt by danbrown
| From: | danbrown@php.net | Date: | Mon, 13 Dec 2010 16:26:46 +0000 |
| Subject: | note 51067 deleted from ref.mcrypt by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-174866@lists.php.net to get a copy of this message | ||
Note Submitter: davisd50 at yahoo dot com
----
I was creating a cross-platform (unix + windows) application and ran into some issues with different
versions of mcrypt (2.4.x vs 2.5.x) not working with Windows. After further investigation, I found
the following:
Libmcrypt 2.5.7 is not usable with PHP 4.x.
The reason is a very Windows-specific issue. DLLs are Windows' way of providing shared code -
things get loaded once into RAM and are guaranteed identical across all applications that use them.
When an application references a routine/function in a DLL, it may do so either by function name or
by reference number. Referring to a routine by name is considered slow by some people and does slow
down the startup of applications that use large numbers of routines in DLLs (applications such as
PHP). Referring to a routine by reference number is very quick but breaks if a new DLL version
changes the reference number assignments for its routines.
Libmcrypt 2.5.6 & 7's DLLs do not have the same reference number assignments as old
Libmcrypt.dll files did. Specifically, function 148 (mdecrypt_generic) has been moved in 2.5.6/7 to
number 149 due to the addition of the mcrypt_mutex_register function which moved everything above it
alphebetically up a reference number. PHP's php_mcrypt.dll, which provides the PHP language
bindings to the low-level Libmcrypt.dll, refers to Libmcrypt.dll's functions by number instead
of name. PHP 4.x's php_mcrypt.dll refers to function 148 while PHP 5.0's php_mcrypt.dll
refers to function 149 and notes that PHP 5.0 under Windows can only work with Libmcrypt 2.5.6 and
higher (because function 149 in old Libmcrypt is actually the Panama encryption algorithm, not the
expected mcrypt_generic routine).
So, unless you can find a PHP 4.x php_mcrypt.dll that has been compiled for Libmcrypt 2.5.6 and
higher, PHP 4.x won't be able to decrypt data with Libmcrypt 2.5.7 under Windows.