import zend mcrypt tests
Esse commit está contido em:
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
for( $i=1; $i<=64; $i = $i*2 ){
|
||||
echo 'Input: '. $i . PHP_EOL;
|
||||
$random = mcrypt_create_iv( $i, MCRYPT_DEV_URANDOM );
|
||||
echo ' Length: ' . strlen( $random ) . PHP_EOL;
|
||||
echo ' Hex: '. bin2hex( $random ) . PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,27 @@
|
||||
Input: 1
|
||||
Length: 1
|
||||
Hex: %x
|
||||
|
||||
Input: 2
|
||||
Length: 2
|
||||
Hex: %x
|
||||
|
||||
Input: 4
|
||||
Length: 4
|
||||
Hex: %x
|
||||
|
||||
Input: 8
|
||||
Length: 8
|
||||
Hex: %x
|
||||
|
||||
Input: 16
|
||||
Length: 16
|
||||
Hex: %x
|
||||
|
||||
Input: 32
|
||||
Length: 32
|
||||
Hex: %x
|
||||
|
||||
Input: 64
|
||||
Length: 64
|
||||
Hex: %x
|
||||
@@ -0,0 +1,113 @@
|
||||
<?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===
|
||||
@@ -0,0 +1,106 @@
|
||||
*** Testing mcrypt_cbc() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 1--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int -12345--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 10.5--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -10.5--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase false--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, object given, %s(%d)
|
||||
NULL
|
||||
|
||||
--undefined var--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, resource given, %s(%d)
|
||||
NULL
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?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===
|
||||
@@ -0,0 +1,86 @@
|
||||
*** Testing mcrypt_cbc() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(32) "bc27b3a4e33b531d5983fc7df693cd09"
|
||||
|
||||
--int 1--
|
||||
string(32) "bc27b3a4e33b531d5983fc7df693cd09"
|
||||
|
||||
--int 12345--
|
||||
string(32) "d109b7973383127002474ae731c4b3a8"
|
||||
|
||||
--int -12345--
|
||||
string(32) "3e82a931cedb03a38b91a637ff8c9f9e"
|
||||
|
||||
--float 10.5--
|
||||
string(32) "de71833586c1d7132a289960ebeeca7a"
|
||||
|
||||
--float -10.5--
|
||||
string(32) "7d0489dd2e99ae910ecc015573f3dd16"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
string(32) "978055b42c0506a8947e3c3c8d994baf"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
string(32) "4aa84ba400c2b8ef467d4d98372b4f4e"
|
||||
|
||||
--float .5--
|
||||
string(32) "e731dc5059b84e0c8774ac490f77d6e6"
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
|
||||
|
||||
--lowercase null--
|
||||
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
|
||||
|
||||
--lowercase true--
|
||||
string(32) "bc27b3a4e33b531d5983fc7df693cd09"
|
||||
|
||||
--lowercase false--
|
||||
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
|
||||
|
||||
--uppercase TRUE--
|
||||
string(32) "bc27b3a4e33b531d5983fc7df693cd09"
|
||||
|
||||
--uppercase FALSE--
|
||||
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
|
||||
|
||||
--empty string DQ--
|
||||
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
|
||||
|
||||
--empty string SQ--
|
||||
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
|
||||
|
||||
--instance of classWithToString--
|
||||
string(32) "19420fa26f561ee82ed84abbcd2d284b"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
|
||||
|
||||
--unset var--
|
||||
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?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';
|
||||
$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===
|
||||
@@ -0,0 +1,86 @@
|
||||
*** Testing mcrypt_cbc() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(16) "ce5fcfe737859795"
|
||||
|
||||
--int 1--
|
||||
string(16) "84df495f6cd82dd9"
|
||||
|
||||
--int 12345--
|
||||
string(16) "905ab1ae27ee9991"
|
||||
|
||||
--int -12345--
|
||||
string(16) "5835174e9c67c3e7"
|
||||
|
||||
--float 10.5--
|
||||
string(16) "28ff0601ad9e47fa"
|
||||
|
||||
--float -10.5--
|
||||
string(16) "ce9f2b6e2fc3d9f7"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
string(32) "24eb882ce9763e4018fba9b7f01b0c3e"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
string(32) "5eed30e428f32de1d7a7064d0ed4d3eb"
|
||||
|
||||
--float .5--
|
||||
string(16) "bebf2a13676e1e30"
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--lowercase null--
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--lowercase true--
|
||||
string(16) "84df495f6cd82dd9"
|
||||
|
||||
--lowercase false--
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--uppercase TRUE--
|
||||
string(16) "84df495f6cd82dd9"
|
||||
|
||||
--uppercase FALSE--
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--empty string DQ--
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--empty string SQ--
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--instance of classWithToString--
|
||||
string(32) "7c91cdf8f8c51485034a9ee528eb016b"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 3 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--unset var--
|
||||
string(16) "206f6d3617a5ab32"
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 3 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?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';
|
||||
$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===
|
||||
@@ -0,0 +1,106 @@
|
||||
*** Testing mcrypt_cbc() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--int 1--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--int 12345--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--int -12345--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--float 10.5--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--float -10.5--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--float .5--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--lowercase null--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--lowercase true--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--lowercase false--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--empty string DQ--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--empty string SQ--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 5 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--unset var--
|
||||
Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_cbc() expects parameter 5 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* Prototype : string mcrypt_decrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_decrypt() : 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_MODE_ECB;
|
||||
$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_decrypt($value, $key, $data, $mode, $iv) );
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,106 @@
|
||||
*** Testing mcrypt_decrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 1--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int -12345--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 10.5--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -10.5--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase false--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 1 to be string, object given, %s(%d)
|
||||
NULL
|
||||
|
||||
--undefined var--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 1 to be string, resource given, %s(%d)
|
||||
NULL
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* Prototype : string mcrypt_decrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_decrypt() : 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_MODE_ECB;
|
||||
$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_decrypt($cipher, $value, $data, $mode, $iv)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,86 @@
|
||||
*** Testing mcrypt_decrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(32) "43a1ae011df36064589d06bc922ecd97"
|
||||
|
||||
--int 1--
|
||||
string(32) "43a1ae011df36064589d06bc922ecd97"
|
||||
|
||||
--int 12345--
|
||||
string(32) "e5885552e16c44d4eb6164f477b40200"
|
||||
|
||||
--int -12345--
|
||||
string(32) "adf7873831a9035cda9f9dc3b7dc626b"
|
||||
|
||||
--float 10.5--
|
||||
string(32) "08b0b9fac9c227437b7b5d0147e6153b"
|
||||
|
||||
--float -10.5--
|
||||
string(32) "f470cc74d83471b42a3e28d4ec57799a"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
string(32) "36c618c00523fadc372b871eaa9c7b16"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
string(32) "a554a5bdb7a5ceb6ae6f20566ef02e49"
|
||||
|
||||
--float .5--
|
||||
string(32) "bcb840ff76d3788a7911ed36f088a910"
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--lowercase null--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--lowercase true--
|
||||
string(32) "43a1ae011df36064589d06bc922ecd97"
|
||||
|
||||
--lowercase false--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--uppercase TRUE--
|
||||
string(32) "43a1ae011df36064589d06bc922ecd97"
|
||||
|
||||
--uppercase FALSE--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--empty string DQ--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--empty string SQ--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--instance of classWithToString--
|
||||
string(32) "478f9d080563835cc3136610802f1433"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--unset var--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* Prototype : string mcrypt_decrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_decrypt() : 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';
|
||||
$mode = MCRYPT_MODE_ECB;
|
||||
$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_decrypt($cipher, $key, $value, $mode, $iv)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,86 @@
|
||||
*** Testing mcrypt_decrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(16) "52833a00168e547f"
|
||||
|
||||
--int 1--
|
||||
string(16) "82011a0a93098a13"
|
||||
|
||||
--int 12345--
|
||||
string(16) "e8b71c21b6acc162"
|
||||
|
||||
--int -12345--
|
||||
string(16) "db3c458e975563a8"
|
||||
|
||||
--float 10.5--
|
||||
string(16) "6ee8764562f25913"
|
||||
|
||||
--float -10.5--
|
||||
string(16) "d63b39fd5f65678e"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
string(32) "7712cc4828221be40672239d9c32e742"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
string(32) "caa892cb5d28b53c2b75b1e0799427c3"
|
||||
|
||||
--float .5--
|
||||
string(16) "99880c86884385d9"
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--lowercase null--
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--lowercase true--
|
||||
string(16) "82011a0a93098a13"
|
||||
|
||||
--lowercase false--
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--uppercase TRUE--
|
||||
string(16) "82011a0a93098a13"
|
||||
|
||||
--uppercase FALSE--
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--empty string DQ--
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--empty string SQ--
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--instance of classWithToString--
|
||||
string(32) "46677e368bc07ef375bd580e0c4b2594"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 3 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--unset var--
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 3 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* Prototype : string mcrypt_decrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_decrypt() : 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';
|
||||
$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(
|
||||
|
||||
// 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 mode
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump( mcrypt_decrypt($cipher, $key, $data, $value, $iv) );
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,112 @@
|
||||
*** Testing mcrypt_decrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 1--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int -12345--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 10.5--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -10.5--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty array--
|
||||
Error: 8 - Array to string conversion, %s(%d)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
Error: 8 - Array to string conversion, %s(%d)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
Error: 8 - Array to string conversion, %s(%d)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
Error: 8 - Array to string conversion, %s(%d)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase false--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 4096 - Object of class classWithoutToString could not be converted to string, %s(%d)
|
||||
Error: 8 - Object of class classWithoutToString to string conversion, %s(%d)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* Prototype : string mcrypt_decrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_decrypt() : 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';
|
||||
$data = b'string_val';
|
||||
$mode = MCRYPT_MODE_CBC;
|
||||
|
||||
//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_decrypt($cipher, $key, $data, $mode, $value)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,106 @@
|
||||
*** Testing mcrypt_decrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--int 1--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--int 12345--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--int -12345--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--float 10.5--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--float -10.5--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--float .5--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--lowercase null--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--lowercase true--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--lowercase false--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--empty string DQ--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--empty string SQ--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 5 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--unset var--
|
||||
Error: 2 - mcrypt_decrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "a80c6cef6b42c875e2372a0339dc22b0"
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 5 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* 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 (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_ecb($value, $key, $data, $mode, $iv) );
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,106 @@
|
||||
*** 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===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* 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 (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_ecb($cipher, $value, $data, $mode, $iv)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,86 @@
|
||||
*** Testing mcrypt_ecb() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(32) "e469e6b066f9600e1eefd8f53365f96c"
|
||||
|
||||
--int 1--
|
||||
string(32) "e469e6b066f9600e1eefd8f53365f96c"
|
||||
|
||||
--int 12345--
|
||||
string(32) "d74e5f51d1199bcfa61f80168e913007"
|
||||
|
||||
--int -12345--
|
||||
string(32) "17fe485ed735abb34c1dd4455af7b79c"
|
||||
|
||||
--float 10.5--
|
||||
string(32) "cd735509aa4013a130e011686d66ae01"
|
||||
|
||||
--float -10.5--
|
||||
string(32) "a57d99d6d5813039abf50fc50d631e47"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
string(32) "f17ede0bfdaa4408f545f7f4c8b040d2"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
string(32) "326f64e3b9bd5a6beb0a9b52a09a5a48"
|
||||
|
||||
--float .5--
|
||||
string(32) "2aedf7661cd4d8c7593f44c58718e2b8"
|
||||
|
||||
--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--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--lowercase null--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--lowercase true--
|
||||
string(32) "e469e6b066f9600e1eefd8f53365f96c"
|
||||
|
||||
--lowercase false--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--uppercase TRUE--
|
||||
string(32) "e469e6b066f9600e1eefd8f53365f96c"
|
||||
|
||||
--uppercase FALSE--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--empty string DQ--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--empty string SQ--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--instance of classWithToString--
|
||||
string(32) "1fd3514d8ced44d04d9dc7511fce33ef"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 2 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--unset var--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_ecb() expects parameter 2 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* 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 (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';
|
||||
$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===
|
||||
@@ -0,0 +1,86 @@
|
||||
*** 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===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* 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 (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';
|
||||
$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===
|
||||
@@ -0,0 +1,86 @@
|
||||
*** 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===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* Prototype : string mcrypt_encrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_encrypt() : 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_MODE_ECB;
|
||||
$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_encrypt($value, $key, $data, $mode, $iv) );
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,106 @@
|
||||
*** Testing mcrypt_encrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 1--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int -12345--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 10.5--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -10.5--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase false--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 1 to be string, object given, %s(%d)
|
||||
NULL
|
||||
|
||||
--undefined var--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 1 to be string, resource given, %s(%d)
|
||||
NULL
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* Prototype : string mcrypt_encrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_encrypt() : 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_MODE_ECB;
|
||||
$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_encrypt($cipher, $value, $data, $mode, $iv) ));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,86 @@
|
||||
*** Testing mcrypt_encrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(32) "e469e6b066f9600e1eefd8f53365f96c"
|
||||
|
||||
--int 1--
|
||||
string(32) "e469e6b066f9600e1eefd8f53365f96c"
|
||||
|
||||
--int 12345--
|
||||
string(32) "d74e5f51d1199bcfa61f80168e913007"
|
||||
|
||||
--int -12345--
|
||||
string(32) "17fe485ed735abb34c1dd4455af7b79c"
|
||||
|
||||
--float 10.5--
|
||||
string(32) "cd735509aa4013a130e011686d66ae01"
|
||||
|
||||
--float -10.5--
|
||||
string(32) "a57d99d6d5813039abf50fc50d631e47"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
string(32) "f17ede0bfdaa4408f545f7f4c8b040d2"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
string(32) "326f64e3b9bd5a6beb0a9b52a09a5a48"
|
||||
|
||||
--float .5--
|
||||
string(32) "2aedf7661cd4d8c7593f44c58718e2b8"
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--lowercase null--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--lowercase true--
|
||||
string(32) "e469e6b066f9600e1eefd8f53365f96c"
|
||||
|
||||
--lowercase false--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--uppercase TRUE--
|
||||
string(32) "e469e6b066f9600e1eefd8f53365f96c"
|
||||
|
||||
--uppercase FALSE--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--empty string DQ--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--empty string SQ--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--instance of classWithToString--
|
||||
string(32) "1fd3514d8ced44d04d9dc7511fce33ef"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--unset var--
|
||||
string(32) "bfa2cb7240c8d2f6abeb34960c04f6d3"
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* Prototype : string mcrypt_encrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_encrypt() : 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';
|
||||
$mode = MCRYPT_MODE_ECB;
|
||||
$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_encrypt($cipher, $key, $value, $mode, $iv) ));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,86 @@
|
||||
*** Testing mcrypt_encrypt() : 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_encrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_encrypt() 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_encrypt() 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_encrypt() expects parameter 3 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* Prototype : string mcrypt_encrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_encrypt() : 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';
|
||||
$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(
|
||||
|
||||
// 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 mode
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump( mcrypt_encrypt($cipher, $key, $data, $value, $iv) );
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,112 @@
|
||||
*** Testing mcrypt_encrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 1--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int -12345--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 10.5--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -10.5--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty array--
|
||||
Error: 8 - Array to string conversion, %s(%d)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int indexed array--
|
||||
Error: 8 - Array to string conversion, %s(%d)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--associative array--
|
||||
Error: 8 - Array to string conversion, %s(%d)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--nested arrays--
|
||||
Error: 8 - Array to string conversion, %s(%d)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase false--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 4096 - Object of class classWithoutToString could not be converted to string, %s(%d)
|
||||
Error: 8 - Object of class classWithoutToString to string conversion, %s(%d)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/* Prototype : string mcrypt_encrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_encrypt() : 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';
|
||||
$data = b'string_val';
|
||||
//in php, it incorrectly reports problems with iv in ECB mode.
|
||||
$mode = MCRYPT_MODE_CBC;
|
||||
|
||||
//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_encrypt($cipher, $key, $data, $mode, $value)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,106 @@
|
||||
*** Testing mcrypt_encrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--int 1--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--int 12345--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--int -12345--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--float 10.5--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--float -10.5--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--float .5--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--empty array--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--lowercase null--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--lowercase true--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--lowercase false--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--empty string DQ--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--empty string SQ--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 5 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--unset var--
|
||||
Error: 2 - mcrypt_encrypt(): The IV parameter must be as long as the blocksize, %s(%d)
|
||||
string(32) "6438db90653c4d3080c3ceab43618c05"
|
||||
|
||||
--resource--
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 5 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
foreach (stream_get_filters() as $f) {
|
||||
if ($f == "mcrypt.*" || $f == "mdecrypt.*") {
|
||||
echo "FOUND\n";
|
||||
}
|
||||
}
|
||||
|
||||
$secretfile = 'secert-file.tmp';
|
||||
$passphrase = 'My secret';
|
||||
|
||||
$iv = substr(md5('iv'.$passphrase, true), 0, 8);
|
||||
$key = substr(md5('pass1'.$passphrase, true) .
|
||||
md5('pass2'.$passphrase, true), 0, 24);
|
||||
$opts = array('iv'=>$iv, 'key'=>$key);
|
||||
|
||||
$fp = fopen($secretfile, 'wb');
|
||||
stream_filter_append($fp, 'mcrypt.tripledes', STREAM_FILTER_WRITE, $opts);
|
||||
fwrite($fp, 'Secret secret secret data');
|
||||
fclose($fp);
|
||||
|
||||
echo md5_file($secretfile)."\n";
|
||||
|
||||
$fp = fopen($secretfile, 'rb');
|
||||
stream_filter_append($fp, 'mdecrypt.tripledes', STREAM_FILTER_READ, $opts);
|
||||
$data = stream_get_contents($fp);
|
||||
fclose($fp);
|
||||
|
||||
echo $data."\n";
|
||||
|
||||
@unlink($secretfile);
|
||||
@@ -0,0 +1,4 @@
|
||||
FOUND
|
||||
FOUND
|
||||
32e14bd3c31f2bd666e4290ebdb166a7
|
||||
Secret secret secret data
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
var_dump(mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, ''));
|
||||
mcrypt_module_open('', '', '', '');
|
||||
@@ -0,0 +1,2 @@
|
||||
resource(%d) of type (mcrypt)
|
||||
HipHop Warning: %a
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
if(!function_exists("hex2bin")) {
|
||||
function hex2bin($data) {
|
||||
$len = strlen($data);
|
||||
return pack("H" . $len, $data);
|
||||
}
|
||||
}
|
||||
|
||||
print "key plain crypt guess stat\n";
|
||||
$null = "\0\0\0\0\0\0\0\0";
|
||||
$vectors = file(dirname(__FILE__) . "/vectors.txt");
|
||||
|
||||
$td = mcrypt_module_open ("blowfish", "", MCRYPT_MODE_ECB, "");
|
||||
|
||||
foreach($vectors as $data) {
|
||||
$data = trim($data);
|
||||
if ($data) {
|
||||
list($key,$plain,$crypt) = preg_split("/[[:space:]]+/",$data);
|
||||
printf("%s %s ",
|
||||
$key,
|
||||
$plain
|
||||
);
|
||||
$key = hex2bin(trim($key));
|
||||
$plain = hex2bin(($plain));
|
||||
$crypt = strtolower(trim($crypt));
|
||||
|
||||
mcrypt_generic_init ($td, $key, $null);
|
||||
$guess = mcrypt_generic ($td, $plain);
|
||||
$guess = bin2hex($guess);
|
||||
printf("%s %s %s\n",
|
||||
$crypt,
|
||||
$guess,
|
||||
($crypt==$guess ? "OK" : "BAD")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Longer test case from http://www.schneier.com/code/vectors.txt
|
||||
$td = mcrypt_module_open ("blowfish", "", MCRYPT_MODE_CBC, "");
|
||||
|
||||
$key = hex2bin( "0123456789ABCDEFF0E1D2C3B4A59687" );
|
||||
$iv = hex2bin( "FEDCBA9876543210" );
|
||||
$plain = hex2bin( "37363534333231204E6F77206973207468652074696D6520666F722000" );
|
||||
|
||||
mcrypt_generic_init( $td, $key, $iv );
|
||||
$guess = bin2hex( mcrypt_generic( $td, $plain ) );
|
||||
|
||||
echo "\n", $guess, "\n";
|
||||
?>
|
||||
@@ -0,0 +1,36 @@
|
||||
key plain crypt guess stat
|
||||
0000000000000000 0000000000000000 4ef997456198dd78 4ef997456198dd78 OK
|
||||
FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF 51866fd5b85ecb8a 51866fd5b85ecb8a OK
|
||||
3000000000000000 1000000000000001 7d856f9a613063f2 7d856f9a613063f2 OK
|
||||
1111111111111111 1111111111111111 2466dd878b963c9d 2466dd878b963c9d OK
|
||||
0123456789ABCDEF 1111111111111111 61f9c3802281b096 61f9c3802281b096 OK
|
||||
1111111111111111 0123456789ABCDEF 7d0cc630afda1ec7 7d0cc630afda1ec7 OK
|
||||
FEDCBA9876543210 0123456789ABCDEF 0aceab0fc6a0a28d 0aceab0fc6a0a28d OK
|
||||
7CA110454A1A6E57 01A1D6D039776742 59c68245eb05282b 59c68245eb05282b OK
|
||||
0131D9619DC1376E 5CD54CA83DEF57DA b1b8cc0b250f09a0 b1b8cc0b250f09a0 OK
|
||||
07A1133E4A0B2686 0248D43806F67172 1730e5778bea1da4 1730e5778bea1da4 OK
|
||||
3849674C2602319E 51454B582DDF440A a25e7856cf2651eb a25e7856cf2651eb OK
|
||||
04B915BA43FEB5B6 42FD443059577FA2 353882b109ce8f1a 353882b109ce8f1a OK
|
||||
0113B970FD34F2CE 059B5E0851CF143A 48f4d0884c379918 48f4d0884c379918 OK
|
||||
0170F175468FB5E6 0756D8E0774761D2 432193b78951fc98 432193b78951fc98 OK
|
||||
43297FAD38E373FE 762514B829BF486A 13f04154d69d1ae5 13f04154d69d1ae5 OK
|
||||
07A7137045DA2A16 3BDD119049372802 2eedda93ffd39c79 2eedda93ffd39c79 OK
|
||||
04689104C2FD3B2F 26955F6835AF609A d887e0393c2da6e3 d887e0393c2da6e3 OK
|
||||
37D06BB516CB7546 164D5E404F275232 5f99d04f5b163969 5f99d04f5b163969 OK
|
||||
1F08260D1AC2465E 6B056E18759F5CCA 4a057a3b24d3977b 4a057a3b24d3977b OK
|
||||
584023641ABA6176 004BD6EF09176062 452031c1e4fada8e 452031c1e4fada8e OK
|
||||
025816164629B007 480D39006EE762F2 7555ae39f59b87bd 7555ae39f59b87bd OK
|
||||
49793EBC79B3258F 437540C8698F3CFA 53c55f9cb49fc019 53c55f9cb49fc019 OK
|
||||
4FB05E1515AB73A7 072D43A077075292 7a8e7bfa937e89a3 7a8e7bfa937e89a3 OK
|
||||
49E95D6D4CA229BF 02FE55778117F12A cf9c5d7a4986adb5 cf9c5d7a4986adb5 OK
|
||||
018310DC409B26D6 1D9D5C5018F728C2 d1abb290658bc778 d1abb290658bc778 OK
|
||||
1C587F1C13924FEF 305532286D6F295A 55cb3774d13ef201 55cb3774d13ef201 OK
|
||||
0101010101010101 0123456789ABCDEF fa34ec4847b268b2 fa34ec4847b268b2 OK
|
||||
1F1F1F1F0E0E0E0E 0123456789ABCDEF a790795108ea3cae a790795108ea3cae OK
|
||||
E0FEE0FEF1FEF1FE 0123456789ABCDEF c39e072d9fac631d c39e072d9fac631d OK
|
||||
0000000000000000 FFFFFFFFFFFFFFFF 014933e0cdaff6e4 014933e0cdaff6e4 OK
|
||||
FFFFFFFFFFFFFFFF 0000000000000000 f21e9a77b71c49bc f21e9a77b71c49bc OK
|
||||
0123456789ABCDEF 0000000000000000 245946885754369a 245946885754369a OK
|
||||
FEDCBA9876543210 FFFFFFFFFFFFFFFF 6b5c5a9c5d9e0a5a 6b5c5a9c5d9e0a5a OK
|
||||
|
||||
6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
$td = mcrypt_module_open('rijndael-256', '', 'ofb', '');
|
||||
mcrypt_generic($td, "foobar");
|
||||
mdecrypt_generic($td, "baz");
|
||||
?>
|
||||
@@ -0,0 +1,2 @@
|
||||
HipHop Warning: %a
|
||||
HipHop Warning: %a
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
$cipher_alg = MCRYPT_BLOWFISH;
|
||||
$skey = array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
|
||||
$key='';
|
||||
foreach($skey as $t) {
|
||||
$key .= chr($t);
|
||||
}
|
||||
|
||||
$sstr = array(1,2,3,4,5,6,7,8);
|
||||
$iv='';
|
||||
foreach($sstr as $s) {
|
||||
$iv .= chr($s);
|
||||
}
|
||||
|
||||
$str = "12345678";
|
||||
|
||||
$td = mcrypt_module_open(MCRYPT_BLOWFISH,'',MCRYPT_MODE_CBC,'');
|
||||
|
||||
$data = Array(
|
||||
'12345678',
|
||||
'123456789',
|
||||
"\x001234567",
|
||||
'',
|
||||
'1234567812345678',
|
||||
'12345678123456789'
|
||||
);
|
||||
|
||||
foreach ($data as $val) {
|
||||
mcrypt_generic_init($td, $key, $iv);
|
||||
$enc = mcrypt_generic($td, $val);
|
||||
|
||||
mcrypt_generic_deinit($td);
|
||||
|
||||
mcrypt_generic_init($td, $key, $iv);
|
||||
var_dump($dec = @mdecrypt_generic($td, $enc));
|
||||
}
|
||||
|
||||
mcrypt_module_close($td);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
Arquivo binário não exibido.
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
$td = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_ECB, '');
|
||||
echo mcrypt_generic($td,'aaaaaaaa');
|
||||
print "I'm alive!\n";
|
||||
?>
|
||||
@@ -0,0 +1,2 @@
|
||||
HipHop Warning: %a
|
||||
I'm alive!
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
echo "ECB\n";
|
||||
$input = 'to be encrypted';
|
||||
$mkey = hash('sha256', 'secret key', TRUE);
|
||||
$data = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $mkey, $input, MCRYPT_MODE_ECB);
|
||||
echo "CFB\n";
|
||||
$input = 'to be encrypted';
|
||||
$mkey = hash('sha256', 'secret key', TRUE);
|
||||
$data = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $mkey, $input, MCRYPT_MODE_CFB);
|
||||
echo "END\n";
|
||||
?>
|
||||
@@ -0,0 +1,4 @@
|
||||
ECB
|
||||
CFB
|
||||
HipHop Warning: %a
|
||||
END
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, "key", "data", MCRYPT_MODE_ECB)));
|
||||
var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, "key", "data", MCRYPT_MODE_ECB, "a")));
|
||||
var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, "key", "data", MCRYPT_MODE_ECB, "12345678")));
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,3 @@
|
||||
string(16) "372eeb4a524b8d31"
|
||||
string(16) "372eeb4a524b8d31"
|
||||
string(16) "372eeb4a524b8d31"
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$td = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_ECB, '');
|
||||
mcrypt_generic_init($td, 'aaaaaaaa', 'aaaaaaaa');
|
||||
mcrypt_generic_deinit($td);
|
||||
echo mcrypt_generic($td, 'aaaaaaaa');
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
HipHop Warning: %a
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
error_reporting (E_ALL ^ E_NOTICE);
|
||||
echo MCRYPT_TWOFISH."\n";
|
||||
echo MCRYPT_MODE_CBC."\n";
|
||||
|
||||
define ("MODE1", MCRYPT_MODE_CBC);
|
||||
echo MODE1."\n";
|
||||
|
||||
define ("CIPHER", MCRYPT_TWOFISH);
|
||||
define ("MODE2", MCRYPT_MODE_CBC);
|
||||
define ("MODE3", MCRYPT_CBC);
|
||||
|
||||
printf ("cipher=".CIPHER. " mode1=".MODE2. " mode2=". MODE3."\n");
|
||||
?>
|
||||
@@ -0,0 +1,4 @@
|
||||
twofish
|
||||
cbc
|
||||
cbc
|
||||
cipher=twofish mode1=cbc mode2=MCRYPT_CBC
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
$key = "FooBar";
|
||||
$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);
|
||||
|
||||
// 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";
|
||||
|
||||
// a warning must be issued if we don't use a IV on a AES cipher, that usually requires an IV
|
||||
mcrypt_cbc($cipher, $key, $enc_data, MCRYPT_DECRYPT);
|
||||
@@ -0,0 +1,2 @@
|
||||
PHP Testfest 2008
|
||||
HipHop Warning: %a
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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() : basic functionality ***\n";
|
||||
|
||||
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$data = b"This is the secret message which must be encrypted";
|
||||
$mode = MCRYPT_DECRYPT;
|
||||
|
||||
// tripledes uses keys upto 192 bits (24 bytes)
|
||||
$keys = array(
|
||||
b'12345678',
|
||||
b'12345678901234567890',
|
||||
b'123456789012345678901234',
|
||||
b'12345678901234567890123456'
|
||||
);
|
||||
$data1 = array(
|
||||
'IleMhoxiOthmHua4tFBHOw==',
|
||||
'EeF1s6C+w1IiHj1gdDn81g==',
|
||||
'EEuXpjZPueyYoG0LGQ199Q==',
|
||||
'EEuXpjZPueyYoG0LGQ199Q=='
|
||||
);
|
||||
// tripledes is a block cipher of 64 bits (8 bytes)
|
||||
$ivs = array(
|
||||
b'1234',
|
||||
b'12345678',
|
||||
b'123456789'
|
||||
);
|
||||
// data represented in base64 (ascii)
|
||||
$data2 = array(
|
||||
'+G7nGcWIxij3TZjpI9lJdQ==',
|
||||
'3bJiFMeyScxOLQcE6mZtLg==',
|
||||
'+G7nGcWIxij3TZjpI9lJdQ=='
|
||||
);
|
||||
|
||||
$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));
|
||||
}
|
||||
|
||||
$key = b'1234567890123456';
|
||||
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]));
|
||||
}
|
||||
|
||||
function special_var_dump($str) {
|
||||
var_dump(bin2hex($str));
|
||||
}
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,30 @@
|
||||
*** Testing mcrypt_cbc() : basic functionality ***
|
||||
|
||||
--- testing different key lengths
|
||||
|
||||
key length=8
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
key length=20
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
key length=24
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
key length=26
|
||||
HipHop Warning: %a
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
--- testing different iv lengths
|
||||
|
||||
iv length=4
|
||||
HipHop Warning: %a
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
iv length=8
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
iv length=9
|
||||
HipHop Warning: %a
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
===DONE===
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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() : basic functionality ***\n";
|
||||
|
||||
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$data = b"This is the secret message which must be encrypted";
|
||||
$mode = MCRYPT_ENCRYPT;
|
||||
|
||||
// tripledes uses keys upto 192 bits (24 bytes)
|
||||
$keys = array(
|
||||
b'12345678',
|
||||
b'12345678901234567890',
|
||||
b'123456789012345678901234',
|
||||
b'12345678901234567890123456');
|
||||
// tripledes is a block cipher of 64 bits (8 bytes)
|
||||
$ivs = array(
|
||||
b'1234',
|
||||
b'12345678',
|
||||
b'123456789');
|
||||
|
||||
|
||||
$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)));
|
||||
}
|
||||
|
||||
$key = b'1234567890123456';
|
||||
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)));
|
||||
}
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,30 @@
|
||||
*** Testing mcrypt_cbc() : basic functionality ***
|
||||
|
||||
--- testing different key lengths
|
||||
|
||||
key length=8
|
||||
string(112) "082b437d039d09418e20dc9de1dafa7ed6da5c6335b78950968441da1faf40c1f886e04da8ca177b80b376811e138c1bf51cb48dae2e7939"
|
||||
|
||||
key length=20
|
||||
string(112) "0627351e0f8a082bf7981ae2c700a43fd3d44b270ac67b00fded1c5796eea935be0fef2a23da0b3f5e243929e62ac957bf0bf463aa90fc4f"
|
||||
|
||||
key length=24
|
||||
string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac"
|
||||
|
||||
key length=26
|
||||
HipHop Warning: %a
|
||||
string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac"
|
||||
|
||||
--- testing different iv lengths
|
||||
|
||||
iv length=4
|
||||
HipHop Warning: %a
|
||||
string(112) "440a6f54601969b127aad3c217ce7583c7f7b29989693130645569301db0020b29a34a3dcd104b2d0e3ba19d6cbd8a33d352b9c27cc34ef1"
|
||||
|
||||
iv length=8
|
||||
string(112) "bac347506bf092c5557c4363c301745d78f047028e2953e84fd66b30aeb6005812dadbe8baa871b83278341599b0c448ddaaa52b5a378ce5"
|
||||
|
||||
iv length=9
|
||||
HipHop Warning: %a
|
||||
string(112) "440a6f54601969b127aad3c217ce7583c7f7b29989693130645569301db0020b29a34a3dcd104b2d0e3ba19d6cbd8a33d352b9c27cc34ef1"
|
||||
===DONE===
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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===
|
||||
@@ -0,0 +1,10 @@
|
||||
*** Testing mcrypt_cbc() : error conditions ***
|
||||
|
||||
-- Testing mcrypt_cbc() function with more than expected no. of arguments --
|
||||
HipHop Warning: %a
|
||||
NULL
|
||||
|
||||
-- Testing mcrypt_cbc() function with less than expected no. of arguments --
|
||||
HipHop Warning: %a
|
||||
NULL
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?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';
|
||||
$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===
|
||||
@@ -0,0 +1,82 @@
|
||||
*** Testing mcrypt_cbc() : usage variation ***
|
||||
|
||||
--float 10.5--
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--float -10.5--
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--float .5--
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--empty array--
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--int indexed array--
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--associative array--
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--nested arrays--
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--uppercase NULL--
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--lowercase null--
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--lowercase true--
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--lowercase false--
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--uppercase TRUE--
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--uppercase FALSE--
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--empty string DQ--
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--empty string SQ--
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--string DQ--
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--string SQ--
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--mixed case string--
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--heredoc--
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8 - Object of class classWithToString could not be converted to int, %s(%d)
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8 - Object of class classWithoutToString could not be converted to int, %s(%d)
|
||||
string(32) "983d5edc5f77fe42e2372a0339dc22b0"
|
||||
|
||||
--undefined var--
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--unset var--
|
||||
string(32) "5f781523f696d596e4b809d72197a0cc"
|
||||
|
||||
--resource--
|
||||
string(%d) %s
|
||||
===DONE===
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
$key = "FooBar";
|
||||
$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);
|
||||
|
||||
// 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";
|
||||
|
||||
// a warning must be issued if we don't use a IV on a AES cipher, that usually requires an IV
|
||||
mcrypt_cfb($cipher, $key, $enc_data, MCRYPT_DECRYPT);
|
||||
@@ -0,0 +1,2 @@
|
||||
PHP Testfest 2008
|
||||
HipHop Warning: %a
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
$iv1 = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_RAND);
|
||||
$iv2 = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_DEV_URANDOM);
|
||||
$iv3 = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_DEV_RANDOM);
|
||||
|
||||
echo strlen($iv1) . "\n";
|
||||
echo strlen($iv2) . "\n";
|
||||
echo strlen($iv3) . "\n";
|
||||
@@ -0,0 +1,3 @@
|
||||
16
|
||||
16
|
||||
16
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
$key = "FooBar";
|
||||
$secret = "PHP Testfest 2008";
|
||||
$mode = MCRYPT_MODE_CBC;
|
||||
$cipher = MCRYPT_RIJNDAEL_128;
|
||||
|
||||
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, $mode), MCRYPT_RAND);
|
||||
$enc_data = mcrypt_encrypt($cipher, $key, $secret, $mode, $iv);
|
||||
|
||||
// we have to trim as AES rounds the blocks and decrypt doesnt detect that
|
||||
echo trim(mcrypt_decrypt($cipher, $key, $enc_data, $mode, $iv)) . "\n";
|
||||
|
||||
// a warning must be issued if we don't use a IV on a AES cipher, that usually requires an IV
|
||||
mcrypt_decrypt($cipher, $key, $enc_data, MCRYPT_MODE_CBC);
|
||||
|
||||
var_dump(strpos(mcrypt_decrypt(MCRYPT_BLOWFISH, "FooBar", $enc_data, MCRYPT_MODE_CBC, $iv), "Testfest") !== false);
|
||||
@@ -0,0 +1,4 @@
|
||||
PHP Testfest 2008
|
||||
HipHop Warning: %a
|
||||
HipHop Warning: %a
|
||||
bool(false)
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/* Prototype : string mcrypt_decrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_decrypt() : basic functionality ***\n";
|
||||
|
||||
|
||||
// Initialise all required variables
|
||||
$cipher = MCRYPT_3DES;
|
||||
$mode = MCRYPT_MODE_CBC;
|
||||
|
||||
// tripledes uses keys upto 192 bits (24 bytes)
|
||||
$keys = array(
|
||||
b'12345678',
|
||||
b'12345678901234567890',
|
||||
b'123456789012345678901234',
|
||||
b'12345678901234567890123456'
|
||||
);
|
||||
$data1 = array(
|
||||
'IleMhoxiOthmHua4tFBHOw==',
|
||||
'EeF1s6C+w1IiHj1gdDn81g==',
|
||||
'EEuXpjZPueyYoG0LGQ199Q==',
|
||||
'EEuXpjZPueyYoG0LGQ199Q=='
|
||||
);
|
||||
// tripledes is a block cipher of 64 bits (8 bytes)
|
||||
$ivs = array(
|
||||
b'1234',
|
||||
b'12345678',
|
||||
b'123456789'
|
||||
);
|
||||
$data2 = array(
|
||||
'+G7nGcWIxij3TZjpI9lJdQ==',
|
||||
'3bJiFMeyScxOLQcE6mZtLg==',
|
||||
'+G7nGcWIxij3TZjpI9lJdQ=='
|
||||
);
|
||||
|
||||
$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_decrypt($cipher, $keys[$i], base64_decode($data1[$i]), $mode, $iv));
|
||||
}
|
||||
|
||||
$key = b'1234567890123456';
|
||||
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_decrypt($cipher, $key, base64_decode($data2[$i]), $mode, $ivs[$i]));
|
||||
}
|
||||
|
||||
function special_var_dump($str) {
|
||||
var_dump(bin2hex($str));
|
||||
}
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,30 @@
|
||||
*** Testing mcrypt_decrypt() : basic functionality ***
|
||||
|
||||
--- testing different key lengths
|
||||
|
||||
key length=8
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
key length=20
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
key length=24
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
key length=26
|
||||
HipHop Warning: %a
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
--- testing different iv lengths
|
||||
|
||||
iv length=4
|
||||
HipHop Warning: %a
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
iv length=8
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
iv length=9
|
||||
HipHop Warning: %a
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
===DONE===
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/* Prototype : string mcrypt_decrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_decrypt() : basic functionality ***\n";
|
||||
|
||||
|
||||
// Initialise all required variables
|
||||
$cipher = MCRYPT_3DES;
|
||||
$mode = MCRYPT_MODE_ECB;
|
||||
|
||||
// tripledes uses keys upto 192 bits (24 bytes)
|
||||
$keys = array(
|
||||
b'12345678',
|
||||
b'12345678901234567890',
|
||||
b'123456789012345678901234',
|
||||
b'12345678901234567890123456'
|
||||
);
|
||||
$data1 = array(
|
||||
'0D4ArM3ejyhic9rnCcIW9A==',
|
||||
'q0wt1YeOjLpnKm5WsrzKEw==',
|
||||
'zwKEFeqHkhlj+7HZTRA/yA==',
|
||||
'zwKEFeqHkhlj+7HZTRA/yA=='
|
||||
);
|
||||
// tripledes is a block cipher of 64 bits (8 bytes)
|
||||
$ivs = array(
|
||||
b'1234',
|
||||
b'12345678',
|
||||
b'123456789'
|
||||
);
|
||||
$data2 = array(
|
||||
'+G7nGcWIxigQcJD+2P14HA==',
|
||||
'+G7nGcWIxigQcJD+2P14HA==',
|
||||
'+G7nGcWIxigQcJD+2P14HA=='
|
||||
);
|
||||
|
||||
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_decrypt($cipher, $keys[$i], base64_decode($data1[$i]), $mode));
|
||||
}
|
||||
|
||||
$key = b'1234567890123456';
|
||||
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_decrypt($cipher, $key, base64_decode($data2[$i]), $mode, $ivs[$i]));
|
||||
}
|
||||
|
||||
function special_var_dump($str) {
|
||||
var_dump(bin2hex($str));
|
||||
}
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,28 @@
|
||||
*** Testing mcrypt_decrypt() : basic functionality ***
|
||||
|
||||
--- testing different key lengths
|
||||
|
||||
key length=8
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
key length=20
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
key length=24
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
key length=26
|
||||
HipHop Warning: %a
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
--- testing different iv lengths
|
||||
|
||||
iv length=4
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
iv length=8
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
iv length=9
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
===DONE===
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/* Prototype : string mcrypt_decrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_decrypt() : error conditions ***\n";
|
||||
|
||||
|
||||
//Test mcrypt_decrypt with one more than the expected number of arguments
|
||||
echo "\n-- Testing mcrypt_decrypt() function with more than expected no. of arguments --\n";
|
||||
$cipher = 'string_val';
|
||||
$key = 'string_val';
|
||||
$data = 'string_val';
|
||||
$mode = 'string_val';
|
||||
$iv = 'string_val';
|
||||
$extra_arg = 10;
|
||||
var_dump( mcrypt_decrypt($cipher, $key, $data, $mode, $iv, $extra_arg) );
|
||||
|
||||
// Testing mcrypt_decrypt with one less than the expected number of arguments
|
||||
echo "\n-- Testing mcrypt_decrypt() function with less than expected no. of arguments --\n";
|
||||
$cipher = 'string_val';
|
||||
$key = 'string_val';
|
||||
$data = 'string_val';
|
||||
var_dump( mcrypt_decrypt($cipher, $key, $data) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,10 @@
|
||||
*** Testing mcrypt_decrypt() : error conditions ***
|
||||
|
||||
-- Testing mcrypt_decrypt() function with more than expected no. of arguments --
|
||||
HipHop Warning: %a
|
||||
NULL
|
||||
|
||||
-- Testing mcrypt_decrypt() function with less than expected no. of arguments --
|
||||
HipHop Warning: %a
|
||||
NULL
|
||||
===DONE===
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
$key = "FooBar";
|
||||
$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);
|
||||
|
||||
// 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";
|
||||
|
||||
// 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);
|
||||
@@ -0,0 +1 @@
|
||||
PHP Testfest 2008
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/* 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() : basic functionality ***\n";
|
||||
|
||||
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$data = b"This is the secret message which must be encrypted";
|
||||
$mode = MCRYPT_DECRYPT;
|
||||
|
||||
// tripledes uses keys upto 192 bits (24 bytes)
|
||||
$keys = array(
|
||||
b'12345678',
|
||||
b'12345678901234567890',
|
||||
b'123456789012345678901234',
|
||||
b'12345678901234567890123456'
|
||||
);
|
||||
$data1 = array(
|
||||
'0D4ArM3ejyhic9rnCcIW9A==',
|
||||
'q0wt1YeOjLpnKm5WsrzKEw==',
|
||||
'zwKEFeqHkhlj+7HZTRA/yA==',
|
||||
'zwKEFeqHkhlj+7HZTRA/yA=='
|
||||
);
|
||||
// tripledes is a block cipher of 64 bits (8 bytes)
|
||||
$ivs = array(
|
||||
b'1234',
|
||||
b'12345678',
|
||||
b'123456789'
|
||||
);
|
||||
$data2 = array(
|
||||
'+G7nGcWIxigQcJD+2P14HA==',
|
||||
'+G7nGcWIxigQcJD+2P14HA==',
|
||||
'+G7nGcWIxigQcJD+2P14HA=='
|
||||
);
|
||||
|
||||
$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));
|
||||
}
|
||||
|
||||
$key = b'1234567890123456';
|
||||
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]));
|
||||
}
|
||||
|
||||
function special_var_dump($str) {
|
||||
var_dump(bin2hex($str));
|
||||
}
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,28 @@
|
||||
*** Testing mcrypt_ecb() : basic functionality ***
|
||||
|
||||
--- testing different key lengths
|
||||
|
||||
key length=8
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
key length=20
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
key length=24
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
key length=26
|
||||
HipHop Warning: %a
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
--- testing different iv lengths
|
||||
|
||||
iv length=4
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
iv length=8
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
|
||||
iv length=9
|
||||
string(32) "736563726574206d6573736167650000"
|
||||
===DONE===
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/* 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() : basic functionality ***\n";
|
||||
|
||||
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$data = b"This is the secret message which must be encrypted";
|
||||
$mode = MCRYPT_ENCRYPT;
|
||||
|
||||
// tripledes uses keys upto 192 bits (24 bytes)
|
||||
$keys = array(
|
||||
b'12345678',
|
||||
b'12345678901234567890',
|
||||
b'123456789012345678901234',
|
||||
b'12345678901234567890123456'
|
||||
);
|
||||
// tripledes is a block cipher of 64 bits (8 bytes)
|
||||
$ivs = array(
|
||||
b'1234',
|
||||
b'12345678',
|
||||
b'123456789'
|
||||
);
|
||||
|
||||
$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)));
|
||||
}
|
||||
|
||||
$key = b'1234567890123456';
|
||||
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)));
|
||||
}
|
||||
?>
|
||||
===DONE===
|
||||
@@ -0,0 +1,28 @@
|
||||
*** Testing mcrypt_ecb() : basic functionality ***
|
||||
|
||||
--- testing different key lengths
|
||||
|
||||
key length=8
|
||||
string(112) "05c9c4cafb9937d950bdae60ee3abcb8d9f3e1f1fac8acaaa5b11d70b7ca02f3b76d447ab3dd85a4b5df5dedb4b4654595ccdf6da97fa93f"
|
||||
|
||||
key length=20
|
||||
string(112) "0fc7045c4fb4dbcf44baf9ed15ab40331a42ff0632318a16b12ed5873f02e7945e4f63f408d6849534cbb7419c22c8854aaa85e0e05a28e6"
|
||||
|
||||
key length=24
|
||||
string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27"
|
||||
|
||||
key length=26
|
||||
HipHop Warning: %a
|
||||
string(112) "923eedcb20e18e3efa466a6ca1b842b34e6ac46aa3690ef739d0d68a26eb64e1a6ad42e7d18312ae8a57ab927e1dc892e5ff56c061864f27"
|
||||
|
||||
--- testing different iv lengths
|
||||
|
||||
iv length=4
|
||||
string(112) "440a6f54601969b15e81df09cd381ef585fede5f3620587fd1a949c520aed9f6d10ebbabf2cea3e1f04c9251c2878c0ca37d51c80d490165"
|
||||
|
||||
iv length=8
|
||||
string(112) "440a6f54601969b15e81df09cd381ef585fede5f3620587fd1a949c520aed9f6d10ebbabf2cea3e1f04c9251c2878c0ca37d51c80d490165"
|
||||
|
||||
iv length=9
|
||||
string(112) "440a6f54601969b15e81df09cd381ef585fede5f3620587fd1a949c520aed9f6d10ebbabf2cea3e1f04c9251c2878c0ca37d51c80d490165"
|
||||
===DONE===
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/* 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===
|
||||
@@ -0,0 +1,10 @@
|
||||
*** Testing mcrypt_ecb() : error conditions ***
|
||||
|
||||
-- Testing mcrypt_ecb() function with more than expected no. of arguments --
|
||||
HipHop Warning: %a
|
||||
NULL
|
||||
|
||||
-- Testing mcrypt_ecb() function with less than expected no. of arguments --
|
||||
HipHop Warning: %a
|
||||
NULL
|
||||
===DONE===
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* 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 (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';
|
||||
$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===
|
||||
@@ -0,0 +1,82 @@
|
||||
*** 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===
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$td = mcrypt_module_open('rijndael-128', '', MCRYPT_MODE_ECB, '');
|
||||
echo mcrypt_enc_get_algorithms_name($td) . "\n";
|
||||
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, '');
|
||||
echo mcrypt_enc_get_algorithms_name($td) . "\n";
|
||||
$td = mcrypt_module_open(MCRYPT_RC2, '', MCRYPT_MODE_CBC, '');
|
||||
echo mcrypt_enc_get_algorithms_name($td) . "\n";
|
||||
$td = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CBC, '');
|
||||
echo mcrypt_enc_get_algorithms_name($td) . "\n";
|
||||
$td = mcrypt_module_open('des', '', 'ecb', '');
|
||||
echo mcrypt_enc_get_algorithms_name($td) . "\n";
|
||||
@@ -0,0 +1,5 @@
|
||||
Rijndael-128
|
||||
Rijndael-128
|
||||
RC2
|
||||
Blowfish
|
||||
DES
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, '');
|
||||
var_dump(mcrypt_enc_get_block_size($td));
|
||||
$td = mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_CBC, '');
|
||||
var_dump(mcrypt_enc_get_block_size($td));
|
||||
$td = mcrypt_module_open(MCRYPT_WAKE, '', MCRYPT_MODE_STREAM, '');
|
||||
var_dump(mcrypt_enc_get_block_size($td));
|
||||
@@ -0,0 +1,3 @@
|
||||
int(32)
|
||||
int(8)
|
||||
int(1)
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, '');
|
||||
var_dump(mcrypt_enc_get_iv_size($td));
|
||||
$td = mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_CBC, '');
|
||||
var_dump(mcrypt_enc_get_iv_size($td));
|
||||
$td = mcrypt_module_open(MCRYPT_WAKE, '', MCRYPT_MODE_STREAM, '');
|
||||
var_dump(mcrypt_enc_get_iv_size($td));
|
||||
@@ -0,0 +1,3 @@
|
||||
int(32)
|
||||
int(8)
|
||||
int(0)
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, '');
|
||||
var_dump(mcrypt_enc_get_key_size($td));
|
||||
$td = mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_CBC, '');
|
||||
var_dump(mcrypt_enc_get_key_size($td));
|
||||
$td = mcrypt_module_open(MCRYPT_WAKE, '', MCRYPT_MODE_STREAM, '');
|
||||
var_dump(mcrypt_enc_get_key_size($td));
|
||||
@@ -0,0 +1,3 @@
|
||||
int(32)
|
||||
int(24)
|
||||
int(32)
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
$td = mcrypt_module_open('rijndael-128', '', MCRYPT_MODE_ECB, '');
|
||||
echo mcrypt_enc_get_modes_name($td) . "\n";
|
||||
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
|
||||
echo mcrypt_enc_get_modes_name($td) . "\n";
|
||||
$td = mcrypt_module_open(MCRYPT_WAKE, '', MCRYPT_MODE_STREAM, '');
|
||||
echo mcrypt_enc_get_modes_name($td) . "\n";
|
||||
$td = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_OFB, '');
|
||||
echo mcrypt_enc_get_modes_name($td) . "\n";
|
||||
$td = mcrypt_module_open('des', '', 'ecb', '');
|
||||
echo mcrypt_enc_get_modes_name($td) . "\n";
|
||||
$td = mcrypt_module_open('des', '', 'cbc', '');
|
||||
echo mcrypt_enc_get_modes_name($td) . "\n";
|
||||
@@ -0,0 +1,6 @@
|
||||
ECB
|
||||
CBC
|
||||
STREAM
|
||||
OFB
|
||||
ECB
|
||||
CBC
|
||||
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário