]> granicus.if.org Git - php/commitdiff
tests for bug #55169 (mcrypt and openssl)
authorRyan Biesemeyer <yaauie@php.net>
Wed, 20 Jul 2011 18:59:05 +0000 (18:59 +0000)
committerRyan Biesemeyer <yaauie@php.net>
Wed, 20 Jul 2011 18:59:05 +0000 (18:59 +0000)
ext/mcrypt/tests/bug55169.phpt [new file with mode: 0644]
ext/openssl/tests/bug55169.phpt [new file with mode: 0644]

diff --git a/ext/mcrypt/tests/bug55169.phpt b/ext/mcrypt/tests/bug55169.phpt
new file mode 100644 (file)
index 0000000..7bddd50
--- /dev/null
@@ -0,0 +1,43 @@
+--TEST--\r
+mcrypt_create_iv\r
+https://bugs.php.net/bug.php?id=55169\r
+--CREDIT--\r
+Ryan Biesemeyer <ryan@yaauie.com>\r
+--FILE--\r
+<?php\r
+for( $i=1; $i<=64; $i = $i*2 ){\r
+  echo 'Input: '. $i . PHP_EOL;\r
+  $random = mcrypt_create_iv( $i, MCRYPT_DEV_URANDOM );\r
+  echo ' Length: ' . strlen( $random ) . PHP_EOL;\r
+  echo ' Hex: '. bin2hex( $random ) . PHP_EOL;\r
+  echo PHP_EOL;\r
+}\r
+?>\r
+--EXPECTF--\r
+Input: 1\r
+ Length: 1\r
+ Hex: %x\r
+\r
+Input: 2\r
+ Length: 2\r
+ Hex: %x\r
+\r
+Input: 4\r
+ Length: 4\r
+ Hex: %x\r
+\r
+Input: 8\r
+ Length: 8\r
+ Hex: %x\r
+\r
+Input: 16\r
+ Length: 16\r
+ Hex: %x\r
+\r
+Input: 32\r
+ Length: 32\r
+ Hex: %x\r
+\r
+Input: 64\r
+ Length: 64\r
+ Hex: %x\r
diff --git a/ext/openssl/tests/bug55169.phpt b/ext/openssl/tests/bug55169.phpt
new file mode 100644 (file)
index 0000000..39c0700
--- /dev/null
@@ -0,0 +1,43 @@
+--TEST--\r
+openssl_random_pseudo_bytes test\r
+https://bugs.php.net/bug.php?id=55169\r
+--INI--\r
+extension=php_openssl.dll\r
+--SKIPIF--\r
+if(!extension_loaded('openssl')) echo 'skip - requires openssl extension'\r
+--FILE--\r
+<?php\r
+for ($i = -1; $i <= 4; $i++) {\r
+    $bytes = openssl_random_pseudo_bytes($i, $cstrong);\r
+    $hex   = bin2hex($bytes);\r
+\r
+    echo "Lengths: Bytes: $i and Hex: " . strlen($hex) . PHP_EOL;\r
+    var_dump($hex);\r
+    var_dump($cstrong);\r
+    echo PHP_EOL;\r
+}\r
+?>\r
+--EXPECTF--\r
+Lengths: Bytes: -1 and Hex: 0\r
+string(0) ""\r
+NULL\r
+\r
+Lengths: Bytes: 0 and Hex: 0\r
+string(0) ""\r
+NULL\r
+\r
+Lengths: Bytes: 1 and Hex: 2\r
+string(2) "%x"\r
+bool(true)\r
+\r
+Lengths: Bytes: 2 and Hex: 4\r
+string(4) "%x"\r
+bool(true)\r
+\r
+Lengths: Bytes: 3 and Hex: 6\r
+string(6) "%x"\r
+bool(true)\r
+\r
+Lengths: Bytes: 4 and Hex: 8\r
+string(8) "%x"\r
+bool(true)\r