Bug #67287 [NEW]: Warning: mcrypt_encrypt(): Only keys of size 24 supported
| From: | mengxiangbaidu at qq dot com | Date: | Thu, 15 May 2014 14:50:42 +0000 |
| Subject: | Bug #67287 [NEW]: Warning: mcrypt_encrypt(): Only keys of size 24 supported | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-185830@lists.php.net to get a copy of this message | ||
From: mengxiangbaidu at qq dot com
Operating system: windows
PHP version: 5.6.0beta2
Package: mcrypt related
Bug Type: Bug
Bug description:Warning: mcrypt_encrypt(): Only keys of size 24 supported
Description:
------------
php version <= 5.5.12
string(6) "zxcvbn"
Warning: mcrypt_encrypt(): Key of size 32 not supported by this
algorithm. in /test.php on line 9
Warning: mcrypt_decrypt(): Key of size 32 not supported by this
algorithm. in /test.php on line 17
string(0) "zxcvbn"
php version >= 5.6
string(6) "zxcvbn"
Warning: mcrypt_encrypt(): Key of size 32 not supported by this
algorithm. Only keys of size 24 supported in /test.php on line 9
Warning: mcrypt_decrypt(): Key of size 32 not supported by this
algorithm. Only keys of size 24 supported in /test.php on line 17
string(0) ""
================
I know this warning is good thing ã If you are upgrading php 5.5 to
5.6 , the php program does not work ãThis maybe a serious
problemã
Test script:
---------------
<?php
function encrypt($data, $key) {
$block = mcrypt_get_block_size(MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB);
$pad = $block - (strlen($data) % $block);
$data .= str_repeat(chr($pad), $pad);
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_TRIPLEDES,
MCRYPT_MODE_ECB), MCRYPT_RAND);
$encrypted = mcrypt_encrypt(MCRYPT_TRIPLEDES, $key, $data,
MCRYPT_MODE_ECB, $iv);
return $encrypted;
}
function decrypt($data, $key) {
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_TRIPLEDES,
MCRYPT_MODE_ECB), MCRYPT_RAND);
$data = mcrypt_decrypt(MCRYPT_TRIPLEDES, $key, $data,
MCRYPT_MODE_ECB, $iv);
$block = mcrypt_get_block_size(MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB);
$pad = ord($data[($len = strlen($data)) - 1]);
$decrypted = substr($data, 0, strlen($data) - $pad);
return rtrim($decrypted);
}
$key = md5('asdfgh');
$original_data = 'zxcvbn';
var_dump($original_data);
$data = encrypt($original_data, $key);
$data = base64_encode($data);
$data = base64_decode($data);
$data = decrypt($data, $key);
var_dump($data);
Expected result:
----------------
string(6) "zxcvbn"
Warning: mcrypt_encrypt(): Key of size 32 not supported by this
algorithm. Only keys of size 24 supported in /test.php on line 9
Warning: mcrypt_decrypt(): Key of size 32 not supported by this
algorithm. Only keys of size 24 supported in /test.php on line 17
string(0) "zxcvbn"
Actual result:
--------------
string(6) "zxcvbn"
Warning: mcrypt_encrypt(): Key of size 32 not supported by this
algorithm. Only keys of size 24 supported in /test.php on line 9
Warning: mcrypt_decrypt(): Key of size 32 not supported by this
algorithm. Only keys of size 24 supported in /test.php on line 17
string(0) ""
--
Edit bug report at https://bugs.php.net/bug.php?id=67287&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67287&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67287&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67287&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67287&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67287&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67287&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67287&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67287&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67287&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67287&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67287&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67287&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67287&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67287&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67287&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67287&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67287&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67287&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67287&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67287&r=mysqlcfg