mirror of
https://github.com/php/php-src.git
synced 2025-01-13 22:44:36 +08:00
3c42f64e6e
Mainly use spaces for indent and fix some other CS issues. Also drop checks for unsupported OpenSSL library versions.
32 lines
748 B
PHP
32 lines
748 B
PHP
--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"];
|
|
$conf = ['config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'];
|
|
|
|
foreach($passwords as $password) {
|
|
$key = openssl_pkey_new($conf);
|
|
|
|
if (openssl_pkey_export($key, $privatePEM, $password, $conf) === 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!
|