]> granicus.if.org Git - php/commitdiff
Abort on invalid key size
authorNikita Popov <nikic@php.net>
Sat, 1 Mar 2014 22:51:03 +0000 (23:51 +0100)
committerNikita Popov <nikic@php.net>
Wed, 5 Mar 2014 14:32:32 +0000 (15:32 +0100)
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.

31 files changed:
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
ext/mcrypt/tests/mcrypt_cbc_variation2.phpt
ext/mcrypt/tests/mcrypt_cbc_variation3.phpt
ext/mcrypt/tests/mcrypt_cbc_variation4.phpt
ext/mcrypt/tests/mcrypt_cbc_variation5.phpt
ext/mcrypt/tests/mcrypt_cfb.phpt
ext/mcrypt/tests/mcrypt_decrypt.phpt
ext/mcrypt/tests/mcrypt_decrypt_3des_cbc.phpt
ext/mcrypt/tests/mcrypt_decrypt_3des_ecb.phpt
ext/mcrypt/tests/mcrypt_decrypt_variation2.phpt
ext/mcrypt/tests/mcrypt_decrypt_variation3.phpt
ext/mcrypt/tests/mcrypt_decrypt_variation5.phpt
ext/mcrypt/tests/mcrypt_ecb.phpt
ext/mcrypt/tests/mcrypt_ecb_3des_decrypt.phpt
ext/mcrypt/tests/mcrypt_ecb_3des_encrypt.phpt
ext/mcrypt/tests/mcrypt_ecb_variation2.phpt
ext/mcrypt/tests/mcrypt_ecb_variation3.phpt
ext/mcrypt/tests/mcrypt_ecb_variation4.phpt
ext/mcrypt/tests/mcrypt_ecb_variation5.phpt
ext/mcrypt/tests/mcrypt_encrypt_3des_cbc.phpt
ext/mcrypt/tests/mcrypt_encrypt_3des_ecb.phpt
ext/mcrypt/tests/mcrypt_encrypt_variation2.phpt
ext/mcrypt/tests/mcrypt_encrypt_variation3.phpt
ext/mcrypt/tests/mcrypt_encrypt_variation5.phpt
ext/mcrypt/tests/mcrypt_ofb.phpt
ext/mcrypt/tests/mcrypt_rijndael128_128BitKey.phpt
ext/mcrypt/tests/mcrypt_rijndael128_256BitKey.phpt

index 889dce397f19f6aba9e6aa9a1b9d402831afc98a..d3dc5c20408093d1a92dc2bb6b946df4d6628620 100644 (file)
@@ -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);
        
index ddb691e362d5f003514048b417f8bc14f6e3721a..1f0fe40a3d757237bc6d7b36724edac8cb3a2021 100644 (file)
@@ -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"
index fb74df93228175510073678dbf7f82c359430f56..cf723e3803258cd5f56c37a961662a69ca46e72f 100644 (file)
@@ -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
index f65123bc429b192b81a4575ffdb77e324fec9a8a..775c153643778aeb083726bf305f512961240c1c 100644 (file)
@@ -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
 
index 962d4091a2f3c86efaba75d46464b23c37fcd7a4..2e8dd5fd50993ba86de165a5cfd59e0c57f4d081 100644 (file)
@@ -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
 
index 3d2a0614722d4f7862854391648b966c481f4372..6a1624127b2b4c6e90d39a3a12031ac44573f014 100644 (file)
@@ -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)
index 9a1464b1122cc68ed5c0f291017bb4eec8861164..f9098a4221b2baf67a4377985b6ca5dd49968968 100644 (file)
@@ -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';
 
index a3dd29ba41b052a154ab7e6790026b2fa49d7930..a13e4ffb7c3cfdc3f9acf46cfc74b06c48ca5d30 100644 (file)
@@ -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';
 
index d3a6d9c12d96a1234a8f8999ae347140b78d9157..24d518d096e482e374b980173212c9045d68b1ef 100644 (file)
@@ -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;
 
