Skip to content

Commit

Permalink
Use different algorithm in cms tests
Browse files Browse the repository at this point in the history
Same as with pkcs7, switch these tests to use an algorithm that
OpenSSL 3 supports out of the box.

Once again, we should consider changing the default or making it
required.
  • Loading branch information
nikic committed Aug 5, 2021
1 parent 563b3e3 commit ec4d926
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ext/openssl/tests/openssl_cms_decrypt_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ $single_cert = "file://" . __DIR__ . "/cert.crt";
$headers = array("test@test", "testing openssl_cms_encrypt()");
$wrong = "wrong";
$empty = "";
$cipher = OPENSSL_CIPHER_AES_128_CBC;

openssl_cms_encrypt($infile, $encrypted, $single_cert, $headers);
openssl_cms_encrypt($infile, $encrypted, $single_cert, $headers, cipher_algo: $cipher);

var_dump(openssl_cms_decrypt($encrypted, $outfile, $single_cert, $privkey));
print("\nDecrypted text:\n");
Expand Down
3 changes: 2 additions & 1 deletion ext/openssl/tests/openssl_cms_encrypt_der.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ $decryptfile = $tname . ".out";
$single_cert = "file://" . __DIR__ . "/cert.crt";
$privkey = "file://" . __DIR__ . "/private_rsa_1024.key";
$headers = array("test@test", "testing openssl_cms_encrypt()");
$cipher = OPENSSL_CIPHER_AES_128_CBC;

var_dump(openssl_cms_encrypt($infile, $cryptfile, $single_cert, $headers, OPENSSL_CMS_BINARY, OPENSSL_ENCODING_DER));
var_dump(openssl_cms_encrypt($infile, $cryptfile, $single_cert, $headers, OPENSSL_CMS_BINARY, OPENSSL_ENCODING_DER, $cipher));
if (openssl_cms_decrypt($cryptfile, $decryptfile, $single_cert, $privkey, OPENSSL_ENCODING_DER) == false) {
print "DER decrypt error\n";
print "recipient:\n";
Expand Down
3 changes: 2 additions & 1 deletion ext/openssl/tests/openssl_cms_encrypt_pem.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ $decryptfile = $tname . ".pemout";
$single_cert = "file://" . __DIR__ . "/cert.crt";
$privkey = "file://" . __DIR__ . "/private_rsa_1024.key";
$headers = array("test@test", "testing openssl_cms_encrypt()");
$cipher = OPENSSL_CIPHER_AES_128_CBC;

var_dump(openssl_cms_encrypt($infile, $cryptfile, $single_cert, $headers, OPENSSL_CMS_BINARY, OPENSSL_ENCODING_PEM));
var_dump(openssl_cms_encrypt($infile, $cryptfile, $single_cert, $headers, OPENSSL_CMS_BINARY, OPENSSL_ENCODING_PEM, $cipher));
if (openssl_cms_decrypt($cryptfile, $decryptfile, $single_cert, $privkey, OPENSSL_ENCODING_PEM) == false) {
print "PEM decrypt error\n";
print "recipient:\n";
Expand Down

0 comments on commit ec4d926

Please sign in to comment.