Bug #67286 [Com]: Warning: mcrypt_encrypt(): Only keys of size 24 supported

From: Date: Wed, 18 May 2016 08:31:42 +0000
Subject: Bug #67286 [Com]: Warning: mcrypt_encrypt(): Only keys of size 24 supported
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201173@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67286&edit=1

 ID:                 67286
 Comment by:         wcode404 at gmail dot com
 Reported by:        mengxiangbaidu at qq dot com
 Summary:            Warning: mcrypt_encrypt():  Only keys of size 24
                     supported
 Status:             Wont fix
 Type:               Bug
 Package:            mcrypt related
 Operating System:   windows
 PHP Version:        5.6.0beta2
 Block user comment: N
 Private report:     N

 New Comment:

This bug is still relevant. In my project, encryption is used to communicate with external
applications and i can not change the encryption key is in them.


Previous Comments:
------------------------------------------------------------------------
[2014-10-15 19:11:31] gm dot outside+php at gmail dot com

Related To: Bug #68238

------------------------------------------------------------------------
[2014-10-15 18:36:06] gm dot outside+php at gmail dot com

I agree, something fishy is going on with that code.  I recently filed another bug report (bug
#68238), it looks like the source of the bug is the same.  However, @nikic was quick enough there to
close it as "not a bug", but truth to be told all applications which rely on the mcrypt
extension are broken with PHP 5.6+ now. :(

------------------------------------------------------------------------
[2014-10-15 18:30:10] gm dot outside+php at gmail dot com

Related To: Bug #68238

------------------------------------------------------------------------
[2014-09-23 22:51:54] dharkness at gmail dot com

@nikic

I don't know if you noticed (it took a couple of readings for me to spot it), but this bug
isn't about the warning message. The problem is that it produces a different and incorrect
result.

* with 5.5 you get the warning (ok) and the correct decrypted message (good)
* with 5.6 you get the warning (ok) but the *incorrect* decrypted message (bad)

Insecure code should cause a warning but still work correctly where possible.

------------------------------------------------------------------------
[2014-05-15 21:13:52] nikic@php.net

The warning was added to prevent usage of encryption primitives with malformed key data. It's
there to catch code like the one you have provided, where use of incorrect keys compromises the
security of the entire encryption. It won't be going away.

Btw, just so it has been said, the key you are using has several issues:

 * You are using hex output of md5, instead of binary output. Effectively this means that
you're loosing half of the entropy.
 * You are using md5 as a KDF - unless you already pass strong keying material to it, this is by no
means safe - if you need to start off weak keying material, the use of PBKDF2 or similar is
required.
 * I assume that you are not actually passing a 6 character string to md5, but if you do,
that's way too short. E.g. a random base64 string with 6 characters only has 36 bits of
entropy.

Furthermore you're using the insecure ECB block chaining mode.

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=67286


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


Thread (6 messages)

« previous php.bugs (#201173) next »