index 1c7b9c12ff3a894d0eb6a72b761ff152e280bf13..a82ea46d115f4d345bfb973c62e7ad98e6c96942 100644 (file)
@@ -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;
 
index ebf95cde178a8191505d6c5a2b976b3a771b3e57..f615889f9ae0ae5a00f7618ad4426ef69a69de86 100644 (file)
@@ -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;
index 9c4f30d8ad1702cd53ad60816aef20c7cc819dd4..0a366dc14aa9953ef9a7142a5cb89ce0d4a505ce 100644 (file)
@@ -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
 
index 5f841c1b04384dc6cf6301f5dafa419193a2fd43..a5a0e7279285d3308d4f3c9e16b9442eed7b7764 100644 (file)
@@ -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===
index 85adb9c99fa58dc4219479d091469e3de9cc5fb9..ce907bf696a4f2b26649de9c8771a2c17faff8e6 100644 (file)
@@ -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)
index 50da2605b21d323c352d594628bc6cd57d14c01b..a36f2c7a836b722a650ad78a1c5e3f80e5876ed6 100644 (file)
@@ -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';
 
index aeda9efd0c1e20e0cdd6e14634758626495a5700..60941fed3326c5713047b31985d4e2e5647281b2 100644 (file)
@@ -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;
 
index b6d0a227865abf3bed8721962ba83a511c3dc0c4..7a4bc3aa6a8588ab513917f58012932c5fe1d17b 100644 (file)
@@ -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;
 
index 82f9608da8d1b31a0a4de33961588c66f019f1c0..29772e9a708c75cd2dbc33e44c916e093d858932 100644 (file)
@@ -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===
index 50107b4b0f48b68884da7b6e03b09e3be2d4ec40..7a21df3d0bcc3aa6deeb973553d9604b4c47ddef 100644 (file)
@@ -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
 
index ed57400e0fb912da46389f7359f198df87c09ba3..ea3af842f5310942b5007e4a9160961a615957de 100644 (file)
@@ -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)
index 29993045633e0cb2a112bc6584433ff130ee1278..171468f82fb5543860f4250fdee141871188ce87 100644 (file)
@@ -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';
 
index e52040e29521908620f76a04f83ac64bf0dc84b7..b5c4f294eb52105832037aeae107afafc392ad79 100644 (file)
@@ -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';
 
index 3f4f7f5ddbcdeb5709f0011e799a7a4197528644..8771b9a78c714424ac88aeee38460a8a7d4f57c3 100644 (file)
@@ -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;
 
index 21b3cee63b41100e4deabdd48d4188981e517162..9c9f926167eac58f7a7af89a5b1a3a88073e5fa7 100644 (file)
@@ -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
 
index 1b3188f8e5ceda3aef95e776b1f533a8fe991b1c..0531dcb27a44f567596d5af9d01e073a530d766a 100644 (file)
@@ -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===
index 0f4fd0fe87b3f3e4df42f891936cf0b76e7b2082..286fbea46330100dc2d1d37f5b63cca715529828 100644 (file)
@@ -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)
index c472540640f1038d75d8fcb3728206ff2d750ac7..9fb8e7c550077e3bdc850110f6461a1667b4f39d 100644 (file)
@@ -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';
 
index 8d1cf86ef0b1381a0bb55a32a4d9b24f355056f8..07c5e158cbe18089b155acc6eb10648f57cc5e83 100644 (file)
@@ -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;
index 942035306035a6a06bef49cff5dfbdb44735a43d..5580575a4826c3794b250dd73e0244696f4346a9 100644 (file)
@@ -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;
 
index 7a12da87f0f2cf1f3cb2911d429223a267a55537..ee1fceede515a814052bd1774d29c39596d32bbf 100644 (file)
@@ -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"
index f69d36929403f05a5c0f54aca077f7b3d5795638..7f6ad5ddf401cc97cba41212549cf3e0741e72c3 100644 (file)
@@ -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===