mirror of
https://github.com/php/php-src.git
synced 2024-10-16 14:02:37 +00:00
78 lines
2.6 KiB
Plaintext
78 lines
2.6 KiB
Plaintext
|
--TEST--
|
||
|
openssl_pkcs7_decrypt() tests
|
||
|
--SKIPIF--
|
||
|
<?php if (!extension_loaded("openssl")) print "skip"; ?>
|
||
|
--FILE--
|
||
|
<?php
|
||
|
$infile = dirname(__FILE__) . "/cert.crt";
|
||
|
$privkey = "file://" . dirname(__FILE__) . "/private.key";
|
||
|
$encrypted = tempnam(b"/tmp", b"ssl");
|
||
|
if ($encrypted === false)
|
||
|
die("failed to get a temporary filename!");
|
||
|
$outfile = tempnam(b"/tmp", b"ssl");
|
||
|
if ($outfile === false) {
|
||
|
unlink($outfile);
|
||
|
die("failed to get a temporary filename!");
|
||
|
}
|
||
|
|
||
|
$single_cert = "file://" . dirname(__FILE__) . "/cert.crt";
|
||
|
$headers = array("test@test", "testing openssl_pkcs7_encrypt()");
|
||
|
$wrong = "wrong";
|
||
|
$wrong2 = b"wrong";
|
||
|
$empty = b"";
|
||
|
|
||
|
openssl_pkcs7_encrypt($infile, $encrypted, $single_cert, $headers);
|
||
|
var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $privkey));
|
||
|
var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $wrong));
|
||
|
var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $wrong2));
|
||
|
var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $wrong, $privkey));
|
||
|
var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $wrong2, $privkey));
|
||
|
var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, null, $privkey));
|
||
|
var_dump(openssl_pkcs7_decrypt($wrong, $outfile, $single_cert, $privkey));
|
||
|
var_dump(openssl_pkcs7_decrypt($empty, $outfile, $single_cert, $privkey));
|
||
|
var_dump(openssl_pkcs7_decrypt($encrypted, $empty, $single_cert, $privkey));
|
||
|
var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $empty, $privkey));
|
||
|
var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $empty));
|
||
|
|
||
|
if (file_exists($encrypted)) {
|
||
|
echo "true\n";
|
||
|
unlink($encrypted);
|
||
|
}
|
||
|
if (file_exists($outfile)) {
|
||
|
echo "true\n";
|
||
|
unlink($outfile);
|
||
|
}
|
||
|
?>
|
||
|
--EXPECTF--
|
||
|
bool(true)
|
||
|
|
||
|
Warning: openssl_pkcs7_decrypt(): Binary string expected, Unicode string received in %s on line %d
|
||
|
|
||
|
Warning: openssl_pkcs7_decrypt(): unable to get private key in %s on line %d
|
||
|
bool(false)
|
||
|
|
||
|
Warning: openssl_pkcs7_decrypt(): unable to get private key in %s on line %d
|
||
|
bool(false)
|
||
|
|
||
|
Warning: openssl_pkcs7_decrypt(): Binary string expected, Unicode string received in %s on line %d
|
||
|
|
||
|
Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d
|
||
|
bool(false)
|
||
|
|
||
|
Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d
|
||
|
bool(false)
|
||
|
|
||
|
Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d
|
||
|
bool(false)
|
||
|
bool(false)
|
||
|
bool(false)
|
||
|
bool(false)
|
||
|
|
||
|
Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d
|
||
|
bool(false)
|
||
|
|
||
|
Warning: openssl_pkcs7_decrypt(): unable to get private key in %s on line %d
|
||
|
bool(false)
|
||
|
true
|
||
|
true
|