Trim trailing whitespace

This commit is contained in:
Peter Kokot
2018-10-03 06:27:33 +02:00
parent 7f295fd0b8
commit 725b127386
28 changed files with 241 additions and 241 deletions

26
LICENSE
View File

@@ -1,7 +1,7 @@
--------------------------------------------------------------------
--------------------------------------------------------------------
The PHP License, version 3.01
Copyright (c) 1999 - 2016 The PHP Group. All rights reserved.
--------------------------------------------------------------------
--------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, is permitted provided that the following conditions
@@ -9,22 +9,22 @@ are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name "PHP" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact group@php.net.
4. Products derived from this software may not be called "PHP", nor
may "PHP" appear in their name, without prior written permission
from group@php.net. You may indicate that your software works in
conjunction with PHP by saying "Foo for PHP" instead of calling
it "PHP Foo" or "phpfoo"
5. The PHP Group may publish revised and/or new versions of the
license from time to time. Each version will be given a
distinguishing version number.
@@ -41,27 +41,27 @@ are met:
"This product includes PHP software, freely available from
<http://www.php.net/software/>".
THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------
--------------------------------------------------------------------
This software consists of voluntary contributions made by many
individuals on behalf of the PHP Group.
The PHP Group can be contacted via Email at group@php.net.
For more information on the PHP Group and the PHP project,
For more information on the PHP Group and the PHP project,
please see <http://www.php.net>.
PHP includes the Zend Engine, freely available at

View File

@@ -13,7 +13,7 @@ AC_DEFUN([PHP_MCRYPT_CHECK_VERSION],[
AC_MSG_ERROR(libmcrypt version 2.5.6 or greater required.)
])
CPPFLAGS=$old_CPPFLAGS
])
])
PHP_ARG_WITH(mcrypt, for mcrypt support,
@@ -30,7 +30,7 @@ if test "$PHP_MCRYPT" != "no"; then
PHP_MCRYPT_CHECK_VERSION
PHP_CHECK_LIBRARY(mcrypt, mcrypt_module_open,
PHP_CHECK_LIBRARY(mcrypt, mcrypt_module_open,
[
PHP_ADD_LIBRARY(ltdl,, MCRYPT_SHARED_LIBADD)
AC_DEFINE(HAVE_LIBMCRYPT,1,[ ])

View File

@@ -8,7 +8,7 @@ if(!function_exists("hex2bin")) {
function hex2bin($data) {
$len = strlen($data);
return pack("H" . $len, $data);
}
}
}
print "key plain crypt guess stat\n";
@@ -24,7 +24,7 @@ foreach($vectors as $data) {
printf("%s %s ",
$key,
$plain
);
);
$key = hex2bin(trim($key));
$plain = hex2bin(($plain));
$crypt = strtolower(trim($crypt));
@@ -36,8 +36,8 @@ foreach($vectors as $data) {
$crypt,
$guess,
($crypt==$guess ? "OK" : "BAD")
);
}
);
}
}
// Longer test case from http://www.schneier.com/code/vectors.txt

Binary file not shown.

View File

