com php-src: Abort on invalid key size: ext/mcrypt/mcrypt.c ext/mcrypt/tests/bug46010.phpt ext/mcrypt/tests/mcrypt_cbc. phpt
ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt ex t/mcrypt/tests/mcrypt_cbc_variation2.phpt ext/mcrypt/
tests/mcrypt_cbc_variation3.phpt ext/mcrypt/tests/mcr ypt_cbc_variation4.phpt ext/mcrypt/tests/mcrypt_cbc _variation5.phpt
ext/mcrypt/tests/mcrypt_cfb.phpt ext/mcrypt/tests/mcrypt_d
| From: | Nikita Popov | Date: | Wed, 05 Mar 2014 14:32:32 +0000 |
| Subject: | com php-src: Abort on invalid key size: ext/mcrypt/mcrypt.c ext/mcrypt/tests/bug46010.phpt ext/mcrypt/tests/mcrypt_cbc. phpt ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt ex t/mcrypt/tests/mcrypt_cbc_variation2.phpt ext/mcrypt/ tests/mcrypt_cbc_variation3.phpt ext/mcrypt/tests/mcr ypt_cbc_variation4.phpt ext/mcrypt/tests/mcrypt_cbc _variation5.phpt ext/mcrypt/tests/mcrypt_cfb.phpt ext/mcrypt/tests/mcrypt_d |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76346@lists.php.net to get a copy of this message | ||
Commit: a861a3a93d89a50ce58e1ab1abef1eb501f97483
Author: Nikita Popov <nikic@php.net> Sat, 1 Mar 2014 23:51:03 +0100
Parents: 25d801f97ec3f4bcac8977efd50f843eba9b19e1
Branches: PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a861a3a93d89a50ce58e1ab1abef1eb501f97483
Log:
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.
Changed paths:
M ext/mcrypt/mcrypt.c
M ext/mcrypt/tests/bug46010.phpt
M ext/mcrypt/tests/mcrypt_cbc.phpt
M ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt
M ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt
M ext/mcrypt/tests/mcrypt_cbc_variation2.phpt
M ext/mcrypt/tests/mcrypt_cbc_variation3.phpt
M ext/mcrypt/tests/mcrypt_cbc_variation4.phpt
M ext/mcrypt/tests/mcrypt_cbc_variation5.phpt
M ext/mcrypt/tests/mcrypt_cfb.phpt
M ext/mcrypt/tests/mcrypt_decrypt.phpt
M ext/mcrypt/tests/mcrypt_decrypt_3des_cbc.phpt
M ext/mcrypt/tests/mcrypt_decrypt_3des_ecb.phpt
M ext/mcrypt/tests/mcrypt_decrypt_variation2.phpt
M ext/mcrypt/tests/mcrypt_decrypt_variation3.phpt
M ext/mcrypt/tests/mcrypt_decrypt_variation5.phpt
M ext/mcrypt/tests/mcrypt_ecb.phpt
M ext/mcrypt/tests/mcrypt_ecb_3des_decrypt.phpt
M ext/mcrypt/tests/mcrypt_ecb_3des_encrypt.phpt
M ext/mcrypt/tests/mcrypt_ecb_variation2.phpt
M ext/mcrypt/tests/mcrypt_ecb_variation3.phpt
M ext/mcrypt/tests/mcrypt_ecb_variation4.phpt
M ext/mcrypt/tests/mcrypt_ecb_variation5.phpt
M ext/mcrypt/tests/mcrypt_encrypt_3des_cbc.phpt
M ext/mcrypt/tests/mcrypt_encrypt_3des_ecb.phpt
M ext/mcrypt/tests/mcrypt_encrypt_variation2.phpt
M ext/mcrypt/tests/mcrypt_encrypt_variation3.phpt
M ext/mcrypt/tests/mcrypt_encrypt_variation5.phpt
M ext/mcrypt/tests/mcrypt_ofb.phpt
M ext/mcrypt/tests/mcrypt_rijndael128_128BitKey.phpt
M ext/mcrypt/tests/mcrypt_rijndael128_256BitKey.phpt
diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index 889dce3..d3dc5c2 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -1169,7 +1169,7 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons { char *cipher_dir_string; char *module_dir_string; - int block_size, max_key_length, use_key_length, i, count, iv_size; + int block_size, use_key_length, i, count, iv_size; unsigned long int data_size; int *key_length_sizes; char *key_s = NULL, *iv_s; @@ -1184,33 +1184,27 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons RETURN_FALSE; } /* Checking for key-length */ - max_key_length = mcrypt_enc_get_key_size(td); - if (key_len > max_key_length) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Size of key is too large for this algorithm"); - } key_length_sizes = mcrypt_enc_get_supported_key_sizes(td, &count); if (count == 0 && key_length_sizes == NULL) { /* all lengths 1 - k_l_s = OK */ use_key_length = key_len; key_s = emalloc(use_key_length); memset(key_s, 0, use_key_length); memcpy(key_s, key, use_key_length); - } else if (count == 1) { /* only m_k_l = OK */ - key_s = emalloc(key_length_sizes[0]); - memset(key_s, 0, key_length_sizes[0]); - memcpy(key_s, key, MIN(key_len, key_length_sizes[0])); - use_key_length = key_length_sizes[0]; - } else { /* dertermine smallest supported key > length of requested key */ - use_key_length = max_key_length; /* start with max key length */ + } else { for (i = 0; i < count; i++) { - if (key_length_sizes[i] >= key_len && - key_length_sizes[i] < use_key_length) - { - use_key_length = key_length_sizes[i]; + if (key_length_sizes[i] == key_len) { + use_key_length = key_len; + key_s = emalloc(use_key_length); + memcpy(key_s, key, use_key_length); + break; } } - key_s = emalloc(use_key_length); - memset(key_s, 0, use_key_length); - memcpy(key_s, key, MIN(key_len, use_key_length)); + + if (!key_s) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Key of length %d not supported by this algorithm", key_len); + mcrypt_free(key_length_sizes); + RETURN_FALSE; + } } mcrypt_free (key_length_sizes); diff --git a/ext/mcrypt/tests/bug46010.phpt b/ext/mcrypt/tests/bug46010.phpt index ddb691e..1f0fe40 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" diff --git a/ext/mcrypt/tests/mcrypt_cbc.phpt b/ext/mcrypt/tests/mcrypt_cbc.phpt index fb74df9..cf723e3 100644 --- a/ext/mcrypt/tests/mcrypt_cbc.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc.phpt @@ -4,7 +4,7 @@ mcrypt_cbc <?php if (!extension_loaded("mcrypt")) print "skip"; ?> --FILE-- <?php -$key = "FooBar"; +$key = "0123456789012345"; $secret = "PHP Testfest 2008"; $cipher = MCRYPT_RIJNDAEL_128; @@ -17,6 +17,7 @@ echo trim(mcrypt_cbc($cipher, $key, $enc_data, MCRYPT_DECRYPT, $iv)) . "\n"; // a warning must be issued if we don't use a IV on a AES cipher, that usually requires an IV var_dump(mcrypt_cbc($cipher, $key, $enc_data, MCRYPT_DECRYPT)); +?> --EXPECTF-- Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d diff --git a/ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt b/ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt index f65123b..775c153 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt @@ -21,7 +21,7 @@ $cipher = MCRYPT_TRIPLEDES; $data = b"This is the secret message which must be encrypted"; $mode = MCRYPT_DECRYPT; -// tripledes uses keys upto 192 bits (24 bytes) +// tripledes uses keys with exactly 192 bits (24 bytes) $keys = array( b'12345678', b'12345678901234567890', @@ -54,7 +54,7 @@ for ($i = 0; $i < sizeof($keys); $i++) { special_var_dump(mcrypt_cbc($cipher, $keys[$i], base64_decode($data1[$i]), $mode, $iv)); } -$key = b'1234567890123456'; +$key = b'123456789012345678901234'; echo "\n--- testing different iv lengths\n"; for ($i = 0; $i < sizeof($ivs); $i++) { echo "\niv length=".strlen($ivs[$i])."\n"; @@ -74,12 +74,16 @@ function special_var_dump($str) { key length=8 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_cbc(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_cbc(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 @@ -90,8 +94,8 @@ key length=26 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -Warning: mcrypt_cbc(): Size of key is too large for this algorithm in %s on line %d -string(32) "736563726574206d6573736167650000" +Warning: mcrypt_cbc(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths @@ -105,7 +109,7 @@ string(0) "" iv length=8 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(32) "736563726574206d6573736167650000" +string(32) "659ec947f4dc3a3b9c50de744598d3c8" iv length=9 diff --git a/ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt b/ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt index 962d409..2e8dd5f 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt @@ -21,7 +21,7 @@ $cipher = MCRYPT_TRIPLEDES; $data = b"This is the secret message which must be encrypted"; $mode = MCRYPT_ENCRYPT; -// tripledes uses keys upto 192 bits (24 bytes) +// tripledes uses keys with exactly 192 bits (24 bytes) $keys = array( b'12345678', b'12345678901234567890', @@ -41,7 +41,7 @@ foreach ($keys as $key) { var_dump(bin2hex(mcrypt_cbc($cipher, $key, $data, $mode, $iv))); } -$key = b'1234567890123456'; +$key = b'123456789012345678901234'; echo "\n--- testing different iv lengths\n"; foreach ($ivs as $iv) { echo "\niv length=".strlen($iv)."\n"; @@ -57,12 +57,16 @@ foreach ($ivs as $iv) { key length=8 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(112) "082b437d039d09418e20dc9de1dafa7ed6da5c6335b78950968441da1faf40c1f886e04da8ca177b80b376811e138c1bf51cb48dae2e7939" + +Warning: mcrypt_cbc(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(112) "0627351e0f8a082bf7981ae2c700a43fd3d44b270ac67b00fded1c5796eea935be0fef2a23da0b3f5e243929e62ac957bf0bf463aa90fc4f" + +Warning: mcrypt_cbc(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 @@ -73,8 +77,8 @@ key length=26 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -Warning: mcrypt_cbc(): Size of key is too large for this algorithm in %s on line %d -string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac" +Warning: mcrypt_cbc(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths @@ -88,7 +92,7 @@ string(0) "" iv length=8 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(112) "bac347506bf092c5557c4363c301745d78f047028e2953e84fd66b30aeb6005812dadbe8baa871b83278341599b0c448ddaaa52b5a378ce5" +string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac" iv length=9 diff --git a/ext/mcrypt/tests/mcrypt_cbc_variation2.phpt b/ext/mcrypt/tests/mcrypt_cbc_variation2.phpt index 3d2a061..6a16241 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_variation2.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_variation2.phpt @@ -125,39 +125,48 @@ fclose($fp); --int 0-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "bc27b3a4e33b531d5983fc7df693cd09" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 1-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "bc27b3a4e33b531d5983fc7df693cd09" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 12345-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "d109b7973383127002474ae731c4b3a8" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int -12345-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "3e82a931cedb03a38b91a637ff8c9f9e" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 10.5-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "de71833586c1d7132a289960ebeeca7a" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -10.5-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "7d0489dd2e99ae910ecc015573f3dd16" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 12.3456789000e10-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "978055b42c0506a8947e3c3c8d994baf" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -12.3456789000e10-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "4aa84ba400c2b8ef467d4d98372b4f4e" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float .5-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "e731dc5059b84e0c8774ac490f77d6e6" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty array-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) @@ -181,39 +190,48 @@ string(0) "" --uppercase NULL-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase null-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase true-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "bc27b3a4e33b531d5983fc7df693cd09" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase false-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase TRUE-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "bc27b3a4e33b531d5983fc7df693cd09" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase FALSE-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string DQ-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string SQ-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithToString-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "19420fa26f561ee82ed84abbcd2d284b" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithoutToString-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) @@ -222,11 +240,13 @@ string(0) "" --undefined var-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --unset var-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --resource-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) diff --git a/ext/mcrypt/tests/mcrypt_cbc_variation3.phpt b/ext/mcrypt/tests/mcrypt_cbc_variation3.phpt index 9a1464b..f9098a4 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_variation3.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_variation3.phpt @@ -27,7 +27,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $mode = MCRYPT_ENCRYPT; $iv = b'01234567'; diff --git a/ext/mcrypt/tests/mcrypt_cbc_variation4.phpt b/ext/mcrypt/tests/mcrypt_cbc_variation4.phpt index a3dd29b..a13e4ff 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_variation4.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_variation4.phpt @@ -27,7 +27,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $data = b'string_val'; $iv = b'01234567'; diff --git a/ext/mcrypt/tests/mcrypt_cbc_variation5.phpt b/ext/mcrypt/tests/mcrypt_cbc_variation5.phpt index d3a6d9c..24d518d 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_variation5.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_variation5.phpt @@ -27,7 +27,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $data = b'string_val'; $mode = MCRYPT_ENCRYPT; diff --git a/ext/mcrypt/tests/mcrypt_cfb.phpt b/ext/mcrypt/tests/mcrypt_cfb.phpt index 1c7b9c1..a82ea46 100644 --- a/ext/mcrypt/tests/mcrypt_cfb.phpt +++ b/ext/mcrypt/tests/mcrypt_cfb.phpt @@ -4,7 +4,7 @@ mcrypt_cfb <?php if (!extension_loaded("mcrypt")) print "skip"; ?> --FILE-- <?php -$key = "FooBar"; +$key = "0123456789012345"; $secret = "PHP Testfest 2008"; $cipher = MCRYPT_RIJNDAEL_128; diff --git a/ext/mcrypt/tests/mcrypt_decrypt.phpt b/ext/mcrypt/tests/mcrypt_decrypt.phpt index ebf95cd..f615889 100644 --- a/ext/mcrypt/tests/mcrypt_decrypt.phpt +++ b/ext/mcrypt/tests/mcrypt_decrypt.phpt @@ -4,7 +4,7 @@ mcrypt_decrypt <?php if (!extension_loaded("mcrypt")) print "skip"; ?> --FILE-- <?php -$key = "FooBar"; +$key = "0123456789012345"; $secret = "PHP Testfest 2008"; $mode = MCRYPT_MODE_CBC; $cipher = MCRYPT_RIJNDAEL_128; diff --git a/ext/mcrypt/tests/mcrypt_decrypt_3des_cbc.phpt b/ext/mcrypt/tests/mcrypt_decrypt_3des_cbc.phpt index 9c4f30d..0a366dc 100644 --- a/ext/mcrypt/tests/mcrypt_decrypt_3des_cbc.phpt +++ b/ext/mcrypt/tests/mcrypt_decrypt_3des_cbc.phpt @@ -21,7 +21,7 @@ echo "*** Testing mcrypt_decrypt() : basic functionality ***\n"; $cipher = MCRYPT_3DES; $mode = MCRYPT_MODE_CBC; -// tripledes uses keys upto 192 bits (24 bytes) +// tripledes uses keys with exactly 192 bits (24 bytes) $keys = array( b'12345678', b'12345678901234567890', @@ -53,7 +53,7 @@ for ($i = 0; $i < sizeof($keys); $i++) { special_var_dump(mcrypt_decrypt($cipher, $keys[$i], base64_decode($data1[$i]), $mode, $iv)); } -$key = b'1234567890123456'; +$key = b'123456789012345678901234'; echo "\n--- testing different iv lengths\n"; for ($i = 0; $i < sizeof($ivs); $i++) { echo "\niv length=".strlen($ivs[$i])."\n"; @@ -71,18 +71,22 @@ function special_var_dump($str) { --- testing different key lengths key length=8 -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_decrypt(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_decrypt(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 string(32) "736563726574206d6573736167650000" key length=26 -Warning: mcrypt_decrypt(): Size of key is too large for this algorithm in %s on line %d -string(32) "736563726574206d6573736167650000" +Warning: mcrypt_decrypt(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths @@ -92,7 +96,7 @@ Warning: mcrypt_decrypt(): The IV parameter must be as long as the blocksize in string(0) "" iv length=8 -string(32) "736563726574206d6573736167650000" +string(32) "659ec947f4dc3a3b9c50de744598d3c8" iv length=9 diff --git a/ext/mcrypt/tests/mcrypt_decrypt_3des_ecb.phpt b/ext/mcrypt/tests/mcrypt_decrypt_3des_ecb.phpt index 5f841c1..a5a0e72 100644 --- a/ext/mcrypt/tests/mcrypt_decrypt_3des_ecb.phpt +++ b/ext/mcrypt/tests/mcrypt_decrypt_3des_ecb.phpt @@ -21,7 +21,7 @@ echo "*** Testing mcrypt_decrypt() : basic functionality ***\n"; $cipher = MCRYPT_3DES; $mode = MCRYPT_MODE_ECB; -// tripledes uses keys upto 192 bits (24 bytes) +// tripledes uses keys with exactly 192 bits (24 bytes) $keys = array( b'12345678', b'12345678901234567890', @@ -52,7 +52,7 @@ for ($i = 0; $i < sizeof($keys); $i++) { special_var_dump(mcrypt_decrypt($cipher, $keys[$i], base64_decode($data1[$i]), $mode)); } -$key = b'1234567890123456'; +$key = b'123456789012345678901234'; echo "\n--- testing different iv lengths\n"; for ($i = 0; $i < sizeof($ivs); $i++) { echo "\niv length=".strlen($ivs[$i])."\n"; @@ -70,27 +70,31 @@ function special_var_dump($str) { --- testing different key lengths key length=8 -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_decrypt(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_decrypt(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 string(32) "736563726574206d6573736167650000" key length=26 -Warning: mcrypt_decrypt(): Size of key is too large for this algorithm in %s on line %d -string(32) "736563726574206d6573736167650000" +Warning: mcrypt_decrypt(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths iv length=4 -string(32) "736563726574206d6573736167650000" +string(32) "a9298896ed1b7335f8f10f7ff6d7a239" iv length=8 -string(32) "736563726574206d6573736167650000" +string(32) "a9298896ed1b7335f8f10f7ff6d7a239" iv length=9 -string(32) "736563726574206d6573736167650000" +string(32) "a9298896ed1b7335f8f10f7ff6d7a239" ===DONE=== diff --git a/ext/mcrypt/tests/mcrypt_decrypt_variation2.phpt b/ext/mcrypt/tests/mcrypt_decrypt_variation2.phpt index 85adb9c..ce907bf 100644 --- a/ext/mcrypt/tests/mcrypt_decrypt_variation2.phpt +++ b/ext/mcrypt/tests/mcrypt_decrypt_variation2.phpt @@ -124,31 +124,40 @@ fclose($fp); *** Testing mcrypt_decrypt() : usage variation *** --int 0-- -string(32) "43a1ae011df36064589d06bc922ecd97" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 1-- -string(32) "43a1ae011df36064589d06bc922ecd97" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 12345-- -string(32) "e5885552e16c44d4eb6164f477b40200" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int -12345-- -string(32) "adf7873831a9035cda9f9dc3b7dc626b" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 10.5-- -string(32) "08b0b9fac9c227437b7b5d0147e6153b" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -10.5-- -string(32) "f470cc74d83471b42a3e28d4ec57799a" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 12.3456789000e10-- -string(32) "36c618c00523fadc372b871eaa9c7b16" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -12.3456789000e10-- -string(32) "a554a5bdb7a5ceb6ae6f20566ef02e49" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float .5-- -string(32) "bcb840ff76d3788a7911ed36f088a910" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty array-- Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, array given, %s(%d) @@ -167,41 +176,52 @@ Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, array given, %s(%d string(0) "" --uppercase NULL-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase null-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase true-- -string(32) "43a1ae011df36064589d06bc922ecd97" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase false-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase TRUE-- -string(32) "43a1ae011df36064589d06bc922ecd97" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase FALSE-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string DQ-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string SQ-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithToString-- -string(32) "478f9d080563835cc3136610802f1433" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithoutToString-- Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, object given, %s(%d) string(0) "" --undefined var-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --unset var-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --resource-- Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, resource given, %s(%d) diff --git a/ext/mcrypt/tests/mcrypt_decrypt_variation3.phpt b/ext/mcrypt/tests/mcrypt_decrypt_variation3.phpt index 50da260..a36f2c7 100644 --- a/ext/mcrypt/tests/mcrypt_decrypt_variation3.phpt +++ b/ext/mcrypt/tests/mcrypt_decrypt_variation3.phpt @@ -27,7 +27,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $mode = MCRYPT_MODE_ECB; $iv = b'01234567'; diff --git a/ext/mcrypt/tests/mcrypt_decrypt_variation5.phpt b/ext/mcrypt/tests/mcrypt_decrypt_variation5.phpt index aeda9ef..60941fe 100644 --- a/ext/mcrypt/tests/mcrypt_decrypt_variation5.phpt +++ b/ext/mcrypt/tests/mcrypt_decrypt_variation5.phpt @@ -27,7 +27,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $data = b'string_val'; $mode = MCRYPT_MODE_CBC; diff --git a/ext/mcrypt/tests/mcrypt_ecb.phpt b/ext/mcrypt/tests/mcrypt_ecb.phpt index b6d0a22..7a4bc3a 100644 --- a/ext/mcrypt/tests/mcrypt_ecb.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb.phpt @@ -4,7 +4,7 @@ mcrypt_ecb <?php if (!extension_loaded("mcrypt")) print "skip"; ?> --FILE-- <?php -$key = "FooBar"; +$key = "0123456789012345"; $secret = "PHP Testfest 2008"; $cipher = MCRYPT_RIJNDAEL_128; diff --git a/ext/mcrypt/tests/mcrypt_ecb_3des_decrypt.phpt b/ext/mcrypt/tests/mcrypt_ecb_3des_decrypt.phpt index 82f9608..29772e9 100644 --- a/ext/mcrypt/tests/mcrypt_ecb_3des_decrypt.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb_3des_decrypt.phpt @@ -55,7 +55,7 @@ for ($i = 0; $i < sizeof($keys); $i++) { special_var_dump(mcrypt_ecb($cipher, $keys[$i], base64_decode($data1[$i]), $mode, $iv)); } -$key = b'1234567890123456'; +$key = b'123456789012345678901234'; echo "\n--- testing different iv lengths\n"; for ($i = 0; $i < sizeof($ivs); $i++) { echo "\niv length=".strlen($ivs[$i])."\n"; @@ -73,27 +73,31 @@ function special_var_dump($str) { --- testing different key lengths key length=8 -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_ecb(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_ecb(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 string(32) "736563726574206d6573736167650000" key length=26 -Warning: mcrypt_ecb(): Size of key is too large for this algorithm in %s on line %d -string(32) "736563726574206d6573736167650000" +Warning: mcrypt_ecb(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths iv length=4 -string(32) "736563726574206d6573736167650000" +string(32) "a9298896ed1b7335f8f10f7ff6d7a239" iv length=8 -string(32) "736563726574206d6573736167650000" +string(32) "a9298896ed1b7335f8f10f7ff6d7a239" iv length=9 -string(32) "736563726574206d6573736167650000" +string(32) "a9298896ed1b7335f8f10f7ff6d7a239" ===DONE=== diff --git a/ext/mcrypt/tests/mcrypt_ecb_3des_encrypt.phpt b/ext/mcrypt/tests/mcrypt_ecb_3des_encrypt.phpt index 50107b4..7a21df3 100644 --- a/ext/mcrypt/tests/mcrypt_ecb_3des_encrypt.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb_3des_encrypt.phpt @@ -44,7 +44,7 @@ foreach ($keys as $key) { var_dump(bin2hex(mcrypt_ecb($cipher, $key, $data, $mode, $iv))); } -$key = b'1234567890123456'; +$key = b"1234567890123456\0\0\0\0\0\0\0\0"; echo "\n--- testing different iv lengths\n"; foreach ($ivs as $iv) { echo "\niv length=".strlen($iv)."\n"; @@ -58,18 +58,22 @@ foreach ($ivs as $iv) { --- testing different key lengths key length=8 -string(112) "05c9c4cafb9937d950bdae60ee3abcb8d9f3e1f1fac8acaaa5b11d70b7ca02f3b76d447ab3dd85a4b5df5dedb4b4654595ccdf6da97fa93f" + +Warning: mcrypt_ecb(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 -string(112) "0fc7045c4fb4dbcf44baf9ed15ab40331a42ff0632318a16b12ed5873f02e7945e4f63f408d6849534cbb7419c22c8854aaa85e0e05a28e6" + +Warning: mcrypt_ecb(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27" key length=26 -Warning: mcrypt_ecb(): Size of key is too large for this algorithm in %s on line %d -string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27" +Warning: mcrypt_ecb(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths diff --git a/ext/mcrypt/tests/mcrypt_ecb_variation2.phpt b/ext/mcrypt/tests/mcrypt_ecb_variation2.phpt index ed57400..ea3af84 100644 --- a/ext/mcrypt/tests/mcrypt_ecb_variation2.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb_variation2.phpt @@ -126,31 +126,40 @@ fclose($fp); *** Testing mcrypt_ecb() : usage variation *** --int 0-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 1-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 12345-- -string(32) "d74e5f51d1199bcfa61f80168e913007" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int -12345-- -string(32) "17fe485ed735abb34c1dd4455af7b79c" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 10.5-- -string(32) "cd735509aa4013a130e011686d66ae01" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -10.5-- -string(32) "a57d99d6d5813039abf50fc50d631e47" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 12.3456789000e10-- -string(32) "f17ede0bfdaa4408f545f7f4c8b040d2" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -12.3456789000e10-- -string(32) "326f64e3b9bd5a6beb0a9b52a09a5a48" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float .5-- -string(32) "2aedf7661cd4d8c7593f44c58718e2b8" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty array-- Error: 2 - mcrypt_ecb() expects parameter 2 to be string, array given, %s(%d) @@ -169,41 +178,52 @@ Error: 2 - mcrypt_ecb() expects parameter 2 to be string, array given, %s(%d) string(0) "" --uppercase NULL-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase null-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase true-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase false-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase TRUE-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase FALSE-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string DQ-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string SQ-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithToString-- -string(32) "1fd3514d8ced44d04d9dc7511fce33ef" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithoutToString-- Error: 2 - mcrypt_ecb() expects parameter 2 to be string, object given, %s(%d) string(0) "" --undefined var-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --unset var-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --resource-- Error: 2 - mcrypt_ecb() expects parameter 2 to be string, resource given, %s(%d) diff --git a/ext/mcrypt/tests/mcrypt_ecb_variation3.phpt b/ext/mcrypt/tests/mcrypt_ecb_variation3.phpt index 2999304..171468f 100644 --- a/ext/mcrypt/tests/mcrypt_ecb_variation3.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb_variation3.phpt @@ -29,7 +29,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $mode = MCRYPT_ENCRYPT; $iv = b'01234567'; diff --git a/ext/mcrypt/tests/mcrypt_ecb_variation4.phpt b/ext/mcrypt/tests/mcrypt_ecb_variation4.phpt index e52040e..b5c4f29 100644 --- a/ext/mcrypt/tests/mcrypt_ecb_variation4.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb_variation4.phpt @@ -29,7 +29,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $data = b'string_val'; $iv = b'01234567'; diff --git a/ext/mcrypt/tests/mcrypt_ecb_variation5.phpt b/ext/mcrypt/tests/mcrypt_ecb_variation5.phpt index 3f4f7f5..8771b9a 100644 --- a/ext/mcrypt/tests/mcrypt_ecb_variation5.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb_variation5.phpt @@ -29,7 +29,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $data = b'string_val'; $mode = MCRYPT_ENCRYPT; diff --git a/ext/mcrypt/tests/mcrypt_encrypt_3des_cbc.phpt b/ext/mcrypt/tests/mcrypt_encrypt_3des_cbc.phpt index 21b3cee..9c9f926 100644 --- a/ext/mcrypt/tests/mcrypt_encrypt_3des_cbc.phpt +++ b/ext/mcrypt/tests/mcrypt_encrypt_3des_cbc.phpt @@ -49,7 +49,7 @@ foreach ($keys as $key) { var_dump(bin2hex(mcrypt_encrypt($cipher, $key, $data, $mode, $iv))); } -$key = b'1234567890123456'; +$key = b'123456789012345678901234'; echo "\n--- testing different iv lengths\n"; foreach ($ivs as $iv) { echo "\niv length=".strlen($iv)."\n"; @@ -64,18 +64,22 @@ foreach ($ivs as $iv) { --- testing different key lengths key length=8 -string(112) "082b437d039d09418e20dc9de1dafa7ed6da5c6335b78950968441da1faf40c1f886e04da8ca177b80b376811e138c1bf51cb48dae2e7939" + +Warning: mcrypt_encrypt(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 -string(112) "0627351e0f8a082bf7981ae2c700a43fd3d44b270ac67b00fded1c5796eea935be0fef2a23da0b3f5e243929e62ac957bf0bf463aa90fc4f" + +Warning: mcrypt_encrypt(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac" key length=26 -Warning: mcrypt_encrypt(): Size of key is too large for this algorithm in %s on line %d -string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac" +Warning: mcrypt_encrypt(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths @@ -85,7 +89,7 @@ Warning: mcrypt_encrypt(): The IV parameter must be as long as the blocksize in string(0) "" iv length=8 -string(112) "bac347506bf092c5557c4363c301745d78f047028e2953e84fd66b30aeb6005812dadbe8baa871b83278341599b0c448ddaaa52b5a378ce5" +string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac" iv length=9 diff --git a/ext/mcrypt/tests/mcrypt_encrypt_3des_ecb.phpt b/ext/mcrypt/tests/mcrypt_encrypt_3des_ecb.phpt index 1b3188f..0531dcb 100644 --- a/ext/mcrypt/tests/mcrypt_encrypt_3des_ecb.phpt +++ b/ext/mcrypt/tests/mcrypt_encrypt_3des_ecb.phpt @@ -34,7 +34,7 @@ foreach ($keys as $key) { var_dump(bin2hex(mcrypt_encrypt($cipher, $key, $data, $mode))); } -$key = b'12345678'; +$key = b'123456789012345678901234'; $ivs = array( b'1234', b'12345678', @@ -56,27 +56,31 @@ foreach ($ivs as $iv) { --- testing different key lengths key length=8 -string(112) "05c9c4cafb9937d950bdae60ee3abcb8d9f3e1f1fac8acaaa5b11d70b7ca02f3b76d447ab3dd85a4b5df5dedb4b4654595ccdf6da97fa93f" + +Warning: mcrypt_encrypt(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 -string(112) "0fc7045c4fb4dbcf44baf9ed15ab40331a42ff0632318a16b12ed5873f02e7945e4f63f408d6849534cbb7419c22c8854aaa85e0e05a28e6" + +Warning: mcrypt_encrypt(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27" key length=26 -Warning: mcrypt_encrypt(): Size of key is too large for this algorithm in %s on line %d -string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27" +Warning: mcrypt_encrypt(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths iv length=4 -string(112) "05c9c4cafb9937d950bdae60ee3abcb8d9f3e1f1fac8acaaa5b11d70b7ca02f3b76d447ab3dd85a4b5df5dedb4b4654595ccdf6da97fa93f" +string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27" iv length=8 -string(112) "05c9c4cafb9937d950bdae60ee3abcb8d9f3e1f1fac8acaaa5b11d70b7ca02f3b76d447ab3dd85a4b5df5dedb4b4654595ccdf6da97fa93f" +string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27" iv length=9 -string(112) "05c9c4cafb9937d950bdae60ee3abcb8d9f3e1f1fac8acaaa5b11d70b7ca02f3b76d447ab3dd85a4b5df5dedb4b4654595ccdf6da97fa93f" +string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27" ===DONE=== diff --git a/ext/mcrypt/tests/mcrypt_encrypt_variation2.phpt b/ext/mcrypt/tests/mcrypt_encrypt_variation2.phpt index 0f4fd0f..286fbea 100644 --- a/ext/mcrypt/tests/mcrypt_encrypt_variation2.phpt +++ b/ext/mcrypt/tests/mcrypt_encrypt_variation2.phpt @@ -124,31 +124,40 @@ fclose($fp); *** Testing mcrypt_encrypt() : usage variation *** --int 0-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 1-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 12345-- -string(32) "d74e5f51d1199bcfa61f80168e913007" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int -12345-- -string(32) "17fe485ed735abb34c1dd4455af7b79c" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 10.5-- -string(32) "cd735509aa4013a130e011686d66ae01" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -10.5-- -string(32) "a57d99d6d5813039abf50fc50d631e47" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 12.3456789000e10-- -string(32) "f17ede0bfdaa4408f545f7f4c8b040d2" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -12.3456789000e10-- -string(32) "326f64e3b9bd5a6beb0a9b52a09a5a48" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float .5-- -string(32) "2aedf7661cd4d8c7593f44c58718e2b8" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty array-- Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, array given, %s(%d) @@ -167,41 +176,52 @@ Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, array given, %s(%d string(0) "" --uppercase NULL-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase null-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase true-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase false-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase TRUE-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase FALSE-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string DQ-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string SQ-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithToString-- -string(32) "1fd3514d8ced44d04d9dc7511fce33ef" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithoutToString-- Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, object given, %s(%d) string(0) "" --undefined var-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --unset var-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --resource-- Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, resource given, %s(%d) diff --git a/ext/mcrypt/tests/mcrypt_encrypt_variation3.phpt b/ext/mcrypt/tests/mcrypt_encrypt_variation3.phpt index c472540..9fb8e7c 100644 --- a/ext/mcrypt/tests/mcrypt_encrypt_variation3.phpt +++ b/ext/mcrypt/tests/mcrypt_encrypt_variation3.phpt @@ -27,7 +27,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $mode = MCRYPT_MODE_ECB; $iv = b'01234567'; diff --git a/ext/mcrypt/tests/mcrypt_encrypt_variation5.phpt b/ext/mcrypt/tests/mcrypt_encrypt_variation5.phpt index 8d1cf86..07c5e15 100644 --- a/ext/mcrypt/tests/mcrypt_encrypt_variation5.phpt +++ b/ext/mcrypt/tests/mcrypt_encrypt_variation5.phpt @@ -27,7 +27,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $data = b'string_val'; //in php, it incorrectly reports problems with iv in ECB mode. $mode = MCRYPT_MODE_CBC; diff --git a/ext/mcrypt/tests/mcrypt_ofb.phpt b/ext/mcrypt/tests/mcrypt_ofb.phpt index 9420353..5580575 100644 --- a/ext/mcrypt/tests/mcrypt_ofb.phpt +++ b/ext/mcrypt/tests/mcrypt_ofb.phpt @@ -4,7 +4,7 @@ mcrypt_ofb <?php if (!extension_loaded("mcrypt")) print "skip"; ?> --FILE-- <?php -$key = "FooBar"; +$key = "0123456789012345"; $secret = "PHP Testfest 2008"; $cipher = MCRYPT_RIJNDAEL_128; diff --git a/ext/mcrypt/tests/mcrypt_rijndael128_128BitKey.phpt b/ext/mcrypt/tests/mcrypt_rijndael128_128BitKey.phpt index 7a12da8..ee1fcee 100644 --- a/ext/mcrypt/tests/mcrypt_rijndael128_128BitKey.phpt +++ b/ext/mcrypt/tests/mcrypt_rijndael128_128BitKey.phpt @@ -1,5 +1,5 @@ --TEST-- -Test mcrypt_encrypt() function : TripleDES functionality +Test mcrypt_encrypt() function : AES functionality --SKIPIF-- <?php if (!extension_loaded("mcrypt")) { @@ -75,22 +75,34 @@ foreach ($ivs as $iv) { --- testing different key lengths key length=0 -string(128) "4fbf24aaa789f5194260ade1acd9499402c1845cc517e8fe43cfb5b90a0df294db33ecd1a836c47d6bf6d8600512ba415e17008a1e1991f81056258d82099397" + +Warning: mcrypt_encrypt(): Key of length 0 not supported by this algorithm in %s on line %d +string(0) "" Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000" + +Warning: mcrypt_cbc(): Key of length 0 not supported by this algorithm in %s on line %d +string(0) "" key length=0 -string(128) "4fbf24aaa789f5194260ade1acd9499402c1845cc517e8fe43cfb5b90a0df294db33ecd1a836c47d6bf6d8600512ba415e17008a1e1991f81056258d82099397" + +Warning: mcrypt_encrypt(): Key of length 0 not supported by this algorithm in %s on line %d +string(0) "" Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000" + +Warning: mcrypt_cbc(): Key of length 0 not supported by this algorithm in %s on line %d +string(0) "" key length=8 -string(128) "d6a3042b278fa5816dc6f46152acbe5fd7d1813c3808c27cd969d8e10a64d0238724edfda0322f4512308f22d142df0e92bed861c2b732f7650e234df59183dc" + +Warning: mcrypt_encrypt(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000" + +Warning: mcrypt_cbc(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=16 string(128) "dc8f957ec530acf10cd95ba7da7b6405380fe19a2941e9a8de54680512f18491bc374e5464885ae6c2ae2aa7a6cdd2fbe12a06bbc4bd59dbbfaa15f09044f101" diff --git a/ext/mcrypt/tests/mcrypt_rijndael128_256BitKey.phpt b/ext/mcrypt/tests/mcrypt_rijndael128_256BitKey.phpt index f69d369..7f6ad5d 100644 --- a/ext/mcrypt/tests/mcrypt_rijndael128_256BitKey.phpt +++ b/ext/mcrypt/tests/mcrypt_rijndael128_256BitKey.phpt @@ -1,5 +1,5 @@ --TEST-- -Test mcrypt_encrypt() function : TripleDES functionality +Test mcrypt_encrypt() function : AES functionality --SKIPIF-- <?php if (!extension_loaded("mcrypt")) { @@ -62,16 +62,24 @@ foreach ($keys as $key) { --- testing different key lengths key length=20 -string(128) "6369830bfc89a39c9981c9a40e349e3bbc8599c28d7ffbd7a330a67690dac6dfb76a55814e95c83cced68eb1544cdd8406d272c249bd0a60fa5b605d4aefbaa0" -string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000" + +Warning: mcrypt_encrypt(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" + +Warning: mcrypt_decrypt(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 string(128) "8ecdf1ed5742aff16ef34c819c8d22c707c54f4d9ffc18e5f6ab79fe68c25705351e2c001a0b9f29e5def67570ca9da644efb69a8bb97940cb4bec094dae8bb5" string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000" key length=30 -string(128) "f7731f0c0ab22270b2f516c7837256ed731ba6658ca8f78cda2ab1588e204f990843719ae88474f6572711674fcda9f40d99155e4cc4f5a31aa461ad36a7871d" -string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000" + +Warning: mcrypt_encrypt(): Key of length 30 not supported by this algorithm in %s on line %d +string(0) "" + +Warning: mcrypt_decrypt(): Key of length 30 not supported by this algorithm in %s on line %d +string(0) "" key length=32 string(128) "f23bc103bfd0859a8318acee6d96e5f43dff68f3cdeae817a1e77c33492e32bdb82c5f660fcd1a2bfda70d9de4d5d8028ce179a9e2f7f9ee7dd61c7b4b409e95" @@ -79,9 +87,9 @@ string(128) "546869732069732074686520736563726574206d657373616765207768696368206 key length=40 -Warning: mcrypt_encrypt(): Size of key is too large for this algorithm in %s on line %d -string(128) "f23bc103bfd0859a8318acee6d96e5f43dff68f3cdeae817a1e77c33492e32bdb82c5f660fcd1a2bfda70d9de4d5d8028ce179a9e2f7f9ee7dd61c7b4b409e95" +Warning: mcrypt_encrypt(): Key of length 40 not supported by this algorithm in %s on line %d +string(0) "" -Warning: mcrypt_decrypt(): Size of key is too large for this algorithm in %s on line %d -string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000" -===DONE=== \ No newline at end of file +Warning: mcrypt_decrypt(): Key of length 40 not supported by this algorithm in %s on line %d +string(0) "" +===DONE===
diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index 889dce3..d3dc5c2 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -1169,7 +1169,7 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons { char *cipher_dir_string; char *module_dir_string; - int block_size, max_key_length, use_key_length, i, count, iv_size; + int block_size, use_key_length, i, count, iv_size; unsigned long int data_size; int *key_length_sizes; char *key_s = NULL, *iv_s; @@ -1184,33 +1184,27 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons RETURN_FALSE; } /* Checking for key-length */ - max_key_length = mcrypt_enc_get_key_size(td); - if (key_len > max_key_length) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Size of key is too large for this algorithm"); - } key_length_sizes = mcrypt_enc_get_supported_key_sizes(td, &count); if (count == 0 && key_length_sizes == NULL) { /* all lengths 1 - k_l_s = OK */ use_key_length = key_len; key_s = emalloc(use_key_length); memset(key_s, 0, use_key_length); memcpy(key_s, key, use_key_length); - } else if (count == 1) { /* only m_k_l = OK */ - key_s = emalloc(key_length_sizes[0]); - memset(key_s, 0, key_length_sizes[0]); - memcpy(key_s, key, MIN(key_len, key_length_sizes[0])); - use_key_length = key_length_sizes[0]; - } else { /* dertermine smallest supported key > length of requested key */ - use_key_length = max_key_length; /* start with max key length */ + } else { for (i = 0; i < count; i++) { - if (key_length_sizes[i] >= key_len && - key_length_sizes[i] < use_key_length) - { - use_key_length = key_length_sizes[i]; + if (key_length_sizes[i] == key_len) { + use_key_length = key_len; + key_s = emalloc(use_key_length); + memcpy(key_s, key, use_key_length); + break; } } - key_s = emalloc(use_key_length); - memset(key_s, 0, use_key_length); - memcpy(key_s, key, MIN(key_len, use_key_length)); + + if (!key_s) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Key of length %d not supported by this algorithm", key_len); + mcrypt_free(key_length_sizes); + RETURN_FALSE; + } } mcrypt_free (key_length_sizes); diff --git a/ext/mcrypt/tests/bug46010.phpt b/ext/mcrypt/tests/bug46010.phpt index ddb691e..1f0fe40 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" diff --git a/ext/mcrypt/tests/mcrypt_cbc.phpt b/ext/mcrypt/tests/mcrypt_cbc.phpt index fb74df9..cf723e3 100644 --- a/ext/mcrypt/tests/mcrypt_cbc.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc.phpt @@ -4,7 +4,7 @@ mcrypt_cbc <?php if (!extension_loaded("mcrypt")) print "skip"; ?> --FILE-- <?php -$key = "FooBar"; +$key = "0123456789012345"; $secret = "PHP Testfest 2008"; $cipher = MCRYPT_RIJNDAEL_128; @@ -17,6 +17,7 @@ echo trim(mcrypt_cbc($cipher, $key, $enc_data, MCRYPT_DECRYPT, $iv)) . "\n"; // a warning must be issued if we don't use a IV on a AES cipher, that usually requires an IV var_dump(mcrypt_cbc($cipher, $key, $enc_data, MCRYPT_DECRYPT)); +?> --EXPECTF-- Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d diff --git a/ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt b/ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt index f65123b..775c153 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt @@ -21,7 +21,7 @@ $cipher = MCRYPT_TRIPLEDES; $data = b"This is the secret message which must be encrypted"; $mode = MCRYPT_DECRYPT; -// tripledes uses keys upto 192 bits (24 bytes) +// tripledes uses keys with exactly 192 bits (24 bytes) $keys = array( b'12345678', b'12345678901234567890', @@ -54,7 +54,7 @@ for ($i = 0; $i < sizeof($keys); $i++) { special_var_dump(mcrypt_cbc($cipher, $keys[$i], base64_decode($data1[$i]), $mode, $iv)); } -$key = b'1234567890123456'; +$key = b'123456789012345678901234'; echo "\n--- testing different iv lengths\n"; for ($i = 0; $i < sizeof($ivs); $i++) { echo "\niv length=".strlen($ivs[$i])."\n"; @@ -74,12 +74,16 @@ function special_var_dump($str) { key length=8 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_cbc(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_cbc(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 @@ -90,8 +94,8 @@ key length=26 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -Warning: mcrypt_cbc(): Size of key is too large for this algorithm in %s on line %d -string(32) "736563726574206d6573736167650000" +Warning: mcrypt_cbc(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths @@ -105,7 +109,7 @@ string(0) "" iv length=8 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(32) "736563726574206d6573736167650000" +string(32) "659ec947f4dc3a3b9c50de744598d3c8" iv length=9 diff --git a/ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt b/ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt index 962d409..2e8dd5f 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt @@ -21,7 +21,7 @@ $cipher = MCRYPT_TRIPLEDES; $data = b"This is the secret message which must be encrypted"; $mode = MCRYPT_ENCRYPT; -// tripledes uses keys upto 192 bits (24 bytes) +// tripledes uses keys with exactly 192 bits (24 bytes) $keys = array( b'12345678', b'12345678901234567890', @@ -41,7 +41,7 @@ foreach ($keys as $key) { var_dump(bin2hex(mcrypt_cbc($cipher, $key, $data, $mode, $iv))); } -$key = b'1234567890123456'; +$key = b'123456789012345678901234'; echo "\n--- testing different iv lengths\n"; foreach ($ivs as $iv) { echo "\niv length=".strlen($iv)."\n"; @@ -57,12 +57,16 @@ foreach ($ivs as $iv) { key length=8 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(112) "082b437d039d09418e20dc9de1dafa7ed6da5c6335b78950968441da1faf40c1f886e04da8ca177b80b376811e138c1bf51cb48dae2e7939" + +Warning: mcrypt_cbc(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(112) "0627351e0f8a082bf7981ae2c700a43fd3d44b270ac67b00fded1c5796eea935be0fef2a23da0b3f5e243929e62ac957bf0bf463aa90fc4f" + +Warning: mcrypt_cbc(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 @@ -73,8 +77,8 @@ key length=26 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -Warning: mcrypt_cbc(): Size of key is too large for this algorithm in %s on line %d -string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac" +Warning: mcrypt_cbc(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths @@ -88,7 +92,7 @@ string(0) "" iv length=8 Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(112) "bac347506bf092c5557c4363c301745d78f047028e2953e84fd66b30aeb6005812dadbe8baa871b83278341599b0c448ddaaa52b5a378ce5" +string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac" iv length=9 diff --git a/ext/mcrypt/tests/mcrypt_cbc_variation2.phpt b/ext/mcrypt/tests/mcrypt_cbc_variation2.phpt index 3d2a061..6a16241 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_variation2.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_variation2.phpt @@ -125,39 +125,48 @@ fclose($fp); --int 0-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "bc27b3a4e33b531d5983fc7df693cd09" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 1-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "bc27b3a4e33b531d5983fc7df693cd09" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 12345-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "d109b7973383127002474ae731c4b3a8" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int -12345-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "3e82a931cedb03a38b91a637ff8c9f9e" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 10.5-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "de71833586c1d7132a289960ebeeca7a" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -10.5-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "7d0489dd2e99ae910ecc015573f3dd16" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 12.3456789000e10-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "978055b42c0506a8947e3c3c8d994baf" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -12.3456789000e10-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "4aa84ba400c2b8ef467d4d98372b4f4e" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float .5-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "e731dc5059b84e0c8774ac490f77d6e6" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty array-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) @@ -181,39 +190,48 @@ string(0) "" --uppercase NULL-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase null-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase true-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "bc27b3a4e33b531d5983fc7df693cd09" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase false-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase TRUE-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "bc27b3a4e33b531d5983fc7df693cd09" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase FALSE-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string DQ-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string SQ-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithToString-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "19420fa26f561ee82ed84abbcd2d284b" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithoutToString-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) @@ -222,11 +240,13 @@ string(0) "" --undefined var-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --unset var-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) -string(32) "be722a5ffc361d721fbcab1eacc6acf5" +Error: 2 - mcrypt_cbc(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --resource-- Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) diff --git a/ext/mcrypt/tests/mcrypt_cbc_variation3.phpt b/ext/mcrypt/tests/mcrypt_cbc_variation3.phpt index 9a1464b..f9098a4 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_variation3.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_variation3.phpt @@ -27,7 +27,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $mode = MCRYPT_ENCRYPT; $iv = b'01234567'; diff --git a/ext/mcrypt/tests/mcrypt_cbc_variation4.phpt b/ext/mcrypt/tests/mcrypt_cbc_variation4.phpt index a3dd29b..a13e4ff 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_variation4.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_variation4.phpt @@ -27,7 +27,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $data = b'string_val'; $iv = b'01234567'; diff --git a/ext/mcrypt/tests/mcrypt_cbc_variation5.phpt b/ext/mcrypt/tests/mcrypt_cbc_variation5.phpt index d3a6d9c..24d518d 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_variation5.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_variation5.phpt @@ -27,7 +27,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $data = b'string_val'; $mode = MCRYPT_ENCRYPT; diff --git a/ext/mcrypt/tests/mcrypt_cfb.phpt b/ext/mcrypt/tests/mcrypt_cfb.phpt index 1c7b9c1..a82ea46 100644 --- a/ext/mcrypt/tests/mcrypt_cfb.phpt +++ b/ext/mcrypt/tests/mcrypt_cfb.phpt @@ -4,7 +4,7 @@ mcrypt_cfb <?php if (!extension_loaded("mcrypt")) print "skip"; ?> --FILE-- <?php -$key = "FooBar"; +$key = "0123456789012345"; $secret = "PHP Testfest 2008"; $cipher = MCRYPT_RIJNDAEL_128; diff --git a/ext/mcrypt/tests/mcrypt_decrypt.phpt b/ext/mcrypt/tests/mcrypt_decrypt.phpt index ebf95cd..f615889 100644 --- a/ext/mcrypt/tests/mcrypt_decrypt.phpt +++ b/ext/mcrypt/tests/mcrypt_decrypt.phpt @@ -4,7 +4,7 @@ mcrypt_decrypt <?php if (!extension_loaded("mcrypt")) print "skip"; ?> --FILE-- <?php -$key = "FooBar"; +$key = "0123456789012345"; $secret = "PHP Testfest 2008"; $mode = MCRYPT_MODE_CBC; $cipher = MCRYPT_RIJNDAEL_128; diff --git a/ext/mcrypt/tests/mcrypt_decrypt_3des_cbc.phpt b/ext/mcrypt/tests/mcrypt_decrypt_3des_cbc.phpt index 9c4f30d..0a366dc 100644 --- a/ext/mcrypt/tests/mcrypt_decrypt_3des_cbc.phpt +++ b/ext/mcrypt/tests/mcrypt_decrypt_3des_cbc.phpt @@ -21,7 +21,7 @@ echo "*** Testing mcrypt_decrypt() : basic functionality ***\n"; $cipher = MCRYPT_3DES; $mode = MCRYPT_MODE_CBC; -// tripledes uses keys upto 192 bits (24 bytes) +// tripledes uses keys with exactly 192 bits (24 bytes) $keys = array( b'12345678', b'12345678901234567890', @@ -53,7 +53,7 @@ for ($i = 0; $i < sizeof($keys); $i++) { special_var_dump(mcrypt_decrypt($cipher, $keys[$i], base64_decode($data1[$i]), $mode, $iv)); } -$key = b'1234567890123456'; +$key = b'123456789012345678901234'; echo "\n--- testing different iv lengths\n"; for ($i = 0; $i < sizeof($ivs); $i++) { echo "\niv length=".strlen($ivs[$i])."\n"; @@ -71,18 +71,22 @@ function special_var_dump($str) { --- testing different key lengths key length=8 -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_decrypt(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_decrypt(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 string(32) "736563726574206d6573736167650000" key length=26 -Warning: mcrypt_decrypt(): Size of key is too large for this algorithm in %s on line %d -string(32) "736563726574206d6573736167650000" +Warning: mcrypt_decrypt(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths @@ -92,7 +96,7 @@ Warning: mcrypt_decrypt(): The IV parameter must be as long as the blocksize in string(0) "" iv length=8 -string(32) "736563726574206d6573736167650000" +string(32) "659ec947f4dc3a3b9c50de744598d3c8" iv length=9 diff --git a/ext/mcrypt/tests/mcrypt_decrypt_3des_ecb.phpt b/ext/mcrypt/tests/mcrypt_decrypt_3des_ecb.phpt index 5f841c1..a5a0e72 100644 --- a/ext/mcrypt/tests/mcrypt_decrypt_3des_ecb.phpt +++ b/ext/mcrypt/tests/mcrypt_decrypt_3des_ecb.phpt @@ -21,7 +21,7 @@ echo "*** Testing mcrypt_decrypt() : basic functionality ***\n"; $cipher = MCRYPT_3DES; $mode = MCRYPT_MODE_ECB; -// tripledes uses keys upto 192 bits (24 bytes) +// tripledes uses keys with exactly 192 bits (24 bytes) $keys = array( b'12345678', b'12345678901234567890', @@ -52,7 +52,7 @@ for ($i = 0; $i < sizeof($keys); $i++) { special_var_dump(mcrypt_decrypt($cipher, $keys[$i], base64_decode($data1[$i]), $mode)); } -$key = b'1234567890123456'; +$key = b'123456789012345678901234'; echo "\n--- testing different iv lengths\n"; for ($i = 0; $i < sizeof($ivs); $i++) { echo "\niv length=".strlen($ivs[$i])."\n"; @@ -70,27 +70,31 @@ function special_var_dump($str) { --- testing different key lengths key length=8 -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_decrypt(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_decrypt(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 string(32) "736563726574206d6573736167650000" key length=26 -Warning: mcrypt_decrypt(): Size of key is too large for this algorithm in %s on line %d -string(32) "736563726574206d6573736167650000" +Warning: mcrypt_decrypt(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths iv length=4 -string(32) "736563726574206d6573736167650000" +string(32) "a9298896ed1b7335f8f10f7ff6d7a239" iv length=8 -string(32) "736563726574206d6573736167650000" +string(32) "a9298896ed1b7335f8f10f7ff6d7a239" iv length=9 -string(32) "736563726574206d6573736167650000" +string(32) "a9298896ed1b7335f8f10f7ff6d7a239" ===DONE=== diff --git a/ext/mcrypt/tests/mcrypt_decrypt_variation2.phpt b/ext/mcrypt/tests/mcrypt_decrypt_variation2.phpt index 85adb9c..ce907bf 100644 --- a/ext/mcrypt/tests/mcrypt_decrypt_variation2.phpt +++ b/ext/mcrypt/tests/mcrypt_decrypt_variation2.phpt @@ -124,31 +124,40 @@ fclose($fp); *** Testing mcrypt_decrypt() : usage variation *** --int 0-- -string(32) "43a1ae011df36064589d06bc922ecd97" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 1-- -string(32) "43a1ae011df36064589d06bc922ecd97" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 12345-- -string(32) "e5885552e16c44d4eb6164f477b40200" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int -12345-- -string(32) "adf7873831a9035cda9f9dc3b7dc626b" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 10.5-- -string(32) "08b0b9fac9c227437b7b5d0147e6153b" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -10.5-- -string(32) "f470cc74d83471b42a3e28d4ec57799a" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 12.3456789000e10-- -string(32) "36c618c00523fadc372b871eaa9c7b16" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -12.3456789000e10-- -string(32) "a554a5bdb7a5ceb6ae6f20566ef02e49" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float .5-- -string(32) "bcb840ff76d3788a7911ed36f088a910" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty array-- Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, array given, %s(%d) @@ -167,41 +176,52 @@ Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, array given, %s(%d string(0) "" --uppercase NULL-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase null-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase true-- -string(32) "43a1ae011df36064589d06bc922ecd97" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase false-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase TRUE-- -string(32) "43a1ae011df36064589d06bc922ecd97" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase FALSE-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string DQ-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string SQ-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithToString-- -string(32) "478f9d080563835cc3136610802f1433" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithoutToString-- Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, object given, %s(%d) string(0) "" --undefined var-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --unset var-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_decrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --resource-- Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, resource given, %s(%d) diff --git a/ext/mcrypt/tests/mcrypt_decrypt_variation3.phpt b/ext/mcrypt/tests/mcrypt_decrypt_variation3.phpt index 50da260..a36f2c7 100644 --- a/ext/mcrypt/tests/mcrypt_decrypt_variation3.phpt +++ b/ext/mcrypt/tests/mcrypt_decrypt_variation3.phpt @@ -27,7 +27,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $mode = MCRYPT_MODE_ECB; $iv = b'01234567'; diff --git a/ext/mcrypt/tests/mcrypt_decrypt_variation5.phpt b/ext/mcrypt/tests/mcrypt_decrypt_variation5.phpt index aeda9ef..60941fe 100644 --- a/ext/mcrypt/tests/mcrypt_decrypt_variation5.phpt +++ b/ext/mcrypt/tests/mcrypt_decrypt_variation5.phpt @@ -27,7 +27,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $data = b'string_val'; $mode = MCRYPT_MODE_CBC; diff --git a/ext/mcrypt/tests/mcrypt_ecb.phpt b/ext/mcrypt/tests/mcrypt_ecb.phpt index b6d0a22..7a4bc3a 100644 --- a/ext/mcrypt/tests/mcrypt_ecb.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb.phpt @@ -4,7 +4,7 @@ mcrypt_ecb <?php if (!extension_loaded("mcrypt")) print "skip"; ?> --FILE-- <?php -$key = "FooBar"; +$key = "0123456789012345"; $secret = "PHP Testfest 2008"; $cipher = MCRYPT_RIJNDAEL_128; diff --git a/ext/mcrypt/tests/mcrypt_ecb_3des_decrypt.phpt b/ext/mcrypt/tests/mcrypt_ecb_3des_decrypt.phpt index 82f9608..29772e9 100644 --- a/ext/mcrypt/tests/mcrypt_ecb_3des_decrypt.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb_3des_decrypt.phpt @@ -55,7 +55,7 @@ for ($i = 0; $i < sizeof($keys); $i++) { special_var_dump(mcrypt_ecb($cipher, $keys[$i], base64_decode($data1[$i]), $mode, $iv)); } -$key = b'1234567890123456'; +$key = b'123456789012345678901234'; echo "\n--- testing different iv lengths\n"; for ($i = 0; $i < sizeof($ivs); $i++) { echo "\niv length=".strlen($ivs[$i])."\n"; @@ -73,27 +73,31 @@ function special_var_dump($str) { --- testing different key lengths key length=8 -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_ecb(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 -string(32) "736563726574206d6573736167650000" + +Warning: mcrypt_ecb(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 string(32) "736563726574206d6573736167650000" key length=26 -Warning: mcrypt_ecb(): Size of key is too large for this algorithm in %s on line %d -string(32) "736563726574206d6573736167650000" +Warning: mcrypt_ecb(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths iv length=4 -string(32) "736563726574206d6573736167650000" +string(32) "a9298896ed1b7335f8f10f7ff6d7a239" iv length=8 -string(32) "736563726574206d6573736167650000" +string(32) "a9298896ed1b7335f8f10f7ff6d7a239" iv length=9 -string(32) "736563726574206d6573736167650000" +string(32) "a9298896ed1b7335f8f10f7ff6d7a239" ===DONE=== diff --git a/ext/mcrypt/tests/mcrypt_ecb_3des_encrypt.phpt b/ext/mcrypt/tests/mcrypt_ecb_3des_encrypt.phpt index 50107b4..7a21df3 100644 --- a/ext/mcrypt/tests/mcrypt_ecb_3des_encrypt.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb_3des_encrypt.phpt @@ -44,7 +44,7 @@ foreach ($keys as $key) { var_dump(bin2hex(mcrypt_ecb($cipher, $key, $data, $mode, $iv))); } -$key = b'1234567890123456'; +$key = b"1234567890123456\0\0\0\0\0\0\0\0"; echo "\n--- testing different iv lengths\n"; foreach ($ivs as $iv) { echo "\niv length=".strlen($iv)."\n"; @@ -58,18 +58,22 @@ foreach ($ivs as $iv) { --- testing different key lengths key length=8 -string(112) "05c9c4cafb9937d950bdae60ee3abcb8d9f3e1f1fac8acaaa5b11d70b7ca02f3b76d447ab3dd85a4b5df5dedb4b4654595ccdf6da97fa93f" + +Warning: mcrypt_ecb(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 -string(112) "0fc7045c4fb4dbcf44baf9ed15ab40331a42ff0632318a16b12ed5873f02e7945e4f63f408d6849534cbb7419c22c8854aaa85e0e05a28e6" + +Warning: mcrypt_ecb(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27" key length=26 -Warning: mcrypt_ecb(): Size of key is too large for this algorithm in %s on line %d -string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27" +Warning: mcrypt_ecb(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths diff --git a/ext/mcrypt/tests/mcrypt_ecb_variation2.phpt b/ext/mcrypt/tests/mcrypt_ecb_variation2.phpt index ed57400..ea3af84 100644 --- a/ext/mcrypt/tests/mcrypt_ecb_variation2.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb_variation2.phpt @@ -126,31 +126,40 @@ fclose($fp); *** Testing mcrypt_ecb() : usage variation *** --int 0-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 1-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 12345-- -string(32) "d74e5f51d1199bcfa61f80168e913007" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int -12345-- -string(32) "17fe485ed735abb34c1dd4455af7b79c" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 10.5-- -string(32) "cd735509aa4013a130e011686d66ae01" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -10.5-- -string(32) "a57d99d6d5813039abf50fc50d631e47" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 12.3456789000e10-- -string(32) "f17ede0bfdaa4408f545f7f4c8b040d2" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -12.3456789000e10-- -string(32) "326f64e3b9bd5a6beb0a9b52a09a5a48" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float .5-- -string(32) "2aedf7661cd4d8c7593f44c58718e2b8" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty array-- Error: 2 - mcrypt_ecb() expects parameter 2 to be string, array given, %s(%d) @@ -169,41 +178,52 @@ Error: 2 - mcrypt_ecb() expects parameter 2 to be string, array given, %s(%d) string(0) "" --uppercase NULL-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase null-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase true-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase false-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase TRUE-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase FALSE-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string DQ-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string SQ-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithToString-- -string(32) "1fd3514d8ced44d04d9dc7511fce33ef" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithoutToString-- Error: 2 - mcrypt_ecb() expects parameter 2 to be string, object given, %s(%d) string(0) "" --undefined var-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --unset var-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_ecb(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --resource-- Error: 2 - mcrypt_ecb() expects parameter 2 to be string, resource given, %s(%d) diff --git a/ext/mcrypt/tests/mcrypt_ecb_variation3.phpt b/ext/mcrypt/tests/mcrypt_ecb_variation3.phpt index 2999304..171468f 100644 --- a/ext/mcrypt/tests/mcrypt_ecb_variation3.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb_variation3.phpt @@ -29,7 +29,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $mode = MCRYPT_ENCRYPT; $iv = b'01234567'; diff --git a/ext/mcrypt/tests/mcrypt_ecb_variation4.phpt b/ext/mcrypt/tests/mcrypt_ecb_variation4.phpt index e52040e..b5c4f29 100644 --- a/ext/mcrypt/tests/mcrypt_ecb_variation4.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb_variation4.phpt @@ -29,7 +29,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $data = b'string_val'; $iv = b'01234567'; diff --git a/ext/mcrypt/tests/mcrypt_ecb_variation5.phpt b/ext/mcrypt/tests/mcrypt_ecb_variation5.phpt index 3f4f7f5..8771b9a 100644 --- a/ext/mcrypt/tests/mcrypt_ecb_variation5.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb_variation5.phpt @@ -29,7 +29,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $data = b'string_val'; $mode = MCRYPT_ENCRYPT; diff --git a/ext/mcrypt/tests/mcrypt_encrypt_3des_cbc.phpt b/ext/mcrypt/tests/mcrypt_encrypt_3des_cbc.phpt index 21b3cee..9c9f926 100644 --- a/ext/mcrypt/tests/mcrypt_encrypt_3des_cbc.phpt +++ b/ext/mcrypt/tests/mcrypt_encrypt_3des_cbc.phpt @@ -49,7 +49,7 @@ foreach ($keys as $key) { var_dump(bin2hex(mcrypt_encrypt($cipher, $key, $data, $mode, $iv))); } -$key = b'1234567890123456'; +$key = b'123456789012345678901234'; echo "\n--- testing different iv lengths\n"; foreach ($ivs as $iv) { echo "\niv length=".strlen($iv)."\n"; @@ -64,18 +64,22 @@ foreach ($ivs as $iv) { --- testing different key lengths key length=8 -string(112) "082b437d039d09418e20dc9de1dafa7ed6da5c6335b78950968441da1faf40c1f886e04da8ca177b80b376811e138c1bf51cb48dae2e7939" + +Warning: mcrypt_encrypt(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 -string(112) "0627351e0f8a082bf7981ae2c700a43fd3d44b270ac67b00fded1c5796eea935be0fef2a23da0b3f5e243929e62ac957bf0bf463aa90fc4f" + +Warning: mcrypt_encrypt(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac" key length=26 -Warning: mcrypt_encrypt(): Size of key is too large for this algorithm in %s on line %d -string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac" +Warning: mcrypt_encrypt(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths @@ -85,7 +89,7 @@ Warning: mcrypt_encrypt(): The IV parameter must be as long as the blocksize in string(0) "" iv length=8 -string(112) "bac347506bf092c5557c4363c301745d78f047028e2953e84fd66b30aeb6005812dadbe8baa871b83278341599b0c448ddaaa52b5a378ce5" +string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac" iv length=9 diff --git a/ext/mcrypt/tests/mcrypt_encrypt_3des_ecb.phpt b/ext/mcrypt/tests/mcrypt_encrypt_3des_ecb.phpt index 1b3188f..0531dcb 100644 --- a/ext/mcrypt/tests/mcrypt_encrypt_3des_ecb.phpt +++ b/ext/mcrypt/tests/mcrypt_encrypt_3des_ecb.phpt @@ -34,7 +34,7 @@ foreach ($keys as $key) { var_dump(bin2hex(mcrypt_encrypt($cipher, $key, $data, $mode))); } -$key = b'12345678'; +$key = b'123456789012345678901234'; $ivs = array( b'1234', b'12345678', @@ -56,27 +56,31 @@ foreach ($ivs as $iv) { --- testing different key lengths key length=8 -string(112) "05c9c4cafb9937d950bdae60ee3abcb8d9f3e1f1fac8acaaa5b11d70b7ca02f3b76d447ab3dd85a4b5df5dedb4b4654595ccdf6da97fa93f" + +Warning: mcrypt_encrypt(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=20 -string(112) "0fc7045c4fb4dbcf44baf9ed15ab40331a42ff0632318a16b12ed5873f02e7945e4f63f408d6849534cbb7419c22c8854aaa85e0e05a28e6" + +Warning: mcrypt_encrypt(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27" key length=26 -Warning: mcrypt_encrypt(): Size of key is too large for this algorithm in %s on line %d -string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27" +Warning: mcrypt_encrypt(): Key of length 26 not supported by this algorithm in %s on line %d +string(0) "" --- testing different iv lengths iv length=4 -string(112) "05c9c4cafb9937d950bdae60ee3abcb8d9f3e1f1fac8acaaa5b11d70b7ca02f3b76d447ab3dd85a4b5df5dedb4b4654595ccdf6da97fa93f" +string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27" iv length=8 -string(112) "05c9c4cafb9937d950bdae60ee3abcb8d9f3e1f1fac8acaaa5b11d70b7ca02f3b76d447ab3dd85a4b5df5dedb4b4654595ccdf6da97fa93f" +string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27" iv length=9 -string(112) "05c9c4cafb9937d950bdae60ee3abcb8d9f3e1f1fac8acaaa5b11d70b7ca02f3b76d447ab3dd85a4b5df5dedb4b4654595ccdf6da97fa93f" +string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27" ===DONE=== diff --git a/ext/mcrypt/tests/mcrypt_encrypt_variation2.phpt b/ext/mcrypt/tests/mcrypt_encrypt_variation2.phpt index 0f4fd0f..286fbea 100644 --- a/ext/mcrypt/tests/mcrypt_encrypt_variation2.phpt +++ b/ext/mcrypt/tests/mcrypt_encrypt_variation2.phpt @@ -124,31 +124,40 @@ fclose($fp); *** Testing mcrypt_encrypt() : usage variation *** --int 0-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 1-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int 12345-- -string(32) "d74e5f51d1199bcfa61f80168e913007" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --int -12345-- -string(32) "17fe485ed735abb34c1dd4455af7b79c" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 10.5-- -string(32) "cd735509aa4013a130e011686d66ae01" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -10.5-- -string(32) "a57d99d6d5813039abf50fc50d631e47" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float 12.3456789000e10-- -string(32) "f17ede0bfdaa4408f545f7f4c8b040d2" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float -12.3456789000e10-- -string(32) "326f64e3b9bd5a6beb0a9b52a09a5a48" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --float .5-- -string(32) "2aedf7661cd4d8c7593f44c58718e2b8" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty array-- Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, array given, %s(%d) @@ -167,41 +176,52 @@ Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, array given, %s(%d string(0) "" --uppercase NULL-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase null-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase true-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --lowercase false-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase TRUE-- -string(32) "e469e6b066f9600e1eefd8f53365f96c" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --uppercase FALSE-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string DQ-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --empty string SQ-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithToString-- -string(32) "1fd3514d8ced44d04d9dc7511fce33ef" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --instance of classWithoutToString-- Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, object given, %s(%d) string(0) "" --undefined var-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --unset var-- -string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3" +Error: 2 - mcrypt_encrypt(): Key of length %d not supported by this algorithm, %s(%d) +string(0) "" --resource-- Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, resource given, %s(%d) diff --git a/ext/mcrypt/tests/mcrypt_encrypt_variation3.phpt b/ext/mcrypt/tests/mcrypt_encrypt_variation3.phpt index c472540..9fb8e7c 100644 --- a/ext/mcrypt/tests/mcrypt_encrypt_variation3.phpt +++ b/ext/mcrypt/tests/mcrypt_encrypt_variation3.phpt @@ -27,7 +27,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $mode = MCRYPT_MODE_ECB; $iv = b'01234567'; diff --git a/ext/mcrypt/tests/mcrypt_encrypt_variation5.phpt b/ext/mcrypt/tests/mcrypt_encrypt_variation5.phpt index 8d1cf86..07c5e15 100644 --- a/ext/mcrypt/tests/mcrypt_encrypt_variation5.phpt +++ b/ext/mcrypt/tests/mcrypt_encrypt_variation5.phpt @@ -27,7 +27,7 @@ set_error_handler('test_error_handler'); // Initialise function arguments not being substituted (if any) $cipher = MCRYPT_TRIPLEDES; -$key = b'string_val'; +$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; $data = b'string_val'; //in php, it incorrectly reports problems with iv in ECB mode. $mode = MCRYPT_MODE_CBC; diff --git a/ext/mcrypt/tests/mcrypt_ofb.phpt b/ext/mcrypt/tests/mcrypt_ofb.phpt index 9420353..5580575 100644 --- a/ext/mcrypt/tests/mcrypt_ofb.phpt +++ b/ext/mcrypt/tests/mcrypt_ofb.phpt @@ -4,7 +4,7 @@ mcrypt_ofb <?php if (!extension_loaded("mcrypt")) print "skip"; ?> --FILE-- <?php -$key = "FooBar"; +$key = "0123456789012345"; $secret = "PHP Testfest 2008"; $cipher = MCRYPT_RIJNDAEL_128; diff --git a/ext/mcrypt/tests/mcrypt_rijndael128_128BitKey.phpt b/ext/mcrypt/tests/mcrypt_rijndael128_128BitKey.phpt index 7a12da8..ee1fcee 100644 --- a/ext/mcrypt/tests/mcrypt_rijndael128_128BitKey.phpt +++ b/ext/mcrypt/tests/mcrypt_rijndael128_128BitKey.phpt @@ -1,5 +1,5 @@ --TEST-- -Test mcrypt_encrypt() function : TripleDES functionality +Test mcrypt_encrypt() function : AES functionality --SKIPIF-- <?php if (!extension_loaded("mcrypt")) { @@ -75,22 +75,34 @@ foreach ($ivs as $iv) { --- testing different key lengths key length=0 -string(128) "4fbf24aaa789f5194260ade1acd9499402c1845cc517e8fe43cfb5b90a0df294db33ecd1a836c47d6bf6d8600512ba415e17008a1e1991f81056258d82099397" + +Warning: mcrypt_encrypt(): Key of length 0 not supported by this algorithm in %s on line %d +string(0) "" Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000" + +Warning: mcrypt_cbc(): Key of length 0 not supported by this algorithm in %s on line %d +string(0) "" key length=0 -string(128) "4fbf24aaa789f5194260ade1acd9499402c1845cc517e8fe43cfb5b90a0df294db33ecd1a836c47d6bf6d8600512ba415e17008a1e1991f81056258d82099397" + +Warning: mcrypt_encrypt(): Key of length 0 not supported by this algorithm in %s on line %d +string(0) "" Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000" + +Warning: mcrypt_cbc(): Key of length 0 not supported by this algorithm in %s on line %d +string(0) "" key length=8 -string(128) "d6a3042b278fa5816dc6f46152acbe5fd7d1813c3808c27cd969d8e10a64d0238724edfda0322f4512308f22d142df0e92bed861c2b732f7650e234df59183dc" + +Warning: mcrypt_encrypt(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d -string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000" + +Warning: mcrypt_cbc(): Key of length 8 not supported by this algorithm in %s on line %d +string(0) "" key length=16 string(128) "dc8f957ec530acf10cd95ba7da7b6405380fe19a2941e9a8de54680512f18491bc374e5464885ae6c2ae2aa7a6cdd2fbe12a06bbc4bd59dbbfaa15f09044f101" diff --git a/ext/mcrypt/tests/mcrypt_rijndael128_256BitKey.phpt b/ext/mcrypt/tests/mcrypt_rijndael128_256BitKey.phpt index f69d369..7f6ad5d 100644 --- a/ext/mcrypt/tests/mcrypt_rijndael128_256BitKey.phpt +++ b/ext/mcrypt/tests/mcrypt_rijndael128_256BitKey.phpt @@ -1,5 +1,5 @@ --TEST-- -Test mcrypt_encrypt() function : TripleDES functionality +Test mcrypt_encrypt() function : AES functionality --SKIPIF-- <?php if (!extension_loaded("mcrypt")) { @@ -62,16 +62,24 @@ foreach ($keys as $key) { --- testing different key lengths key length=20 -string(128) "6369830bfc89a39c9981c9a40e349e3bbc8599c28d7ffbd7a330a67690dac6dfb76a55814e95c83cced68eb1544cdd8406d272c249bd0a60fa5b605d4aefbaa0" -string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000" + +Warning: mcrypt_encrypt(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" + +Warning: mcrypt_decrypt(): Key of length 20 not supported by this algorithm in %s on line %d +string(0) "" key length=24 string(128) "8ecdf1ed5742aff16ef34c819c8d22c707c54f4d9ffc18e5f6ab79fe68c25705351e2c001a0b9f29e5def67570ca9da644efb69a8bb97940cb4bec094dae8bb5" string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000" key length=30 -string(128) "f7731f0c0ab22270b2f516c7837256ed731ba6658ca8f78cda2ab1588e204f990843719ae88474f6572711674fcda9f40d99155e4cc4f5a31aa461ad36a7871d" -string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000" + +Warning: mcrypt_encrypt(): Key of length 30 not supported by this algorithm in %s on line %d +string(0) "" + +Warning: mcrypt_decrypt(): Key of length 30 not supported by this algorithm in %s on line %d +string(0) "" key length=32 string(128) "f23bc103bfd0859a8318acee6d96e5f43dff68f3cdeae817a1e77c33492e32bdb82c5f660fcd1a2bfda70d9de4d5d8028ce179a9e2f7f9ee7dd61c7b4b409e95" @@ -79,9 +87,9 @@ string(128) "546869732069732074686520736563726574206d657373616765207768696368206 key length=40 -Warning: mcrypt_encrypt(): Size of key is too large for this algorithm in %s on line %d -string(128) "f23bc103bfd0859a8318acee6d96e5f43dff68f3cdeae817a1e77c33492e32bdb82c5f660fcd1a2bfda70d9de4d5d8028ce179a9e2f7f9ee7dd61c7b4b409e95" +Warning: mcrypt_encrypt(): Key of length 40 not supported by this algorithm in %s on line %d +string(0) "" -Warning: mcrypt_decrypt(): Size of key is too large for this algorithm in %s on line %d -string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000" -===DONE=== \ No newline at end of file +Warning: mcrypt_decrypt(): Key of length 40 not supported by this algorithm in %s on line %d +string(0) "" +===DONE===