1--TEST-- 2Bug #37595 (mcrypt_generic calculates data length in wrong way) 3--SKIPIF-- 4<?php if (!extension_loaded("mcrypt")) print "skip"; ?> 5--FILE-- 6<?php 7 8$cipher_alg = MCRYPT_BLOWFISH; 9$skey = array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); 10$key=''; 11foreach($skey as $t) { 12 $key .= chr($t); 13 } 14 15$sstr = array(1,2,3,4,5,6,7,8); 16$iv=''; 17foreach($sstr as $s) { 18 $iv .= chr($s); 19} 20 21$str = "12345678"; 22 23$td = mcrypt_module_open(MCRYPT_BLOWFISH,'',MCRYPT_MODE_CBC,''); 24 25$data = Array( 26 '12345678', 27 '123456789', 28 "\x001234567", 29 '', 30 '1234567812345678', 31 '12345678123456789' 32 ); 33 34foreach ($data as $val) { 35 mcrypt_generic_init($td, $key, $iv); 36 $enc = mcrypt_generic($td, $val); 37 38 mcrypt_generic_deinit($td); 39 40 mcrypt_generic_init($td, $key, $iv); 41 var_dump($dec = @mdecrypt_generic($td, $enc)); 42} 43 44mcrypt_module_close($td); 45 46echo "Done\n"; 47?> 48--EXPECTF-- 49Deprecated: Function mcrypt_module_open() is deprecated in %s%ebug37595.php on line 18 50 51Deprecated: Function mcrypt_generic_init() is deprecated in %s%ebug37595.php on line 30 52 53Deprecated: Function mcrypt_generic() is deprecated in %s%ebug37595.php on line 31 54 55Deprecated: Function mcrypt_generic_deinit() is deprecated in %s%ebug37595.php on line 33 56 57Deprecated: Function mcrypt_generic_init() is deprecated in %s%ebug37595.php on line 35 58string(8) "12345678" 59 60Deprecated: Function mcrypt_generic_init() is deprecated in %s%ebug37595.php on line 30 61 62Deprecated: Function mcrypt_generic() is deprecated in %s%ebug37595.php on line 31 63 64Deprecated: Function mcrypt_generic_deinit() is deprecated in %s%ebug37595.php on line 33 65 66Deprecated: Function mcrypt_generic_init() is deprecated in %s%ebug37595.php on line 35 67string(16) "123456789" 68 69Deprecated: Function mcrypt_generic_init() is deprecated in %s%ebug37595.php on line 30 70 71Deprecated: Function mcrypt_generic() is deprecated in %s%ebug37595.php on line 31 72 73Deprecated: Function mcrypt_generic_deinit() is deprecated in %s%ebug37595.php on line 33 74 75Deprecated: Function mcrypt_generic_init() is deprecated in %s%ebug37595.php on line 35 76string(8) "1234567" 77 78Deprecated: Function mcrypt_generic_init() is deprecated in %s%ebug37595.php on line 30 79 80Deprecated: Function mcrypt_generic() is deprecated in %s%ebug37595.php on line 31 81 82Warning: mcrypt_generic(): An empty string was passed in %s%ebug37595.php on line 31 83 84Deprecated: Function mcrypt_generic_deinit() is deprecated in %s%ebug37595.php on line 33 85 86Deprecated: Function mcrypt_generic_init() is deprecated in %s%ebug37595.php on line 35 87bool(false) 88 89Deprecated: Function mcrypt_generic_init() is deprecated in %s%ebug37595.php on line 30 90 91Deprecated: Function mcrypt_generic() is deprecated in %s%ebug37595.php on line 31 92 93Deprecated: Function mcrypt_generic_deinit() is deprecated in %s%ebug37595.php on line 33 94 95Deprecated: Function mcrypt_generic_init() is deprecated in %s%ebug37595.php on line 35 96string(16) "1234567812345678" 97 98Deprecated: Function mcrypt_generic_init() is deprecated in %s%ebug37595.php on line 30 99 100Deprecated: Function mcrypt_generic() is deprecated in %s%ebug37595.php on line 31 101 102Deprecated: Function mcrypt_generic_deinit() is deprecated in %s%ebug37595.php on line 33 103 104Deprecated: Function mcrypt_generic_init() is deprecated in %s%ebug37595.php on line 35 105string(24) "12345678123456789" 106 107Deprecated: Function mcrypt_module_close() is deprecated in %s%ebug37595.php on line 39 108Done 109