summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Soria Parra <dsp@php.net>2008-05-17 23:27:42 +0000
committerDavid Soria Parra <dsp@php.net>2008-05-17 23:27:42 +0000
commit02eb39d64b8fda81fe10507976b04fb55769214b (patch)
treef075c330977d60cb79ebeb91d9b271478bcdde06
parent11fb7561f057aa3fdb11c13f76356f83ed67f17f (diff)
downloadphp-git-02eb39d64b8fda81fe10507976b04fb55769214b.tar.gz
Tests from Munich PHP Testfest 2008
-rw-r--r--ext/mcrypt/tests/mcrypt_cbc.phpt23
-rw-r--r--ext/mcrypt/tests/mcrypt_cbf.phpt23
-rw-r--r--ext/mcrypt/tests/mcrypt_create_iv.phpt17
-rw-r--r--ext/mcrypt/tests/mcrypt_decrypt.phpt28
-rw-r--r--ext/mcrypt/tests/mcrypt_ecb.phpt21
-rw-r--r--ext/mcrypt/tests/mcrypt_enc_get_algorithms_name.phpt22
-rw-r--r--ext/mcrypt/tests/mcrypt_enc_get_block_size.phpt16
-rw-r--r--ext/mcrypt/tests/mcrypt_enc_get_iv_size.phpt16
-rw-r--r--ext/mcrypt/tests/mcrypt_enc_get_key_size.phpt16
-rw-r--r--ext/mcrypt/tests/mcrypt_enc_get_mode_name.phpt25
-rw-r--r--ext/mcrypt/tests/mcrypt_enc_get_supported_key_sizes.phpt18
-rw-r--r--ext/mcrypt/tests/mcrypt_enc_is_block_algorithm.phpt16
-rw-r--r--ext/mcrypt/tests/mcrypt_enc_is_block_algorithm_mode.phpt16
-rw-r--r--ext/mcrypt/tests/mcrypt_enc_is_block_mode.phpt19
-rw-r--r--ext/mcrypt/tests/mcrypt_enc_self_test.phpt10
-rw-r--r--ext/mcrypt/tests/mcrypt_get_block_size.phpt13
-rw-r--r--ext/mcrypt/tests/mcrypt_get_cipher_name.phpt15
-rw-r--r--ext/mcrypt/tests/mcrypt_get_iv_size.phpt17
-rw-r--r--ext/mcrypt/tests/mcrypt_get_key_size.phpt13
-rw-r--r--ext/mcrypt/tests/mcrypt_list_algorithms.phpt16
-rw-r--r--ext/mcrypt/tests/mcrypt_list_modes.phpt26
-rw-r--r--ext/mcrypt/tests/mcrypt_module_get_algo_block_size.phpt19
-rw-r--r--ext/mcrypt/tests/mcrypt_module_get_algo_key_size.phpt19
-rw-r--r--ext/mcrypt/tests/mcrypt_module_get_supported_key_sizes.phpt19
-rw-r--r--ext/mcrypt/tests/mcrypt_module_is_block_algorithm.phpt15
-rw-r--r--ext/mcrypt/tests/mcrypt_module_is_block_algorithm_mode.phpt15
-rw-r--r--ext/mcrypt/tests/mcrypt_module_is_block_mode.phpt17
-rw-r--r--ext/mcrypt/tests/mcrypt_module_open.phpt14
-rw-r--r--ext/mcrypt/tests/mcrypt_module_self_test.phpt13
-rw-r--r--ext/mcrypt/tests/mcrypt_ofb.phpt21
30 files changed, 538 insertions, 0 deletions
diff --git a/ext/mcrypt/tests/mcrypt_cbc.phpt b/ext/mcrypt/tests/mcrypt_cbc.phpt
new file mode 100644
index 0000000000..43b50ab211
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_cbc.phpt
@@ -0,0 +1,23 @@
+--TEST--
+mcrypt_cbc
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt") || unicode_semantics()) print "skip"; ?>
+--FILE--
+<?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);
+
+--EXPECTF--
+PHP Testfest 2008
+
+Warning: mcrypt_cbc(): Attempt to use an empty IV, which is NOT recommended in %s on line %d
diff --git a/ext/mcrypt/tests/mcrypt_cbf.phpt b/ext/mcrypt/tests/mcrypt_cbf.phpt
new file mode 100644
index 0000000000..ebc2834aba
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_cbf.phpt
@@ -0,0 +1,23 @@
+--TEST--
+mcrypt_cbf
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt") || unicode_semantics()) print "skip"; ?>
+--FILE--
+<?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_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);
+
+--EXPECTF--
+PHP Testfest 2008
+
+Warning: mcrypt_cfb(): Attempt to use an empty IV, which is NOT recommended in %s on line %d
diff --git a/ext/mcrypt/tests/mcrypt_create_iv.phpt b/ext/mcrypt/tests/mcrypt_create_iv.phpt
new file mode 100644
index 0000000000..cf6456fef7
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_create_iv.phpt
@@ -0,0 +1,17 @@
+--TEST--
+mcrypt_create_iv
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?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_192, MCRYPT_MODE_ECB), MCRYPT_DEV_URANDOM);
+$iv3 = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_DEV_RANDOM);
+
+echo strlen($iv1) . "\n";
+echo strlen($iv2) . "\n";
+echo strlen($iv3) . "\n";
+--EXPECT--
+16
+24
+32
diff --git a/ext/mcrypt/tests/mcrypt_decrypt.phpt b/ext/mcrypt/tests/mcrypt_decrypt.phpt
new file mode 100644
index 0000000000..498762bc89
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_decrypt.phpt
@@ -0,0 +1,28 @@
+--TEST--
+mcrypt_decrypt
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt") || unicode_semantics()) print "skip"; ?>
+--FILE--
+<?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);
+--EXPECTF--
+PHP Testfest 2008
+
+Warning: mcrypt_decrypt(): Attempt to use an empty IV, which is NOT recommended in %s on line %d
+
+Warning: mcrypt_decrypt(): The IV parameter must be as long as the blocksize in %s on line %d
+bool(false)
diff --git a/ext/mcrypt/tests/mcrypt_ecb.phpt b/ext/mcrypt/tests/mcrypt_ecb.phpt
new file mode 100644
index 0000000000..fc54516e42
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_ecb.phpt
@@ -0,0 +1,21 @@
+--TEST--
+mcrypt_ecb
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt") || unicode_semantics()) print "skip"; ?>
+--FILE--
+<?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);
+
+--EXPECTF--
+PHP Testfest 2008
diff --git a/ext/mcrypt/tests/mcrypt_enc_get_algorithms_name.phpt b/ext/mcrypt/tests/mcrypt_enc_get_algorithms_name.phpt
new file mode 100644
index 0000000000..5b0bb01b9f
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_enc_get_algorithms_name.phpt
@@ -0,0 +1,22 @@
+--TEST--
+mcrypt_enc_get_algorithms_name
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?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";
+--EXPECT--
+Rijndael-128
+Rijndael-128
+RC2
+Blowfish
+DES \ No newline at end of file
diff --git a/ext/mcrypt/tests/mcrypt_enc_get_block_size.phpt b/ext/mcrypt/tests/mcrypt_enc_get_block_size.phpt
new file mode 100644
index 0000000000..06f5adda7a
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_enc_get_block_size.phpt
@@ -0,0 +1,16 @@
+--TEST--
+mcrypt_enc_get_block_size
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?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));
+--EXPECT--
+int(32)
+int(8)
+int(1)
diff --git a/ext/mcrypt/tests/mcrypt_enc_get_iv_size.phpt b/ext/mcrypt/tests/mcrypt_enc_get_iv_size.phpt
new file mode 100644
index 0000000000..b4f9d6e4b5
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_enc_get_iv_size.phpt
@@ -0,0 +1,16 @@
+--TEST--
+mcrypt_enc_get_iv_size
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?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));
+--EXPECT--
+int(32)
+int(8)
+int(0)
diff --git a/ext/mcrypt/tests/mcrypt_enc_get_key_size.phpt b/ext/mcrypt/tests/mcrypt_enc_get_key_size.phpt
new file mode 100644
index 0000000000..22328e14d6
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_enc_get_key_size.phpt
@@ -0,0 +1,16 @@
+--TEST--
+mcrypt_enc_get_key_size
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?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));
+--EXPECT--
+int(32)
+int(24)
+int(32)
diff --git a/ext/mcrypt/tests/mcrypt_enc_get_mode_name.phpt b/ext/mcrypt/tests/mcrypt_enc_get_mode_name.phpt
new file mode 100644
index 0000000000..21c41f98cb
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_enc_get_mode_name.phpt
@@ -0,0 +1,25 @@
+--TEST--
+mcrypt_enc_get_modes_name
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?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";
+--EXPECT--
+ECB
+CBC
+STREAM
+OFB
+ECB
+CBC
diff --git a/ext/mcrypt/tests/mcrypt_enc_get_supported_key_sizes.phpt b/ext/mcrypt/tests/mcrypt_enc_get_supported_key_sizes.phpt
new file mode 100644
index 0000000000..0ce1f15cf7
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_enc_get_supported_key_sizes.phpt
@@ -0,0 +1,18 @@
+--TEST--
+mcrypt_enc_get_supported_key_sizes
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+$td = mcrypt_module_open('rijndael-256', '', 'ecb', '');
+$var = mcrypt_enc_get_supported_key_sizes($td);
+var_dump($var);
+--EXPECT--
+array(3) {
+ [0]=>
+ int(16)
+ [1]=>
+ int(24)
+ [2]=>
+ int(32)
+} \ No newline at end of file
diff --git a/ext/mcrypt/tests/mcrypt_enc_is_block_algorithm.phpt b/ext/mcrypt/tests/mcrypt_enc_is_block_algorithm.phpt
new file mode 100644
index 0000000000..21a0ed2b88
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_enc_is_block_algorithm.phpt
@@ -0,0 +1,16 @@
+--TEST--
+mcrypt_enc_is_block_algorithm
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+$td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, '');
+var_dump(mcrypt_enc_is_block_algorithm($td));
+$td = mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_CBC, '');
+var_dump(mcrypt_enc_is_block_algorithm($td));
+$td = mcrypt_module_open(MCRYPT_WAKE, '', MCRYPT_MODE_STREAM, '');
+var_dump(mcrypt_enc_is_block_algorithm($td));
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
diff --git a/ext/mcrypt/tests/mcrypt_enc_is_block_algorithm_mode.phpt b/ext/mcrypt/tests/mcrypt_enc_is_block_algorithm_mode.phpt
new file mode 100644
index 0000000000..69c9654175
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_enc_is_block_algorithm_mode.phpt
@@ -0,0 +1,16 @@
+--TEST--
+mcrypt_enc_is_block_algorithm_mode
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+$td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_ECB, '');
+var_dump(mcrypt_enc_is_block_algorithm_mode($td));
+$td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, '');
+var_dump(mcrypt_enc_is_block_algorithm_mode($td));
+$td = mcrypt_module_open(MCRYPT_WAKE, '', MCRYPT_MODE_STREAM, '');
+var_dump(mcrypt_enc_is_block_algorithm_mode($td));
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
diff --git a/ext/mcrypt/tests/mcrypt_enc_is_block_mode.phpt b/ext/mcrypt/tests/mcrypt_enc_is_block_mode.phpt
new file mode 100644
index 0000000000..551f7a6975
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_enc_is_block_mode.phpt
@@ -0,0 +1,19 @@
+--TEST--
+mcrypt_enc_is_block_mode
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+$td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, '');
+var_dump(mcrypt_enc_is_block_mode($td));
+$td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_ECB, '');
+var_dump(mcrypt_enc_is_block_mode($td));
+$td = mcrypt_module_open(MCRYPT_ARCFOUR, '', MCRYPT_MODE_STREAM, '');
+var_dump(mcrypt_enc_is_block_mode($td));
+$td = mcrypt_module_open(MCRYPT_WAKE, '', MCRYPT_MODE_STREAM, '');
+var_dump(mcrypt_enc_is_block_mode($td));
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+bool(false) \ No newline at end of file
diff --git a/ext/mcrypt/tests/mcrypt_enc_self_test.phpt b/ext/mcrypt/tests/mcrypt_enc_self_test.phpt
new file mode 100644
index 0000000000..a161e0e02b
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_enc_self_test.phpt
@@ -0,0 +1,10 @@
+--TEST--
+mcrypt_enc_self_test
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+$td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, '');
+var_dump(mcrypt_enc_self_test($td));
+--EXPECT--
+int(0) \ No newline at end of file
diff --git a/ext/mcrypt/tests/mcrypt_get_block_size.phpt b/ext/mcrypt/tests/mcrypt_get_block_size.phpt
new file mode 100644
index 0000000000..bf1f24df3b
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_get_block_size.phpt
@@ -0,0 +1,13 @@
+--TEST--
+mcrypt_get_block_size
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+var_dump(mcrypt_get_block_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC));
+var_dump(mcrypt_get_block_size(MCRYPT_3DES, MCRYPT_MODE_CBC));
+var_dump(mcrypt_get_block_size(MCRYPT_WAKE, MCRYPT_MODE_STREAM));
+--EXPECT--
+int(32)
+int(8)
+int(1)
diff --git a/ext/mcrypt/tests/mcrypt_get_cipher_name.phpt b/ext/mcrypt/tests/mcrypt_get_cipher_name.phpt
new file mode 100644
index 0000000000..9d4961ae8f
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_get_cipher_name.phpt
@@ -0,0 +1,15 @@
+--TEST--
+mcrypt_get_cipher_name
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+echo mcrypt_get_cipher_name(MCRYPT_RIJNDAEL_256) . "\n";
+echo mcrypt_get_cipher_name(MCRYPT_RC2) . "\n";
+echo mcrypt_get_cipher_name(MCRYPT_ARCFOUR) . "\n";
+echo mcrypt_get_cipher_name(MCRYPT_WAKE) . "\n";
+--EXPECT--
+Rijndael-256
+RC2
+RC4
+WAKE
diff --git a/ext/mcrypt/tests/mcrypt_get_iv_size.phpt b/ext/mcrypt/tests/mcrypt_get_iv_size.phpt
new file mode 100644
index 0000000000..ad3599745c
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_get_iv_size.phpt
@@ -0,0 +1,17 @@
+--TEST--
+mcrypt_enc_get_iv_size
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+var_dump(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC));
+var_dump(mcrypt_get_iv_size(MCRYPT_3DES, MCRYPT_MODE_CBC));
+var_dump(mcrypt_get_iv_size(MCRYPT_WAKE, MCRYPT_MODE_STREAM));
+var_dump(mcrypt_get_iv_size(MCRYPT_XTEA, MCRYPT_MODE_STREAM));
+--EXPECTF--
+int(32)
+int(8)
+int(0)
+
+Warning: mcrypt_get_iv_size(): Module initialization failed in %s on line %d
+bool(false) \ No newline at end of file
diff --git a/ext/mcrypt/tests/mcrypt_get_key_size.phpt b/ext/mcrypt/tests/mcrypt_get_key_size.phpt
new file mode 100644
index 0000000000..930cf4d640
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_get_key_size.phpt
@@ -0,0 +1,13 @@
+--TEST--
+mcrypt_get_key_size
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+var_dump(mcrypt_get_key_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC));
+var_dump(mcrypt_get_key_size(MCRYPT_3DES, MCRYPT_MODE_CBC));
+var_dump(mcrypt_get_key_size(MCRYPT_WAKE, MCRYPT_MODE_STREAM));
+--EXPECT--
+int(32)
+int(24)
+int(32)
diff --git a/ext/mcrypt/tests/mcrypt_list_algorithms.phpt b/ext/mcrypt/tests/mcrypt_list_algorithms.phpt
new file mode 100644
index 0000000000..9baf9a64de
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_list_algorithms.phpt
@@ -0,0 +1,16 @@
+--TEST--
+mcrypt_list_algorithms
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+foreach (mcrypt_list_algorithms() as $algo) {
+ if (in_array($algo, array('rijndael-256', 'des', 'blowfish', 'twofish'))) {
+ echo "FOUND\n";
+ }
+}
+--EXPECT--
+FOUND
+FOUND
+FOUND
+FOUND \ No newline at end of file
diff --git a/ext/mcrypt/tests/mcrypt_list_modes.phpt b/ext/mcrypt/tests/mcrypt_list_modes.phpt
new file mode 100644
index 0000000000..4b9fa7938f
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_list_modes.phpt
@@ -0,0 +1,26 @@
+--TEST--
+mcrypt_list_modes
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt") || unicode_semantics()) print "skip"; ?>
+--FILE--
+<?php
+var_dump(mcrypt_list_modes());
+--EXPECT--
+array(8) {
+ [0]=>
+ string(3) "cbc"
+ [1]=>
+ string(3) "cfb"
+ [2]=>
+ string(3) "ctr"
+ [3]=>
+ string(3) "ecb"
+ [4]=>
+ string(4) "ncfb"
+ [5]=>
+ string(4) "nofb"
+ [6]=>
+ string(3) "ofb"
+ [7]=>
+ string(6) "stream"
+}
diff --git a/ext/mcrypt/tests/mcrypt_module_get_algo_block_size.phpt b/ext/mcrypt/tests/mcrypt_module_get_algo_block_size.phpt
new file mode 100644
index 0000000000..c89a44ad8a
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_module_get_algo_block_size.phpt
@@ -0,0 +1,19 @@
+--TEST--
+mcrypt_module_get_algo_block_size
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+var_dump(mcrypt_module_get_algo_block_size(MCRYPT_RIJNDAEL_256));
+var_dump(mcrypt_module_get_algo_block_size(MCRYPT_RIJNDAEL_192));
+var_dump(mcrypt_module_get_algo_block_size(MCRYPT_RC2));
+var_dump(mcrypt_module_get_algo_block_size(MCRYPT_XTEA));
+var_dump(mcrypt_module_get_algo_block_size(MCRYPT_CAST_128));
+var_dump(mcrypt_module_get_algo_block_size(MCRYPT_BLOWFISH));
+--EXPECT--
+int(32)
+int(24)
+int(8)
+int(8)
+int(8)
+int(8)
diff --git a/ext/mcrypt/tests/mcrypt_module_get_algo_key_size.phpt b/ext/mcrypt/tests/mcrypt_module_get_algo_key_size.phpt
new file mode 100644
index 0000000000..7d3841f3e2
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_module_get_algo_key_size.phpt
@@ -0,0 +1,19 @@
+--TEST--
+mcrypt_module_get_algo_key_size
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+var_dump(mcrypt_module_get_algo_key_size(MCRYPT_RIJNDAEL_256));
+var_dump(mcrypt_module_get_algo_key_size(MCRYPT_RIJNDAEL_192));
+var_dump(mcrypt_module_get_algo_key_size(MCRYPT_RC2));
+var_dump(mcrypt_module_get_algo_key_size(MCRYPT_XTEA));
+var_dump(mcrypt_module_get_algo_key_size(MCRYPT_CAST_128));
+var_dump(mcrypt_module_get_algo_key_size(MCRYPT_BLOWFISH));
+--EXPECT--
+int(32)
+int(32)
+int(128)
+int(16)
+int(16)
+int(56)
diff --git a/ext/mcrypt/tests/mcrypt_module_get_supported_key_sizes.phpt b/ext/mcrypt/tests/mcrypt_module_get_supported_key_sizes.phpt
new file mode 100644
index 0000000000..bf45bb488e
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_module_get_supported_key_sizes.phpt
@@ -0,0 +1,19 @@
+--TEST--
+mcrypt_module_get_supported_key_sizes
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+var_dump(mcrypt_module_get_supported_key_sizes(MCRYPT_RIJNDAEL_256));
+var_dump(mcrypt_module_get_supported_key_sizes(MCRYPT_RC2));
+--EXPECT--
+array(3) {
+ [0]=>
+ int(16)
+ [1]=>
+ int(24)
+ [2]=>
+ int(32)
+}
+array(0) {
+} \ No newline at end of file
diff --git a/ext/mcrypt/tests/mcrypt_module_is_block_algorithm.phpt b/ext/mcrypt/tests/mcrypt_module_is_block_algorithm.phpt
new file mode 100644
index 0000000000..2cfc87ddf5
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_module_is_block_algorithm.phpt
@@ -0,0 +1,15 @@
+--TEST--
+mcrypt_module_is_block_algorithm
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+var_dump(mcrypt_module_is_block_algorithm(MCRYPT_RIJNDAEL_128));
+var_dump(mcrypt_module_is_block_algorithm(MCRYPT_DES));
+var_dump(mcrypt_module_is_block_algorithm(MCRYPT_WAKE));
+var_dump(mcrypt_module_is_block_algorithm(MCRYPT_XTEA));
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+bool(true) \ No newline at end of file
diff --git a/ext/mcrypt/tests/mcrypt_module_is_block_algorithm_mode.phpt b/ext/mcrypt/tests/mcrypt_module_is_block_algorithm_mode.phpt
new file mode 100644
index 0000000000..2924551414
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_module_is_block_algorithm_mode.phpt
@@ -0,0 +1,15 @@
+--TEST--
+mcrypt_module_is_block_algorithm_mode
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+var_dump(mcrypt_module_is_block_algorithm_mode(MCRYPT_MODE_CBC));
+var_dump(mcrypt_module_is_block_algorithm_mode(MCRYPT_MODE_ECB));
+var_dump(mcrypt_module_is_block_algorithm_mode(MCRYPT_MODE_STREAM));
+var_dump(mcrypt_module_is_block_algorithm_mode(MCRYPT_MODE_OFB));
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+bool(true) \ No newline at end of file
diff --git a/ext/mcrypt/tests/mcrypt_module_is_block_mode.phpt b/ext/mcrypt/tests/mcrypt_module_is_block_mode.phpt
new file mode 100644
index 0000000000..662279f596
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_module_is_block_mode.phpt
@@ -0,0 +1,17 @@
+--TEST--
+mcrypt_module_is_block_mode
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+var_dump(mcrypt_module_is_block_mode(MCRYPT_MODE_CBC));
+var_dump(mcrypt_module_is_block_mode(MCRYPT_MODE_ECB));
+var_dump(mcrypt_module_is_block_mode(MCRYPT_MODE_STREAM));
+var_dump(mcrypt_module_is_block_mode(MCRYPT_MODE_NOFB));
+var_dump(mcrypt_module_is_block_mode(MCRYPT_MODE_OFB));
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(false) \ No newline at end of file
diff --git a/ext/mcrypt/tests/mcrypt_module_open.phpt b/ext/mcrypt/tests/mcrypt_module_open.phpt
new file mode 100644
index 0000000000..92f0d555b3
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_module_open.phpt
@@ -0,0 +1,14 @@
+--TEST--
+mcrypt_module_open
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+var_dump(mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, ''));
+mcrypt_module_open('', '', '', '');
+
+--EXPECTF--
+resource(%d) of type (mcrypt)
+
+Warning: mcrypt_module_open(): Could not open encryption module in %s on line %d
+
diff --git a/ext/mcrypt/tests/mcrypt_module_self_test.phpt b/ext/mcrypt/tests/mcrypt_module_self_test.phpt
new file mode 100644
index 0000000000..cf07bfe6a4
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_module_self_test.phpt
@@ -0,0 +1,13 @@
+--TEST--
+mcrypt_module_self_test
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+var_dump(mcrypt_module_self_test(MCRYPT_RIJNDAEL_128));
+var_dump(mcrypt_module_self_test(MCRYPT_RC2));
+var_dump(mcrypt_module_self_test(''));
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
diff --git a/ext/mcrypt/tests/mcrypt_ofb.phpt b/ext/mcrypt/tests/mcrypt_ofb.phpt
new file mode 100644
index 0000000000..0ed1e191d2
--- /dev/null
+++ b/ext/mcrypt/tests/mcrypt_ofb.phpt
@@ -0,0 +1,21 @@
+--TEST--
+mcrypt_ofb
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt") || unicode_semantics()) print "skip"; ?>
+--FILE--
+<?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_ofb($cipher, $key, $secret, MCRYPT_ENCRYPT, $iv);
+
+// we have to trim as AES rounds the blocks and decrypt doesnt detect that
+echo trim(mcrypt_ofb($cipher, $key, $enc_data, MCRYPT_DECRYPT, $iv)) . "\n";
+
+// a warning must be issued if we don't use a IV on a AES cipher, that usually requires an IV
+mcrypt_ofb($cipher, $key, $enc_data, MCRYPT_DECRYPT, $iv);
+
+--EXPECT--
+PHP Testfest 2008