mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-11 19:06:27 +08:00
Add PHP Extension for GmSSL
View http://gmssl.org/docs/php-api.html for more info.
This commit is contained in:
31
php/ext/openssl/tests/bug73833.phpt
Normal file
31
php/ext/openssl/tests/bug73833.phpt
Normal file
@@ -0,0 +1,31 @@
|
||||
--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!
|
||||
Reference in New Issue
Block a user