mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
Removed deprecated mcrypt_ecb() etc
This commit is contained in:
parent
c488a45701
commit
7810659cc3
1
NEWS
1
NEWS
@ -104,6 +104,7 @@
|
||||
- Mcrypt:
|
||||
. Fixed possible read after end of buffer and use after free. (Dmitry)
|
||||
. Removed mcrypt_generic_end() alias. (Nikita)
|
||||
. Removed mcrypt_ecb(), mcrypt_cbc(), mcrypt_cfb(), mcrypt_ofb(). (Nikita)
|
||||
|
||||
- Opcache:
|
||||
. Fixed bug with try blocks being removed when extended_info opcode
|
||||
|
@ -362,8 +362,11 @@ Other
|
||||
them consistent with other GMP functions.
|
||||
|
||||
- Mcrypt
|
||||
. Removed deprecate mcrypt_generic_end() alias in favor of
|
||||
. Removed deprecated mcrypt_generic_end() alias in favor of
|
||||
mcrypt_generic_deinit().
|
||||
. Removed deprecated mcrypt_ecb(), mcrypt_cbc(), mcrypt_cfb() and mcrypt_ofb()
|
||||
functions in favor of mcrypt_encrypt() and mcrypt_decrypt() with an
|
||||
MCRYPT_MODE_* flag.
|
||||
|
||||
- Session
|
||||
. session_start() accepts all INI settings as array. e.g. ['cache_limiter'=>'private']
|
||||
|
@ -200,38 +200,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_decrypt, 0, 0, 5)
|
||||
ZEND_ARG_INFO(0, iv)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_ecb, 0, 0, 5)
|
||||
ZEND_ARG_INFO(0, cipher)
|
||||
ZEND_ARG_INFO(0, key)
|
||||
ZEND_ARG_INFO(0, data)
|
||||
ZEND_ARG_INFO(0, mode)
|
||||
ZEND_ARG_INFO(0, iv)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_cbc, 0, 0, 5)
|
||||
ZEND_ARG_INFO(0, cipher)
|
||||
ZEND_ARG_INFO(0, key)
|
||||
ZEND_ARG_INFO(0, data)
|
||||
ZEND_ARG_INFO(0, mode)
|
||||
ZEND_ARG_INFO(0, iv)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_cfb, 0, 0, 5)
|
||||
ZEND_ARG_INFO(0, cipher)
|
||||
ZEND_ARG_INFO(0, key)
|
||||
ZEND_ARG_INFO(0, data)
|
||||
ZEND_ARG_INFO(0, mode)
|
||||
ZEND_ARG_INFO(0, iv)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_ofb, 0, 0, 5)
|
||||
ZEND_ARG_INFO(0, cipher)
|
||||
ZEND_ARG_INFO(0, key)
|
||||
ZEND_ARG_INFO(0, data)
|
||||
ZEND_ARG_INFO(0, mode)
|
||||
ZEND_ARG_INFO(0, iv)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_create_iv, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, size)
|
||||
ZEND_ARG_INFO(0, source)
|
||||
@ -239,10 +207,6 @@ ZEND_END_ARG_INFO()
|
||||
/* }}} */
|
||||
|
||||
const zend_function_entry mcrypt_functions[] = { /* {{{ */
|
||||
PHP_DEP_FE(mcrypt_ecb, arginfo_mcrypt_ecb)
|
||||
PHP_DEP_FE(mcrypt_cbc, arginfo_mcrypt_cbc)
|
||||
PHP_DEP_FE(mcrypt_cfb, arginfo_mcrypt_cfb)
|
||||
PHP_DEP_FE(mcrypt_ofb, arginfo_mcrypt_ofb)
|
||||
PHP_FE(mcrypt_get_key_size, arginfo_mcrypt_get_key_size)
|
||||
PHP_FE(mcrypt_get_block_size, arginfo_mcrypt_get_block_size)
|
||||
PHP_FE(mcrypt_get_cipher_name, arginfo_mcrypt_get_cipher_name)
|
||||
@ -1342,70 +1306,6 @@ PHP_FUNCTION(mcrypt_decrypt)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string mcrypt_ecb(int cipher, string key, string data, int mode, string iv)
|
||||
ECB crypt/decrypt data using key key with cipher cipher starting with iv */
|
||||
PHP_FUNCTION(mcrypt_ecb)
|
||||
{
|
||||
zval *mode;
|
||||
char *cipher, *key, *data, *iv = NULL;
|
||||
size_t cipher_len, key_len, data_len, iv_len = 0;
|
||||
|
||||
MCRYPT_GET_CRYPT_ARGS
|
||||
|
||||
convert_to_long_ex(mode);
|
||||
|
||||
php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "ecb", iv, iv_len, Z_LVAL_P(mode), return_value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string mcrypt_cbc(int cipher, string key, string data, int mode, string iv)
|
||||
CBC crypt/decrypt data using key key with cipher cipher starting with iv */
|
||||
PHP_FUNCTION(mcrypt_cbc)
|
||||
{
|
||||
zval *mode;
|
||||
char *cipher, *key, *data, *iv = NULL;
|
||||
size_t cipher_len, key_len, data_len, iv_len = 0;
|
||||
|
||||
MCRYPT_GET_CRYPT_ARGS
|
||||
|
||||
convert_to_long_ex(mode);
|
||||
|
||||
php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "cbc", iv, iv_len, Z_LVAL_P(mode), return_value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string mcrypt_cfb(int cipher, string key, string data, int mode, string iv)
|
||||
CFB crypt/decrypt data using key key with cipher cipher starting with iv */
|
||||
PHP_FUNCTION(mcrypt_cfb)
|
||||
{
|
||||
zval *mode;
|
||||
char *cipher, *key, *data, *iv = NULL;
|
||||
size_t cipher_len, key_len, data_len, iv_len = 0;
|
||||
|
||||
MCRYPT_GET_CRYPT_ARGS
|
||||
|
||||
convert_to_long_ex(mode);
|
||||
|
||||
php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "cfb", iv, iv_len, Z_LVAL_P(mode), return_value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string mcrypt_ofb(int cipher, string key, string data, int mode, string iv)
|
||||
OFB crypt/decrypt data using key key with cipher cipher starting with iv */
|
||||
PHP_FUNCTION(mcrypt_ofb)
|
||||
{
|
||||
zval *mode;
|
||||
char *cipher, *key, *data, *iv = NULL;
|
||||
size_t cipher_len, key_len, data_len, iv_len = 0;
|
||||
|
||||
MCRYPT_GET_CRYPT_ARGS
|
||||
|
||||
convert_to_long_ex(mode);
|
||||
|
||||
php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "ofb", iv, iv_len, Z_LVAL_P(mode), return_value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string mcrypt_create_iv(int size, int source)
|
||||
Create an initialization vector (IV) */
|
||||
PHP_FUNCTION(mcrypt_create_iv)
|
||||
|
@ -8,24 +8,18 @@ $key = "0123456789012345";
|
||||
$secret = "PHP Testfest 2008";
|
||||
$cipher = MCRYPT_RIJNDAEL_128;
|
||||
|
||||
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_ECB), MCRYPT_RAND);
|
||||
$enc_data = mcrypt_cbc($cipher, $key, $secret, MCRYPT_ENCRYPT, $iv);
|
||||
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_CBC), MCRYPT_RAND);
|
||||
$enc_data = mcrypt_encrypt($cipher, $key, $secret, MCRYPT_MODE_CBC, $iv);
|
||||
|
||||
// we have to trim as AES rounds the blocks and decrypt doesnt detect that
|
||||
echo trim(mcrypt_cbc($cipher, $key, $enc_data, MCRYPT_DECRYPT, $iv)) . "\n";
|
||||
echo trim(mcrypt_decrypt($cipher, $key, $enc_data, MCRYPT_MODE_CBC, $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));
|
||||
var_dump(mcrypt_decrypt($cipher, $key, $enc_data, MCRYPT_MODE_CBC));
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
PHP Testfest 2008
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Encryption mode requires an initialization vector of size 16 in %s on line %d
|
||||
Warning: mcrypt_decrypt(): Encryption mode requires an initialization vector of size 16 in %s on line %d
|
||||
bool(false)
|
||||
|
@ -14,12 +14,8 @@ if (!extension_loaded("mcrypt")) {
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_cbc() : basic functionality ***\n";
|
||||
|
||||
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$data = b"This is the secret message which must be encrypted";
|
||||
$mode = MCRYPT_DECRYPT;
|
||||
|
||||
// tripledes uses keys with exactly 192 bits (24 bytes)
|
||||
$keys = array(
|
||||
@ -51,14 +47,14 @@ $iv = b'12345678';
|
||||
echo "\n--- testing different key lengths\n";
|
||||
for ($i = 0; $i < sizeof($keys); $i++) {
|
||||
echo "\nkey length=".strlen($keys[$i])."\n";
|
||||
special_var_dump(mcrypt_cbc($cipher, $keys[$i], base64_decode($data1[$i]), $mode, $iv));
|
||||
special_var_dump(mcrypt_decrypt($cipher, $keys[$i], base64_decode($data1[$i]), MCRYPT_MODE_CBC, $iv));
|
||||
}
|
||||
|
||||
$key = b'123456789012345678901234';
|
||||
echo "\n--- testing different iv lengths\n";
|
||||
for ($i = 0; $i < sizeof($ivs); $i++) {
|
||||
echo "\niv length=".strlen($ivs[$i])."\n";
|
||||
special_var_dump(mcrypt_cbc($cipher, $key, base64_decode($data2[$i]), $mode, $ivs[$i]));
|
||||
special_var_dump(mcrypt_decrypt($cipher, $key, base64_decode($data2[$i]), MCRYPT_MODE_CBC, $ivs[$i]));
|
||||
}
|
||||
|
||||
function special_var_dump($str) {
|
||||
@ -67,54 +63,38 @@ function special_var_dump($str) {
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_cbc() : basic functionality ***
|
||||
|
||||
--- testing different key lengths
|
||||
|
||||
key length=8
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Key of size 8 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
Warning: mcrypt_decrypt(): Key of size 8 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
key length=20
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Key of size 20 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
Warning: mcrypt_decrypt(): Key of size 20 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
key length=24
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
key length=26
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Key of size 26 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
Warning: mcrypt_decrypt(): Key of size 26 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
--- testing different iv lengths
|
||||
|
||||
iv length=4
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Received initialization vector of size 4, but size 8 is required for this encryption mode in %s on line %d
|
||||
Warning: mcrypt_decrypt(): Received initialization vector of size 4, but size 8 is required for this encryption mode in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
iv length=8
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
string(32) "659ec947f4dc3a3b9c50de744598d3c8"
|
||||
|
||||
iv length=9
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Received initialization vector of size 9, but size 8 is required for this encryption mode in %s on line %d
|
||||
Warning: mcrypt_decrypt(): Received initialization vector of size 9, but size 8 is required for this encryption mode in %s on line %d
|
||||
string(0) ""
|
||||
===DONE===
|
||||
|
@ -14,12 +14,8 @@ if (!extension_loaded("mcrypt")) {
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_cbc() : basic functionality ***\n";
|
||||
|
||||
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$data = b"This is the secret message which must be encrypted";
|
||||
$mode = MCRYPT_ENCRYPT;
|
||||
|
||||
// tripledes uses keys with exactly 192 bits (24 bytes)
|
||||
$keys = array(
|
||||
@ -38,66 +34,50 @@ $iv = b'12345678';
|
||||
echo "\n--- testing different key lengths\n";
|
||||
foreach ($keys as $key) {
|
||||
echo "\nkey length=".strlen($key)."\n";
|
||||
var_dump(bin2hex(mcrypt_cbc($cipher, $key, $data, $mode, $iv)));
|
||||
var_dump(bin2hex(mcrypt_encrypt($cipher, $key, $data, MCRYPT_MODE_CBC, $iv)));
|
||||
}
|
||||
|
||||
$key = b'123456789012345678901234';
|
||||
echo "\n--- testing different iv lengths\n";
|
||||
foreach ($ivs as $iv) {
|
||||
echo "\niv length=".strlen($iv)."\n";
|
||||
var_dump(bin2hex(mcrypt_cbc($cipher, $key, $data, $mode, $iv)));
|
||||
var_dump(bin2hex(mcrypt_encrypt($cipher, $key, $data, MCRYPT_MODE_CBC, $iv)));
|
||||
}
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_cbc() : basic functionality ***
|
||||
|
||||
--- testing different key lengths
|
||||
|
||||
key length=8
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Key of size 8 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
Warning: mcrypt_encrypt(): Key of size 8 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
key length=20
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Key of size 20 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
Warning: mcrypt_encrypt(): Key of size 20 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
key length=24
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac"
|
||||
|
||||
key length=26
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Key of size 26 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
Warning: mcrypt_encrypt(): Key of size 26 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
--- testing different iv lengths
|
||||
|
||||
iv length=4
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Received initialization vector of size 4, but size 8 is required for this encryption mode in %s on line %d
|
||||
Warning: mcrypt_encrypt(): Received initialization vector of size 4, but size 8 is required for this encryption mode in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
iv length=8
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac"
|
||||
|
||||
iv length=9
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Received initialization vector of size 9, but size 8 is required for this encryption mode in %s on line %d
|
||||
Warning: mcrypt_encrypt(): Received initialization vector of size 9, but size 8 is required for this encryption mode in %s on line %d
|
||||
string(0) ""
|
||||
===DONE===
|
||||
|
@ -1,56 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_cbc() function : error conditions
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_cbc(int cipher, string key, string data, int mode, string iv)
|
||||
* Description: CBC crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_cbc() : error conditions ***\n";
|
||||
|
||||
|
||||
//Test mcrypt_cbc with one more than the expected number of arguments
|
||||
echo "\n-- Testing mcrypt_cbc() function with more than expected no. of arguments --\n";
|
||||
$cipher = 10;
|
||||
$key = 'string_val';
|
||||
$data = 'string_val';
|
||||
$mode = 10;
|
||||
$iv = 'string_val';
|
||||
$extra_arg = 10;
|
||||
var_dump( mcrypt_cbc($cipher, $key, $data, $mode, $iv, $extra_arg) );
|
||||
|
||||
// Testing mcrypt_cbc with one less than the expected number of arguments
|
||||
echo "\n-- Testing mcrypt_cbc() function with less than expected no. of arguments --\n";
|
||||
$cipher = 10;
|
||||
$key = 'string_val';
|
||||
$data = 'string_val';
|
||||
var_dump( mcrypt_cbc($cipher, $key, $data) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_cbc() : error conditions ***
|
||||
|
||||
-- Testing mcrypt_cbc() function with more than expected no. of arguments --
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc() expects at most 5 parameters, 6 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing mcrypt_cbc() function with less than expected no. of arguments --
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc() expects at least 4 parameters, 3 given in %s on line %d
|
||||
NULL
|
||||
===DONE===
|
||||
|
@ -1,256 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_cbc() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_cbc(string cipher, string key, string data, int mode, string iv)
|
||||
* Description: CBC crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_cbc() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$key = b'string_val';
|
||||
$data = b'string_val';
|
||||
$mode = MCRYPT_ENCRYPT;
|
||||
$iv = b'string_val';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for cipher
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump( mcrypt_cbc($value, $key, $data, $mode, $iv) );
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_cbc() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 1--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int -12345--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, object given, %s(%d)
|
||||
NULL
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, resource given, %s(%d)
|
||||
NULL
|
||||
===DONE===
|
||||
|
@ -1,255 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_cbc() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_cbc(string cipher, string key, string data, int mode, string iv)
|
||||
* Description: CBC crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_cbc() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$data = b'string_val';
|
||||
$mode = MCRYPT_ENCRYPT;
|
||||
$iv = b'01234567';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return b"Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = b<<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for key
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump(bin2hex(mcrypt_cbc($cipher, $value, $data, $mode, $iv)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_cbc() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int 1--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int 12345--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int -12345--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
@ -1,235 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_cbc() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_cbc(string cipher, string key, string data, int mode, string iv)
|
||||
* Description: CBC crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_cbc() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||
$mode = MCRYPT_ENCRYPT;
|
||||
$iv = b'01234567';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return b"Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = b<<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for data
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump(bin2hex(mcrypt_cbc($cipher, $key, $value, $mode, $iv)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_cbc() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "ce5fcfe737859795"
|
||||
|
||||
--int 1--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "84df495f6cd82dd9"
|
||||
|
||||
--int 12345--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "905ab1ae27ee9991"
|
||||
|
||||
--int -12345--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "5835174e9c67c3e7"
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "28ff0601ad9e47fa"
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "ce9f2b6e2fc3d9f7"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "24eb882ce9763e4018fba9b7f01b0c3e"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5eed30e428f32de1d7a7064d0ed4d3eb"
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "bebf2a13676e1e30"
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "84df495f6cd82dd9"
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "84df495f6cd82dd9"
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "7c91cdf8f8c51485034a9ee528eb016b"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 3 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 3 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
@ -1,231 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_cbc() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_cbc(string cipher, string key, string data, int mode, string iv)
|
||||
* Description: CBC crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_cbc() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$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';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for mode
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump(bin2hex(mcrypt_cbc($cipher, $key, $data, $value, $iv)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_cbc() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--string DQ--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--string SQ--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--mixed case string--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--heredoc--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 8 - Object of class classWithToString could not be converted to int, %s(%d)
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 8 - Object of class classWithoutToString could not be converted to int, %s(%d)
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
===DONE===
|
@ -1,256 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_cbc() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_cbc(string cipher, string key, string data, int mode, string iv)
|
||||
* Description: CBC crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_cbc() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$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;
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return b"Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = b<<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for iv
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump( bin2hex(mcrypt_cbc($cipher, $key, $data, $mode, $value)) );
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_cbc() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int 1--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int 12345--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int -12345--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 5 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
|
||||
Error: 2 - mcrypt_cbc() expects parameter 5 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
|
@ -9,22 +9,16 @@ $secret = "PHP Testfest 2008";
|
||||
$cipher = MCRYPT_RIJNDAEL_128;
|
||||
|
||||
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_CFB), MCRYPT_RAND);
|
||||
$enc_data = mcrypt_cfb($cipher, $key, $secret, MCRYPT_ENCRYPT, $iv);
|
||||
$enc_data = mcrypt_encrypt($cipher, $key, $secret, MCRYPT_MODE_CFB, $iv);
|
||||
|
||||
// we have to trim as AES rounds the blocks and decrypt doesnt detect that
|
||||
echo trim(mcrypt_cfb($cipher, $key, $enc_data, MCRYPT_DECRYPT, $iv)) . "\n";
|
||||
echo trim(mcrypt_decrypt($cipher, $key, $enc_data, MCRYPT_MODE_CFB, $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_cfb($cipher, $key, $enc_data, MCRYPT_DECRYPT));
|
||||
var_dump(mcrypt_decrypt($cipher, $key, $enc_data, MCRYPT_MODE_CFB));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Deprecated: Function mcrypt_cfb() is deprecated in %s on line %d
|
||||
|
||||
Deprecated: Function mcrypt_cfb() is deprecated in %s on line %d
|
||||
PHP Testfest 2008
|
||||
|
||||
Deprecated: Function mcrypt_cfb() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cfb(): Encryption mode requires an initialization vector of size 16 in %s on line %d
|
||||
Warning: mcrypt_decrypt(): Encryption mode requires an initialization vector of size 16 in %s on line %d
|
||||
bool(false)
|
||||
|
@ -9,19 +9,13 @@ $secret = "PHP Testfest 2008";
|
||||
$cipher = MCRYPT_RIJNDAEL_128;
|
||||
|
||||
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_ECB), MCRYPT_RAND);
|
||||
$enc_data = mcrypt_ecb($cipher, $key, $secret, MCRYPT_ENCRYPT, $iv);
|
||||
$enc_data = mcrypt_encrypt($cipher, $key, $secret, MCRYPT_MODE_ECB, $iv);
|
||||
|
||||
// we have to trim as AES rounds the blocks and decrypt doesnt detect that
|
||||
echo trim(mcrypt_ecb($cipher, $key, $enc_data, MCRYPT_DECRYPT, $iv)) . "\n";
|
||||
echo trim(mcrypt_decrypt($cipher, $key, $enc_data, MCRYPT_MODE_ECB, $iv)) . "\n";
|
||||
|
||||
// a warning must be issued if we don't use a IV on a AES cipher, that usually requires an IV
|
||||
mcrypt_ecb($cipher, $key, $enc_data, MCRYPT_DECRYPT);
|
||||
mcrypt_decrypt($cipher, $key, $enc_data, MCRYPT_MODE_ECB);
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Deprecated: Function mcrypt_ecb() is deprecated in %s on line %d
|
||||
|
||||
Deprecated: Function mcrypt_ecb() is deprecated in %s on line %d
|
||||
PHP Testfest 2008
|
||||
|
||||
Deprecated: Function mcrypt_ecb() is deprecated in %s on line %d
|
||||
|
@ -8,7 +8,7 @@ if (!extension_loaded("mcrypt")) {
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
/* Prototype : string mcrypt_ecb(int cipher, string key, string data, int mode, string iv)
|
||||
* Description: ECB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
@ -16,12 +16,8 @@ error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_ecb() : basic functionality ***\n";
|
||||
|
||||
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$data = b"This is the secret message which must be encrypted";
|
||||
$mode = MCRYPT_DECRYPT;
|
||||
|
||||
// tripledes uses keys up to 192 bits (24 bytes)
|
||||
$keys = array(
|
||||
@ -52,14 +48,14 @@ $iv = b'12345678';
|
||||
echo "\n--- testing different key lengths\n";
|
||||
for ($i = 0; $i < sizeof($keys); $i++) {
|
||||
echo "\nkey length=".strlen($keys[$i])."\n";
|
||||
special_var_dump(mcrypt_ecb($cipher, $keys[$i], base64_decode($data1[$i]), $mode, $iv));
|
||||
special_var_dump(mcrypt_decrypt($cipher, $keys[$i], base64_decode($data1[$i]), MCRYPT_MODE_ECB, $iv));
|
||||
}
|
||||
|
||||
$key = b'123456789012345678901234';
|
||||
echo "\n--- testing different iv lengths\n";
|
||||
for ($i = 0; $i < sizeof($ivs); $i++) {
|
||||
echo "\niv length=".strlen($ivs[$i])."\n";
|
||||
special_var_dump(mcrypt_ecb($cipher, $key, base64_decode($data2[$i]), $mode, $ivs[$i]));
|
||||
special_var_dump(mcrypt_decrypt($cipher, $key, base64_decode($data2[$i]), MCRYPT_MODE_ECB, $ivs[$i]));
|
||||
}
|
||||
|
||||
function special_var_dump($str) {
|
||||
@ -68,18 +64,16 @@ function special_var_dump($str) {
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_ecb() : basic functionality ***
|
||||
|
||||
--- testing different key lengths
|
||||
|
||||
key length=8
|
||||
|
||||
Warning: mcrypt_ecb(): Key of size 8 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
Warning: mcrypt_decrypt(): Key of size 8 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
key length=20
|
||||
|
||||
Warning: mcrypt_ecb(): Key of size 20 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
Warning: mcrypt_decrypt(): Key of size 20 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
key length=24
|
||||
@ -87,7 +81,7 @@ string(32) "736563726574206d6573736167650000"
|
||||
|
||||
key length=26
|
||||
|
||||
Warning: mcrypt_ecb(): Key of size 26 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
Warning: mcrypt_decrypt(): Key of size 26 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
--- testing different iv lengths
|
||||
|
@ -8,7 +8,7 @@ if (!extension_loaded("mcrypt")) {
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
/* Prototype : string mcrypt_ecb(int cipher, string key, string data, int mode, string iv)
|
||||
* Description: ECB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
@ -16,12 +16,8 @@ error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_ecb() : basic functionality ***\n";
|
||||
|
||||
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$data = b"This is the secret message which must be encrypted";
|
||||
$mode = MCRYPT_ENCRYPT;
|
||||
|
||||
// tripledes uses keys up to 192 bits (24 bytes)
|
||||
$keys = array(
|
||||
@ -41,30 +37,28 @@ $iv = b'12345678';
|
||||
echo "\n--- testing different key lengths\n";
|
||||
foreach ($keys as $key) {
|
||||
echo "\nkey length=".strlen($key)."\n";
|
||||
var_dump(bin2hex(mcrypt_ecb($cipher, $key, $data, $mode, $iv)));
|
||||
var_dump(bin2hex(mcrypt_encrypt($cipher, $key, $data, MCRYPT_MODE_ECB, $iv)));
|
||||
}
|
||||
|
||||
$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";
|
||||
var_dump(bin2hex(mcrypt_ecb($cipher, $key, $data, $mode, $iv)));
|
||||
var_dump(bin2hex(mcrypt_encrypt($cipher, $key, $data, MCRYPT_MODE_ECB, $iv)));
|
||||
}
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_ecb() : basic functionality ***
|
||||
|
||||
--- testing different key lengths
|
||||
|
||||
key length=8
|
||||
|
||||
Warning: mcrypt_ecb(): Key of size 8 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
Warning: mcrypt_encrypt(): Key of size 8 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
key length=20
|
||||
|
||||
Warning: mcrypt_ecb(): Key of size 20 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
Warning: mcrypt_encrypt(): Key of size 20 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
key length=24
|
||||
@ -72,7 +66,7 @@ string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6a
|
||||
|
||||
key length=26
|
||||
|
||||
Warning: mcrypt_ecb(): Key of size 26 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
Warning: mcrypt_encrypt(): Key of size 26 not supported by this algorithm. Only keys of size 24 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
--- testing different iv lengths
|
||||
|
@ -1,54 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_ecb() function : error conditions
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
|
||||
/* Prototype : string mcrypt_ecb(int cipher, string key, string data, int mode, string iv)
|
||||
* Description: ECB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_ecb() : error conditions ***\n";
|
||||
|
||||
|
||||
//Test mcrypt_ecb with one more than the expected number of arguments
|
||||
echo "\n-- Testing mcrypt_ecb() function with more than expected no. of arguments --\n";
|
||||
$cipher = 10;
|
||||
$key = 'string_val';
|
||||
$data = 'string_val';
|
||||
$mode = 10;
|
||||
$iv = 'string_val';
|
||||
$extra_arg = 10;
|
||||
var_dump( mcrypt_ecb($cipher, $key, $data, $mode, $iv, $extra_arg) );
|
||||
|
||||
// Testing mcrypt_ecb with one less than the expected number of arguments
|
||||
echo "\n-- Testing mcrypt_ecb() function with less than expected no. of arguments --\n";
|
||||
$cipher = 10;
|
||||
$key = 'string_val';
|
||||
$data = 'string_val';
|
||||
var_dump( mcrypt_ecb($cipher, $key, $data) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_ecb() : error conditions ***
|
||||
|
||||
-- Testing mcrypt_ecb() function with more than expected no. of arguments --
|
||||
|
||||
Warning: mcrypt_ecb() expects at most 5 parameters, 6 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing mcrypt_ecb() function with less than expected no. of arguments --
|
||||
|
||||
Warning: mcrypt_ecb() expects at least 4 parameters, 3 given in %s on line %d
|
||||
NULL
|
||||
===DONE===
|
||||
|
@ -1,232 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_ecb() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
|
||||
/* Prototype : string mcrypt_ecb(string cipher, string key, string data, int mode, string iv)
|
||||
* Description: ECB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_ecb() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if ($err_no & error_reporting()) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$key = b'string_val';
|
||||
$data = b'string_val';
|
||||
$mode = MCRYPT_ENCRYPT;
|
||||
$iv = b'string_val';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for cipher
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump( mcrypt_ecb($value, $key, $data, $mode, $iv) );
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_ecb() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 1--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int -12345--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 10.5--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -10.5--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase false--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 1 to be string, object given, %s(%d)
|
||||
NULL
|
||||
|
||||
--undefined var--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
Error: 2 - mcrypt_ecb(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 1 to be string, resource given, %s(%d)
|
||||
NULL
|
||||
===DONE===
|
||||
|
@ -1,232 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_ecb() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
|
||||
/* Prototype : string mcrypt_ecb(string cipher, string key, string data, int mode, string iv)
|
||||
* Description: ECB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_ecb() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if ($err_no & error_reporting()) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$data = b'string_val';
|
||||
$mode = MCRYPT_ENCRYPT;
|
||||
$iv = b'01234567';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return b"Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = b<<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for key
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump(bin2hex(mcrypt_ecb($cipher, $value, $data, $mode, $iv)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_ecb() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int 1--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int 12345--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int -12345--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float 10.5--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float -10.5--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float .5--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase null--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase true--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase false--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty string DQ--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty string SQ--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %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--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--unset var--
|
||||
Error: 2 - mcrypt_ecb(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 2 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
|
@ -1,212 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_ecb() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
|
||||
/* Prototype : string mcrypt_ecb(string cipher, string key, string data, int mode, string iv)
|
||||
* Description: ECB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_ecb() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if ($err_no & error_reporting()) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$key = b"string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||
$mode = MCRYPT_ENCRYPT;
|
||||
$iv = b'01234567';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return b"Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = b<<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for data
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump(bin2hex(mcrypt_ecb($cipher, $key, $value, $mode, $iv)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_ecb() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(16) "51dc9cd9179b718b"
|
||||
|
||||
--int 1--
|
||||
string(16) "619c335f8c4f9cbf"
|
||||
|
||||
--int 12345--
|
||||
string(16) "b1258d67ab73de00"
|
||||
|
||||
--int -12345--
|
||||
string(16) "8eecf134443bd6b9"
|
||||
|
||||
--float 10.5--
|
||||
string(16) "34b5750a793baff5"
|
||||
|
||||
--float -10.5--
|
||||
string(16) "7a605f2aacc8a11d"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
string(32) "74a0d7026ae586f476d4b17808851e86"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
string(32) "bfb155997017986c01090afebd62c7ca"
|
||||
|
||||
--float .5--
|
||||
string(16) "cc60ac201164b6c7"
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--lowercase null--
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--lowercase true--
|
||||
string(16) "619c335f8c4f9cbf"
|
||||
|
||||
--lowercase false--
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--uppercase TRUE--
|
||||
string(16) "619c335f8c4f9cbf"
|
||||
|
||||
--uppercase FALSE--
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--empty string DQ--
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--empty string SQ--
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--instance of classWithToString--
|
||||
string(32) "749c3b4d16731d98370128754b7c930f"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 3 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--unset var--
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 3 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
|
@ -1,207 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_ecb() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
|
||||
/* Prototype : string mcrypt_ecb(string cipher, string key, string data, int mode, string iv)
|
||||
* Description: ECB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_ecb() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if ($err_no & error_reporting()) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$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';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// string data
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for mode
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump(bin2hex(mcrypt_ecb($cipher, $key, $data, $value, $iv)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_ecb() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
string(32) "a80c6cef6b42c8759143586a57bb7dc6"
|
||||
|
||||
--float -10.5--
|
||||
string(32) "a80c6cef6b42c8759143586a57bb7dc6"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
string(32) "a80c6cef6b42c8759143586a57bb7dc6"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
string(32) "a80c6cef6b42c8759143586a57bb7dc6"
|
||||
|
||||
--float .5--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--empty array--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--int indexed array--
|
||||
string(32) "a80c6cef6b42c8759143586a57bb7dc6"
|
||||
|
||||
--associative array--
|
||||
string(32) "a80c6cef6b42c8759143586a57bb7dc6"
|
||||
|
||||
--nested arrays--
|
||||
string(32) "a80c6cef6b42c8759143586a57bb7dc6"
|
||||
|
||||
--uppercase NULL--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--lowercase null--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--lowercase true--
|
||||
string(32) "a80c6cef6b42c8759143586a57bb7dc6"
|
||||
|
||||
--lowercase false--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--uppercase TRUE--
|
||||
string(32) "a80c6cef6b42c8759143586a57bb7dc6"
|
||||
|
||||
--uppercase FALSE--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--empty string DQ--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--empty string SQ--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--string DQ--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--string SQ--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--mixed case string--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--heredoc--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8 - Object of class classWithToString could not be converted to int, %s(%d)
|
||||
string(32) "a80c6cef6b42c8759143586a57bb7dc6"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8 - Object of class classWithoutToString could not be converted to int, %s(%d)
|
||||
string(32) "a80c6cef6b42c8759143586a57bb7dc6"
|
||||
|
||||
--undefined var--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--unset var--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--resource--
|
||||
string(%d) %s
|
||||
===DONE===
|
@ -1,212 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_ecb() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
|
||||
/* Prototype : string mcrypt_ecb(string cipher, string key, string data, int mode, string iv)
|
||||
* Description: ECB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_ecb() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if ($err_no & error_reporting()) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$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;
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return b"Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = b<<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for iv
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump(bin2hex( mcrypt_ecb($cipher, $key, $data, $mode, $value)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_ecb() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--int 1--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--int 12345--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--int -12345--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--float 10.5--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--float -10.5--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--float .5--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--lowercase null--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--lowercase true--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--lowercase false--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--uppercase TRUE--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--uppercase FALSE--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--empty string DQ--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--empty string SQ--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--instance of classWithToString--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 5 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--unset var--
|
||||
string(32) "6438db90653c4d300909aa02fd6163c2"
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 5 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
|
@ -8,20 +8,16 @@ $key = "0123456789012345";
|
||||
$secret = "PHP Testfest 2008";
|
||||
$cipher = MCRYPT_RIJNDAEL_128;
|
||||
|
||||
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_ECB), MCRYPT_RAND);
|
||||
$enc_data = mcrypt_ofb($cipher, $key, $secret, MCRYPT_ENCRYPT, $iv);
|
||||
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_OFB), MCRYPT_RAND);
|
||||
$enc_data = mcrypt_decrypt($cipher, $key, $secret, MCRYPT_MODE_OFB, $iv);
|
||||
|
||||
// we have to trim as AES rounds the blocks and decrypt doesnt detect that
|
||||
echo trim(mcrypt_ofb($cipher, $key, $enc_data, MCRYPT_DECRYPT, $iv)) . "\n";
|
||||
echo trim(mcrypt_decrypt($cipher, $key, $enc_data, MCRYPT_MODE_OFB, $iv)) . "\n";
|
||||
|
||||
// a warning must be issued if we don't use a IV on a AES cipher, that usually requires an IV
|
||||
mcrypt_ofb($cipher, $key, $enc_data, MCRYPT_DECRYPT, $iv);
|
||||
mcrypt_decrypt($cipher, $key, $enc_data, MCRYPT_MODE_OFB);
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Deprecated: Function mcrypt_ofb() is deprecated in %s on line %d
|
||||
|
||||
Deprecated: Function mcrypt_ofb() is deprecated in %s on line %d
|
||||
PHP Testfest 2008
|
||||
|
||||
Deprecated: Function mcrypt_ofb() is deprecated in %s on line %d
|
||||
Warning: mcrypt_decrypt(): Encryption mode requires an initialization vector of size 16 in %s on line %d
|
||||
|
@ -53,16 +53,12 @@ foreach ($keys as $key) {
|
||||
echo "\nkey length=".strlen($key)."\n";
|
||||
$res = mcrypt_encrypt($cipher, $key, $data, MCRYPT_MODE_CBC, $iv);
|
||||
var_dump(bin2hex($res));
|
||||
$res = mcrypt_cbc($cipher, $key, $res, MCRYPT_DECRYPT, $iv);
|
||||
var_dump(bin2hex($res));
|
||||
}
|
||||
|
||||
$key = b'1234567890123456';
|
||||
echo "\n--- testing different iv lengths\n";
|
||||
foreach ($ivs as $iv) {
|
||||
echo "\niv length=".strlen($iv)."\n";
|
||||
$res = mcrypt_cbc($cipher, $key, $data, $mode, $iv);
|
||||
var_dump(bin2hex($res));
|
||||
$res = mcrypt_decrypt($cipher, $key, $res, MCRYPT_MODE_CBC, $iv);
|
||||
var_dump(bin2hex($res));
|
||||
}
|
||||
@ -79,82 +75,41 @@ key length=0
|
||||
Warning: mcrypt_encrypt(): Key of size 0 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Key of size 0 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
key length=0
|
||||
|
||||
Warning: mcrypt_encrypt(): Key of size 0 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Key of size 0 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
key length=8
|
||||
|
||||
Warning: mcrypt_encrypt(): Key of size 8 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Key of size 8 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
key length=16
|
||||
string(128) "dc8f957ec530acf10cd95ba7da7b6405380fe19a2941e9a8de54680512f18491bc374e5464885ae6c2ae2aa7a6cdd2fbe12a06bbc4bd59dbbfaa15f09044f101"
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000"
|
||||
|
||||
--- testing different iv lengths
|
||||
|
||||
iv length=0
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Received initialization vector of size 0, but size 16 is required for this encryption mode in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
Warning: mcrypt_decrypt(): Received initialization vector of size 0, but size 16 is required for this encryption mode in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
iv length=0
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Received initialization vector of size 0, but size 16 is required for this encryption mode in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
Warning: mcrypt_decrypt(): Received initialization vector of size 0, but size 16 is required for this encryption mode in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
iv length=8
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Received initialization vector of size 8, but size 16 is required for this encryption mode in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
Warning: mcrypt_decrypt(): Received initialization vector of size 8, but size 16 is required for this encryption mode in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
iv length=16
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
string(128) "dc8f957ec530acf10cd95ba7da7b6405380fe19a2941e9a8de54680512f18491bc374e5464885ae6c2ae2aa7a6cdd2fbe12a06bbc4bd59dbbfaa15f09044f101"
|
||||
string(128) "546869732069732074686520736563726574206d657373616765207768696368206d75737420626520656e637279707465640000000000000000000000000000"
|
||||
string(32) "42adc8c0db19473f2c684ff2d6e828a5"
|
||||
|
||||
iv length=17
|
||||
|
||||
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
|
||||
|
||||
Warning: mcrypt_cbc(): Received initialization vector of size 17, but size 16 is required for this encryption mode in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
Warning: mcrypt_decrypt(): Received initialization vector of size 17, but size 16 is required for this encryption mode in %s on line %d
|
||||
string(0) ""
|
||||
===DONE===
|
||||
|
Loading…
Reference in New Issue
Block a user