summaryrefslogtreecommitdiff
path: root/ext/openssl/tests
diff options
context:
space:
mode:
authorJakub Zelenka <bukka@php.net>2017-04-24 17:14:22 +0100
committerJakub Zelenka <bukka@php.net>2017-04-24 17:14:22 +0100
commit2e727b9be149cfbbe8c7410ef1b0a519fb5c0c7e (patch)
treed5f578e6b958092a95927454eb4c43f3f876cf0d /ext/openssl/tests
parent8f20eb0ea1482f857bd522538947829aa41d1da0 (diff)
parent7260f65c62477b6127d2b787ceea88b13d171539 (diff)
downloadphp-git-2e727b9be149cfbbe8c7410ef1b0a519fb5c0c7e.tar.gz
Merge branch 'PHP-7.1'
Diffstat (limited to 'ext/openssl/tests')
-rw-r--r--ext/openssl/tests/bug73833.phpt30
1 files changed, 30 insertions, 0 deletions
diff --git a/ext/openssl/tests/bug73833.phpt b/ext/openssl/tests/bug73833.phpt
new file mode 100644
index 0000000000..e6a298fdcc
--- /dev/null
+++ b/ext/openssl/tests/bug73833.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug #73833: null character not allowed in openssl_pkey_get_private
+--SKIPIF--
+<?php
+if (!extension_loaded("openssl")) die("skip openssl not loaded");
+?>
+--FILE--
+<?php
+$passwords = ["abc\x00defghijkl", "abcdefghikjl"];
+
+foreach($passwords as $password) {
+ $key = openssl_pkey_new();
+
+ if (openssl_pkey_export($key, $privatePEM, $password) === false) {
+ echo "Failed to encrypt.\n";
+ } else {
+ echo "Encrypted!\n";
+ }
+ if (openssl_pkey_get_private($privatePEM, $password) === false) {
+ echo "Failed to decrypt.\n";
+ } else {
+ echo "Decrypted!\n";
+ }
+}
+?>
+--EXPECT--
+Encrypted!
+Decrypted!
+Encrypted!
+Decrypted!