@@ -1,7 +1,7 @@
--TEST--
Bug #43143 (Warning about empty IV with MCRYPT_MODE_ECB)
--SKIPIF--
<?php if (!extension_loaded("mcrypt")) print "skip";
<?php if (!extension_loaded("mcrypt")) print "skip";
if (!extension_loaded("hash")) print "skip"; ?>
--FILE--
<?php

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_cbc() function : basic functionality
Test mcrypt_cbc() function : basic functionality
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?php
/* Prototype : string mcrypt_cbc(int cipher, string key, string data, int mode, string iv)
* Description: CBC crypt/decrypt data using key key with cipher cipher starting with iv
* Description: CBC crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
$cipher = MCRYPT_TRIPLEDES;
@@ -19,9 +19,9 @@ $data = "This is the secret message which must be encrypted";
// tripledes uses keys with exactly 192 bits (24 bytes)
$keys = array(
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678901234567890123456'
);
$data1 = array(
@@ -32,8 +32,8 @@ $data1 = array(
);
// tripledes is a block cipher of 64 bits (8 bytes)
$ivs = array(
'1234',
'12345678',
'1234',
'12345678',
'123456789'
);
// data represented in base64 (ascii)
@@ -50,7 +50,7 @@ for ($i = 0; $i < sizeof($keys); $i++) {
special_var_dump(mcrypt_decrypt($cipher, $keys[$i], base64_decode($data1[$i]), MCRYPT_MODE_CBC, $iv));
}
$key = '123456789012345678901234';
$key = '123456789012345678901234';
echo "\n--- testing different iv lengths\n";
for ($i = 0; $i < sizeof($ivs); $i++) {
echo "\niv length=".strlen($ivs[$i])."\n";
@@ -59,7 +59,7 @@ for ($i = 0; $i < sizeof($ivs); $i++) {
function special_var_dump($str) {
var_dump(bin2hex($str));
}
}
?>
===DONE===
--EXPECTF--

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_cbc() function : basic functionality
Test mcrypt_cbc() function : basic functionality
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?php
/* Prototype : string mcrypt_cbc(int cipher, string key, string data, int mode, string iv)
* Description: CBC crypt/decrypt data using key key with cipher cipher starting with iv
* Description: CBC crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
$cipher = MCRYPT_TRIPLEDES;
@@ -19,14 +19,14 @@ $data = "This is the secret message which must be encrypted";
// tripledes uses keys with exactly 192 bits (24 bytes)
$keys = array(
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678901234567890123456');
// tripledes is a block cipher of 64 bits (8 bytes)
$ivs = array(
'1234',
'12345678',
'1234',
'12345678',
'123456789');
@@ -37,7 +37,7 @@ foreach ($keys as $key) {
var_dump(bin2hex(mcrypt_encrypt($cipher, $key, $data, MCRYPT_MODE_CBC, $iv)));
}
$key = '123456789012345678901234';
$key = '123456789012345678901234';
echo "\n--- testing different iv lengths\n";
foreach ($ivs as $iv) {
echo "\niv length=".strlen($iv)."\n";

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_decrypt() function : basic functionality
Test mcrypt_decrypt() function : basic functionality
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_decrypt() : basic functionality ***\n";
@@ -23,9 +23,9 @@ $mode = MCRYPT_MODE_CBC;
// tripledes uses keys with exactly 192 bits (24 bytes)
$keys = array(
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678901234567890123456'
);
$data1 = array(
@@ -36,8 +36,8 @@ $data1 = array(
);
// tripledes is a block cipher of 64 bits (8 bytes)
$ivs = array(
'1234',
'12345678',
'1234',
'12345678',
'123456789'
);
$data2 = array(
@@ -62,7 +62,7 @@ for ($i = 0; $i < sizeof($ivs); $i++) {
function special_var_dump($str) {
var_dump(bin2hex($str));
}
}
?>
===DONE===
--EXPECTF--

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_decrypt() function : basic functionality
Test mcrypt_decrypt() function : basic functionality
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_decrypt() : basic functionality ***\n";
@@ -23,9 +23,9 @@ $mode = MCRYPT_MODE_ECB;
// tripledes uses keys with exactly 192 bits (24 bytes)
$keys = array(
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678901234567890123456'
);
$data1 = array(
@@ -36,8 +36,8 @@ $data1 = array(
);
// tripledes is a block cipher of 64 bits (8 bytes)
$ivs = array(
'1234',
'12345678',
'1234',
'12345678',
'123456789'
);
$data2 = array(
@@ -52,7 +52,7 @@ for ($i = 0; $i < sizeof($keys); $i++) {
special_var_dump(mcrypt_decrypt($cipher, $keys[$i], base64_decode($data1[$i]), $mode));
}
$key = '123456789012345678901234';
$key = '123456789012345678901234';
echo "\n--- testing different iv lengths\n";
for ($i = 0; $i < sizeof($ivs); $i++) {
echo "\niv length=".strlen($ivs[$i])."\n";
@@ -61,7 +61,7 @@ for ($i = 0; $i < sizeof($ivs); $i++) {
function special_var_dump($str) {
var_dump(bin2hex($str));
}
}
?>
===DONE===
--EXPECTF--

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_decrypt() function : error conditions
Test mcrypt_decrypt() function : error conditions
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_decrypt() : error conditions ***\n";

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_decrypt() function : usage variation
Test mcrypt_decrypt() function : usage variation
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_decrypt() : usage variation ***\n";
@@ -104,9 +104,9 @@ $inputs = array(
// unset data
'unset var' => @$unset_var,
// resource variable
'resource' => $fp
'resource' => $fp
);
// loop through each element of the array for cipher

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_decrypt() function : usage variation
Test mcrypt_decrypt() function : usage variation
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_decrypt() : usage variation ***\n";
@@ -104,9 +104,9 @@ $inputs = array(
// unset data
'unset var' => @$unset_var,
// resource variable
'resource' => $fp
'resource' => $fp
);
// loop through each element of the array for key

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_decrypt() function : usage variation
Test mcrypt_decrypt() function : usage variation
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_decrypt() : usage variation ***\n";
@@ -104,9 +104,9 @@ $inputs = array(
// unset data
'unset var' => @$unset_var,
// resource variable
'resource' => $fp
'resource' => $fp
);
// loop through each element of the array for data

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_decrypt() function : usage variation
Test mcrypt_decrypt() function : usage variation
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_decrypt() : usage variation ***\n";
@@ -104,9 +104,9 @@ $inputs = array(
// unset data
'unset var' => @$unset_var,
// resource variable
'resource' => $fp
'resource' => $fp
);
// loop through each element of the array for mode

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_decrypt() function : usage variation
Test mcrypt_decrypt() function : usage variation
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_decrypt() : usage variation ***\n";
@@ -104,9 +104,9 @@ $inputs = array(
// unset data
'unset var' => @$unset_var,
// resource variable
'resource' => $fp
'resource' => $fp
);
// loop through each element of the array for iv

View File

@@ -1,19 +1,19 @@
--TEST--
Test mcrypt_cbc() function : basic functionality
Test mcrypt_cbc() function : basic functionality
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?php
error_reporting(E_ALL);
/* Prototype : string mcrypt_ecb(int cipher, string key, string data, int mode, string iv)
* Description: ECB crypt/decrypt data using key key with cipher cipher starting with iv
* Description: ECB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
$cipher = MCRYPT_TRIPLEDES;
@@ -21,9 +21,9 @@ $data = "This is the secret message which must be encrypted";
// tripledes uses keys up to 192 bits (24 bytes)
$keys = array(
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678901234567890123456'
);
$data1 = array(
@@ -34,8 +34,8 @@ $data1 = array(
);
// tripledes is a block cipher of 64 bits (8 bytes)
$ivs = array(
'1234',
'12345678',
'1234',
'12345678',
'123456789'
);
$data2 = array(
@@ -60,7 +60,7 @@ for ($i = 0; $i < sizeof($ivs); $i++) {
function special_var_dump($str) {
var_dump(bin2hex($str));
}
}
?>
===DONE===
--EXPECTF--

View File

@@ -1,19 +1,19 @@
--TEST--
Test mcrypt_ecb() function : basic functionality
Test mcrypt_ecb() function : basic functionality
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?php
error_reporting(E_ALL);
/* Prototype : string mcrypt_ecb(int cipher, string key, string data, int mode, string iv)
* Description: ECB crypt/decrypt data using key key with cipher cipher starting with iv
* Description: ECB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
$cipher = MCRYPT_TRIPLEDES;
@@ -21,15 +21,15 @@ $data = "This is the secret message which must be encrypted";
// tripledes uses keys up to 192 bits (24 bytes)
$keys = array(
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678901234567890123456'
);
// tripledes is a block cipher of 64 bits (8 bytes)
$ivs = array(
'1234',
'12345678',
'1234',
'12345678',
'123456789'
);

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_encrypt() function : TripleDES functionality
Test mcrypt_encrypt() function : TripleDES functionality
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_encrypt() : TripleDES functionality ***\n";
@@ -20,7 +20,7 @@ echo "*** Testing mcrypt_encrypt() : TripleDES functionality ***\n";
//test encrypt decrypt
//test tripledes, aes
//test different lengths of key, iv
//test no iv being passed on CBC, ECB
//test no iv being passed on CBC, ECB
//test up to 32 bytes with unlimited strength
$cipher = MCRYPT_TRIPLEDES;
@@ -29,15 +29,15 @@ $data = 'This is the secret message which must be encrypted';
// tripledes uses keys up to 192 bits (24 bytes)
$keys = array(
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678901234567890123456'
);
// tripledes is a block cipher of 64 bits (8 bytes)
$ivs = array(
'1234',
'12345678',
'1234',
'12345678',
'123456789'
);

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_encrypt() function : TripleDES functionality
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_encrypt() : TripleDES functionality ***\n";
@@ -22,9 +22,9 @@ $data = 'This is the secret message which must be encrypted';
// tripledes uses keys up to 192 bits (24 bytes)
$keys = array(
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678',
'12345678901234567890',
'123456789012345678901234',
'12345678901234567890123456'
);
@@ -36,8 +36,8 @@ foreach ($keys as $key) {
$key = '123456789012345678901234';
$ivs = array(
'1234',
'12345678',
'1234',
'12345678',
'123456789'
);

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_encrypt() function : error conditions
Test mcrypt_encrypt() function : error conditions
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_encrypt() : error conditions ***\n";

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_encrypt() function : usage variation - different types for cipher
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_encrypt() : usage variation ***\n";
@@ -104,9 +104,9 @@ $inputs = array(
// unset data
'unset var' => @$unset_var,
// resource variable
'resource' => $fp
'resource' => $fp
);
// loop through each element of the array for cipher

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_encrypt() function : usage variation
Test mcrypt_encrypt() function : usage variation
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_encrypt() : usage variation ***\n";
@@ -104,9 +104,9 @@ $inputs = array(
// unset data
'unset var' => @$unset_var,
// resource variable
'resource' => $fp
'resource' => $fp
);
// loop through each element of the array for key

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_encrypt() function : usage variation
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
?>
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_encrypt() : usage variation ***\n";
@@ -104,9 +104,9 @@ $inputs = array(
// unset data
'unset var' => @$unset_var,
// resource variable
'resource' => $fp
'resource' => $fp
);
// loop through each element of the array for data

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_encrypt() function : usage variation
Test mcrypt_encrypt() function : usage variation
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_encrypt() : usage variation ***\n";
@@ -104,9 +104,9 @@ $inputs = array(
// unset data
'unset var' => @$unset_var,
// resource variable
'resource' => $fp
'resource' => $fp
);
// loop through each element of the array for mode

View File

@@ -1,17 +1,17 @@
--TEST--
Test mcrypt_encrypt() function : usage variation
Test mcrypt_encrypt() function : usage variation
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt_encrypt() : usage variation ***\n";
@@ -105,9 +105,9 @@ $inputs = array(
// unset data
'unset var' => @$unset_var,
// resource variable
'resource' => $fp
'resource' => $fp
);
// loop through each element of the array for iv

View File

@@ -14,7 +14,7 @@ $secretfile = 'secert-file.tmp';
$passphrase = 'My secret';
$iv = substr(md5('iv'.$passphrase, true), 0, 8);
$key = substr(md5('pass1'.$passphrase, true) .
$key = substr(md5('pass1'.$passphrase, true) .
md5('pass2'.$passphrase, true), 0, 24);
$opts = array('iv'=>$iv, 'key'=>$key);

View File

@@ -1,27 +1,27 @@
--TEST--
Test mcrypt_encrypt() function : AES functionality
Test mcrypt_encrypt() function : AES functionality
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
/* 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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
/* 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
* Description: CBC crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt : Rijndael128 functionality ***\n";
@@ -32,17 +32,17 @@ $data = 'This is the secret message which must be encrypted';
// keys up to 128 bits (16 bytes)
$keys = array(
null,
'',
'12345678',
null,
'',
'12345678',
'1234567890123456'
);
// rijndael128 is a block cipher of 128 bits (16 bytes)
$ivs = array(
null,
'',
'12345678',
'1234567890123456',
null,
'',
'12345678',
'1234567890123456',
'12345678901234567'
);
@@ -55,12 +55,12 @@ foreach ($keys as $key) {
var_dump(bin2hex($res));
}
$key = '1234567890123456';
$key = '1234567890123456';
echo "\n--- testing different iv lengths\n";
foreach ($ivs as $iv) {
echo "\niv length=".strlen($iv)."\n";
$res = mcrypt_decrypt($cipher, $key, $res, MCRYPT_MODE_CBC, $iv);
var_dump(bin2hex($res));
var_dump(bin2hex($res));
}
?>

View File

@@ -1,32 +1,32 @@
--TEST--
Test mcrypt_encrypt() function : AES functionality
Test mcrypt_encrypt() function : AES functionality
--SKIPIF--
<?php
<?php
if (!extension_loaded("mcrypt")) {
print "skip - mcrypt extension not loaded";
}
print "skip - mcrypt extension not loaded";
}
?>
--FILE--
<?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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
/* 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
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
/* 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
* Description: CBC crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
/* 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
* Description: ECB crypt/decrypt data using key key with cipher cipher starting with iv
* Source code: ext/mcrypt/mcrypt.c
* Alias to functions:
* Alias to functions:
*/
echo "*** Testing mcrypt : Rijndael128 functionality ***\n";
@@ -37,8 +37,8 @@ $data = 'This is the secret message which must be encrypted';
// keys : 20 bytes, 24 bytes, 30 Bytes, 32 Bytes, 40 Bytes
$keys = array(
'12345678901234567890',
'123456789012345678901234',
'12345678901234567890',
'123456789012345678901234',
'123456789012345678901234567890',
'12345678901234567890123456789012',
'1234567890123456789012345678901234567890'
@@ -52,7 +52,7 @@ foreach ($keys as $key) {
$res = mcrypt_encrypt($cipher, $key, $data, MCRYPT_MODE_CBC, $iv);
var_dump(bin2hex($res));
$res = mcrypt_decrypt($cipher, $key, $res, MCRYPT_MODE_CBC, $iv);
var_dump(bin2hex($res));
var_dump(bin2hex($res));
}
?>
===DONE===