Tests for processing zero-length content in SMIME format

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13087)
This commit is contained in:
Dmitry Belyavskiy 2020-10-07 13:05:28 +03:00
parent 55c61473b5
commit 947fb81345
2 changed files with 17 additions and 0 deletions

View File

@ -45,6 +45,7 @@ my $provname = 'default';
my $datadir = srctop_dir("test", "recipes", "80-test_cms_data");
my $smdir = srctop_dir("test", "smime-certs");
my $smcont = srctop_file("test", "smcont.txt");
my $smcont_zero = srctop_file("test", "smcont_zero.txt");
my ($no_des, $no_dh, $no_dsa, $no_ec, $no_ec2m, $no_rc2, $no_zlib)
= disabled qw/des dh dsa ec ec2m rc2 zlib/;
@ -169,6 +170,15 @@ my @smime_pkcs7_tests = (
\&final_compare
],
[ "signed zero-length content S/MIME format, RSA key SHA1",
[ "{cmd1}", @defaultprov, "-sign", "-in", $smcont_zero, "-md", "sha1",
"-certfile", catfile($smdir, "smroot.pem"),
"-signer", catfile($smdir, "smrsa1.pem"), "-out", "{output}.cms" ],
[ "{cmd2}", @prov, "-verify", "-in", "{output}.cms",
"-CAfile", catfile($smdir, "smroot.pem"), "-out", "{output}.txt" ],
\&zero_compare
],
[ "signed content test streaming S/MIME format, 2 DSA and 2 RSA keys",
[ "{cmd1}", @prov, "-sign", "-in", $smcont, "-nodetach",
"-signer", catfile($smdir, "smrsa1.pem"),
@ -679,6 +689,13 @@ sub final_compare {
return compare_text($smcont, "$opts{output}.txt") == 0;
}
sub zero_compare {
my %opts = @_;
diag "Checking for zero-length file";
return (-e "$opts{output}.txt" && -z "$opts{output}.txt");
}
subtest "CMS => PKCS#7 compatibility tests\n" => sub {
plan tests => scalar @smime_pkcs7_tests;

0
test/smcont_zero.txt Normal file
View File