mirror of
https://github.com/openssl/openssl.git
synced 2024-11-21 01:15:20 +08:00
Fix smime-type for AuthEnvelopedData
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/25482)
This commit is contained in:
parent
f5a8f65b80
commit
7f62adaf2b
@ -300,6 +300,8 @@ int SMIME_write_ASN1_ex(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
|
||||
|
||||
if (ctype_nid == NID_pkcs7_enveloped) {
|
||||
msg_type = "enveloped-data";
|
||||
} else if (ctype_nid == NID_id_smime_ct_authEnvelopedData) {
|
||||
msg_type = "authEnveloped-data";
|
||||
} else if (ctype_nid == NID_pkcs7_signed) {
|
||||
if (econt_nid == NID_id_smime_ct_receipt)
|
||||
msg_type = "signed-receipt";
|
||||
|
@ -623,6 +623,7 @@ my @smime_cms_param_tests = (
|
||||
"-stream", "-out", "{output}.cms",
|
||||
"-recip", catfile($smdir, "smec1.pem"), "-aes128",
|
||||
"-keyopt", "ecdh_kdf_md:sha256" ],
|
||||
sub { my %opts = @_; smimeType_matches("$opts{output}.cms", "enveloped-data"); },
|
||||
[ "{cmd2}", @defaultprov, "-decrypt", "-recip", catfile($smdir, "smec1.pem"),
|
||||
"-in", "{output}.cms", "-out", "{output}.txt" ],
|
||||
\&final_compare
|
||||
@ -632,6 +633,7 @@ my @smime_cms_param_tests = (
|
||||
[ "{cmd1}", @defaultprov, "-encrypt", "-in", $smcont,
|
||||
"-stream", "-out", "{output}.cms",
|
||||
"-recip", catfile($smdir, "smec1.pem"), "-aes-128-gcm", "-keyopt", "ecdh_kdf_md:sha256" ],
|
||||
sub { my %opts = @_; smimeType_matches("$opts{output}.cms", "authEnveloped-data"); },
|
||||
[ "{cmd2}", "-decrypt", "-recip", catfile($smdir, "smec1.pem"),
|
||||
"-in", "{output}.cms", "-out", "{output}.txt" ],
|
||||
\&final_compare
|
||||
@ -835,6 +837,28 @@ sub contentType_matches {
|
||||
return scalar(@c);
|
||||
}
|
||||
|
||||
# Returns 1 if the smime-type matches the passed parameter, otherwise 0.
|
||||
sub smimeType_matches {
|
||||
my ($in, $expected_smime_type) = @_;
|
||||
|
||||
# Read the text file
|
||||
open(my $fh, '<', $in) or die("open failed for $in : $!");
|
||||
local $/;
|
||||
my $content = <$fh>;
|
||||
close($fh);
|
||||
|
||||
# Extract the Content-Type line with the smime-type attribute
|
||||
if ($content =~ /Content-Type:\s*application\/pkcs7-mime.*smime-type=([^\s;]+)/) {
|
||||
my $smime_type = $1;
|
||||
|
||||
# Compare the extracted smime-type with the expected value
|
||||
return ($smime_type eq $expected_smime_type) ? 1 : 0;
|
||||
}
|
||||
|
||||
# If no smime-type is found, return 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub rsapssSaltlen {
|
||||
my ($in) = @_;
|
||||
my $exit = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user