Fix a bunch of binary/unicode issues in the mcrypt tests

This commit is contained in:
Rasmus Lerdorf 2009-07-26 08:13:40 +00:00
parent 4743436576
commit 4551e0fda3
7 changed files with 20 additions and 20 deletions

View File

@ -5,7 +5,7 @@ Bug #41252 (Calling mcrypt_generic without first calling mcrypt_generic_init cra
--FILE--
<?php
$td = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_ECB, '');
echo mcrypt_generic($td,'aaaaaaaa');
echo mcrypt_generic($td,b'aaaaaaaa');
print "I'm alive!\n";
?>
--EXPECTF--

View File

@ -4,8 +4,8 @@ mcrypt_cbc
<?php if (!extension_loaded("mcrypt") || unicode_semantics()) print "skip"; ?>
--FILE--
<?php
$key = "FooBar";
$secret = "PHP Testfest 2008";
$key = b"FooBar";
$secret = b"PHP Testfest 2008";
$cipher = MCRYPT_RIJNDAEL_128;
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_ECB), MCRYPT_RAND);

View File

@ -4,8 +4,8 @@ mcrypt_cbf
<?php if (!extension_loaded("mcrypt") || unicode_semantics()) print "skip"; ?>
--FILE--
<?php
$key = "FooBar";
$secret = "PHP Testfest 2008";
$key = b"FooBar";
$secret = b"PHP Testfest 2008";
$cipher = MCRYPT_RIJNDAEL_128;
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_ECB), MCRYPT_RAND);

View File

@ -4,8 +4,8 @@ mcrypt_decrypt
<?php if (!extension_loaded("mcrypt") || unicode_semantics()) print "skip"; ?>
--FILE--
<?php
$key = "FooBar";
$secret = "PHP Testfest 2008";
$key = b"FooBar";
$secret = b"PHP Testfest 2008";
$mode = MCRYPT_MODE_CBC;
$cipher = MCRYPT_RIJNDAEL_128;
@ -18,7 +18,7 @@ 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);
var_dump(strpos(mcrypt_decrypt(MCRYPT_BLOWFISH, b"FooBar", $enc_data, MCRYPT_MODE_CBC, $iv), b"Testfest") !== false);
--EXPECTF--
PHP Testfest 2008

View File

@ -4,8 +4,8 @@ mcrypt_ecb
<?php if (!extension_loaded("mcrypt") || unicode_semantics()) print "skip"; ?>
--FILE--
<?php
$key = "FooBar";
$secret = "PHP Testfest 2008";
$key = b"FooBar";
$secret = b"PHP Testfest 2008";
$cipher = MCRYPT_RIJNDAEL_128;
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_ECB), MCRYPT_RAND);

View File

@ -8,19 +8,19 @@ var_dump(mcrypt_list_modes());
--EXPECT--
array(8) {
[0]=>
string(3) "cbc"
unicode(3) "cbc"
[1]=>
string(3) "cfb"
unicode(3) "cfb"
[2]=>
string(3) "ctr"
unicode(3) "ctr"
[3]=>
string(3) "ecb"
unicode(3) "ecb"
[4]=>
string(4) "ncfb"
unicode(4) "ncfb"
[5]=>
string(4) "nofb"
unicode(4) "nofb"
[6]=>
string(3) "ofb"
unicode(3) "ofb"
[7]=>
string(6) "stream"
unicode(6) "stream"
}

View File

@ -4,8 +4,8 @@ mcrypt_ofb
<?php if (!extension_loaded("mcrypt") || unicode_semantics()) print "skip"; ?>
--FILE--
<?php
$key = "FooBar";
$secret = "PHP Testfest 2008";
$key = b"FooBar";
$secret = b"PHP Testfest 2008";
$cipher = MCRYPT_RIJNDAEL_128;
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_ECB), MCRYPT_RAND);