From: Bernd Edlinger Date: Sun, 10 Aug 2025 16:50:37 +0000 (+0200) Subject: Add test coverage for PKCS7_TEXT mode X-Git-Tag: openssl-3.4.3~73 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=afb3b3af405782a806922a5ebee3a830a422b24b;p=thirdparty%2Fopenssl.git Add test coverage for PKCS7_TEXT mode This was inspired by the following commit 9882d389df71 ("crypto/pkcs7/pk7_smime.c: Add BIO_free() to avoid memory leak") which discovered a bug in PKCS7_verify(..., PKCS7_TEXT). While there is some test coverage for PKCS_verify by ./test/pkcs7_test.c, there is no test coverage whatsoever of the PKCS7_TEXT flag for PKCS7_sign, PKCS7_encrypt and PKCS7_decrypt. So this adds some test coverage for those functions as well. Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/28223) (cherry picked from commit d582adc672bca4bc71a7766bb692558086efdd69) --- diff --git a/test/recipes/80-test_cms.t b/test/recipes/80-test_cms.t index e3899187e0a..8d6149a1582 100644 --- a/test/recipes/80-test_cms.t +++ b/test/recipes/80-test_cms.t @@ -86,6 +86,15 @@ my @smime_pkcs7_tests = ( \&final_compare ], + [ "signed text content DER format, RSA key", + [ "{cmd1}", @prov, "-sign", "-in", $smcont, "-outform", "DER", "-nodetach", + "-certfile", $smroot, "-signer", $smrsa1, "-text", + "-out", "{output}.cms" ], + [ "{cmd2}", @prov, "-verify", "-in", "{output}.cms", "-inform", "DER", + "-text", "-CAfile", $smroot, "-out", "{output}.txt" ], + \&final_compare + ], + [ "signed detached content DER format, RSA key", [ "{cmd1}", @prov, "-sign", "-in", $smcont, "-outform", "DER", "-signer", $smrsa1, "-out", "{output}.cms" ], @@ -219,6 +228,14 @@ my @smime_pkcs7_tests = ( \&final_compare ], + [ "enveloped text content streaming S/MIME format, DES, 1 recipient", + [ "{cmd1}", @defaultprov, "-encrypt", "-in", $smcont, + "-stream", "-text", "-out", "{output}.cms", $smrsa1 ], + [ "{cmd2}", @defaultprov, "-decrypt", "-recip", $smrsa1, + "-in", "{output}.cms", "-text", "-out", "{output}.txt" ], + \&final_compare + ], + [ "enveloped content test streaming S/MIME format, DES, 3 recipients, 3rd used", [ "{cmd1}", @defaultprov, "-encrypt", "-in", $smcont, "-stream", "-out", "{output}.cms",