summaryrefslogtreecommitdiff
path: root/ext/mcrypt/tests/bug46010.phpt
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2014-03-01 23:51:03 +0100
committerNikita Popov <nikic@php.net>2014-03-05 15:32:32 +0100
commita861a3a93d89a50ce58e1ab1abef1eb501f97483 (patch)
tree88f2cff036668095d35e3491281406874a1c0fc8 /ext/mcrypt/tests/bug46010.phpt
parent25d801f97ec3f4bcac8977efd50f843eba9b19e1 (diff)
downloadphp-git-a861a3a93d89a50ce58e1ab1abef1eb501f97483.tar.gz
Abort on invalid key size
Previously an incorrectly sized key was either silently padded with NUL bytes or truncated. Especially the silent nature of this behavior makes it extremely easy to use weak encryption. A common mistake - which has also been extensively made in our tests - is to use a password instead of a key. Incorrectly sized keys will now be rejected.
Diffstat (limited to 'ext/mcrypt/tests/bug46010.phpt')
-rw-r--r--ext/mcrypt/tests/bug46010.phpt13
1 files changed, 7 insertions, 6 deletions
diff --git a/ext/mcrypt/tests/bug46010.phpt b/ext/mcrypt/tests/bug46010.phpt
index ddb691e362..1f0fe40a3d 100644
--- a/ext/mcrypt/tests/bug46010.phpt
+++ b/ext/mcrypt/tests/bug46010.phpt
@@ -5,12 +5,13 @@ Bug #46010 (warnings incorrectly generated for iv in ecb mode)
--FILE--
<?php
-var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, "key", "data", MCRYPT_MODE_ECB)));
-var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, "key", "data", MCRYPT_MODE_ECB, "a")));
-var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, "key", "data", MCRYPT_MODE_ECB, "12345678")));
+$key = "012345678901234567890123";
+var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, $key, "data", MCRYPT_MODE_ECB)));
+var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, $key, "data", MCRYPT_MODE_ECB, "a")));
+var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, $key, "data", MCRYPT_MODE_ECB, "12345678")));
?>
--EXPECTF--
-string(16) "372eeb4a524b8d31"
-string(16) "372eeb4a524b8d31"
-string(16) "372eeb4a524b8d31"
+string(16) "f7a2ce11d4002294"
+string(16) "f7a2ce11d4002294"
+string(16) "f7a2ce11d4002294"