X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=test%2Frecipes%2F80-test_cms.t;h=f038bea31d5b774ed55ef220ad1f814032c4a39e;hb=665d899fa6d3571da016925067ebcf1789d7d19c;hp=cc2786fbdb1ab462610a66e17ab03a6282e2a5b9;hpb=fd99c6b599a8ed87b726caaa6d88c6915a60e0f4;p=openssl.git diff --git a/test/recipes/80-test_cms.t b/test/recipes/80-test_cms.t index cc2786fbdb..f038bea31d 100644 --- a/test/recipes/80-test_cms.t +++ b/test/recipes/80-test_cms.t @@ -1,4 +1,11 @@ -#! /usr/bin/perl +#! /usr/bin/env perl +# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the OpenSSL license (the "License"). You may not use +# this file except in compliance with the License. You can obtain a copy +# in the file LICENSE in the source distribution or at +# https://www.openssl.org/source/license.html + use strict; use warnings; @@ -6,15 +13,18 @@ use warnings; use POSIX; use File::Spec::Functions qw/catfile/; use File::Compare qw/compare_text/; -use OpenSSL::Test qw/:DEFAULT top_dir top_file/; +use OpenSSL::Test qw/:DEFAULT srctop_dir srctop_file/; +use OpenSSL::Test::Utils; setup("test_cms"); -my $smdir = top_dir("test", "smime-certs"); -my $smcont = top_file("test", "smcont.txt"); -my $no_ec = run(app(["openssl", "no-ec"], stdout => undef)); -my $no_ec2m = run(app(["openssl", "no-ec2m"], stdout => undef)); -my $no_ecdh = run(app(["openssl", "no-ecdh"], stdout => undef)); +plan skip_all => "CMS is not supported by this OpenSSL build" + if disabled("cms"); + +my $smdir = srctop_dir("test", "smime-certs"); +my $smcont = srctop_file("test", "smcont.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/; plan tests => 4; @@ -59,7 +69,7 @@ my @smime_pkcs7_tests = ( "-content", $smcont ] ], - [ "signed detached content DER format, add RSA signer", + [ "signed detached content DER format, add RSA signer (with DSA existing)", [ "-resign", "-inform", "DER", "-in", "test.cms", "-outform", "DER", "-signer", catfile($smdir, "smrsa1.pem"), "-out", "test2.cms" ], [ "-verify", "-in", "test2.cms", "-inform", "DER", @@ -97,6 +107,14 @@ my @smime_pkcs7_tests = ( "-CAfile", catfile($smdir, "smroot.pem"), "-out", "smtst.txt" ] ], + [ "signed content S/MIME format, RSA key SHA1", + [ "-sign", "-in", $smcont, "-md", "sha1", + "-certfile", catfile($smdir, "smroot.pem"), + "-signer", catfile($smdir, "smrsa1.pem"), "-out", "test.cms" ], + [ "-verify", "-in", "test.cms", + "-CAfile", catfile($smdir, "smroot.pem"), "-out", "smtst.txt" ] + ], + [ "signed content test streaming S/MIME format, 2 DSA and 2 RSA keys", [ "-sign", "-in", $smcont, "-nodetach", "-signer", catfile($smdir, "smrsa1.pem"), @@ -119,7 +137,7 @@ my @smime_pkcs7_tests = ( "-CAfile", catfile($smdir, "smroot.pem"), "-out", "smtst.txt" ] ], - [ "enveloped content test streaming S/MIME format, 3 recipients", + [ "enveloped content test streaming S/MIME format, DES, 3 recipients", [ "-encrypt", "-in", $smcont, "-stream", "-out", "test.cms", catfile($smdir, "smrsa1.pem"), @@ -129,7 +147,7 @@ my @smime_pkcs7_tests = ( "-in", "test.cms", "-out", "smtst.txt" ] ], - [ "enveloped content test streaming S/MIME format, 3 recipients, 3rd used", + [ "enveloped content test streaming S/MIME format, DES, 3 recipients, 3rd used", [ "-encrypt", "-in", $smcont, "-stream", "-out", "test.cms", catfile($smdir, "smrsa1.pem"), @@ -139,7 +157,7 @@ my @smime_pkcs7_tests = ( "-in", "test.cms", "-out", "smtst.txt" ] ], - [ "enveloped content test streaming S/MIME format, 3 recipients, key only used", + [ "enveloped content test streaming S/MIME format, DES, 3 recipients, key only used", [ "-encrypt", "-in", $smcont, "-stream", "-out", "test.cms", catfile($smdir, "smrsa1.pem"), @@ -201,7 +219,7 @@ my @smime_cms_tests = ( "-CAfile", catfile($smdir, "smroot.pem") ] ], - [ "enveloped content test streaming S/MIME format, 3 recipients, keyid", + [ "enveloped content test streaming S/MIME format, DES, 3 recipients, keyid", [ "-encrypt", "-in", $smcont, "-stream", "-out", "test.cms", "-keyid", catfile($smdir, "smrsa1.pem"), @@ -306,7 +324,7 @@ my @smime_cms_param_tests = ( "-CAfile", catfile($smdir, "smroot.pem"), "-out", "smtst.txt" ] ], - [ "enveloped content test streaming S/MIME format, OAEP default parameters", + [ "enveloped content test streaming S/MIME format, DES, OAEP default parameters", [ "-encrypt", "-in", $smcont, "-stream", "-out", "test.cms", "-recip", catfile($smdir, "smrsa1.pem"), "-keyopt", "rsa_padding_mode:oaep" ], @@ -314,7 +332,7 @@ my @smime_cms_param_tests = ( "-in", "test.cms", "-out", "smtst.txt" ] ], - [ "enveloped content test streaming S/MIME format, OAEP SHA256", + [ "enveloped content test streaming S/MIME format, DES, OAEP SHA256", [ "-encrypt", "-in", $smcont, "-stream", "-out", "test.cms", "-recip", catfile($smdir, "smrsa1.pem"), "-keyopt", "rsa_padding_mode:oaep", @@ -323,7 +341,7 @@ my @smime_cms_param_tests = ( "-in", "test.cms", "-out", "smtst.txt" ] ], - [ "enveloped content test streaming S/MIME format, ECDH", + [ "enveloped content test streaming S/MIME format, DES, ECDH", [ "-encrypt", "-in", $smcont, "-stream", "-out", "test.cms", "-recip", catfile($smdir, "smec1.pem") ], @@ -331,7 +349,16 @@ my @smime_cms_param_tests = ( "-in", "test.cms", "-out", "smtst.txt" ] ], - [ "enveloped content test streaming S/MIME format, ECDH, key identifier", + [ "enveloped content test streaming S/MIME format, DES, ECDH, 2 recipients, key only used", + [ "-encrypt", "-in", $smcont, + "-stream", "-out", "test.cms", + catfile($smdir, "smec1.pem"), + catfile($smdir, "smec3.pem") ], + [ "-decrypt", "-inkey", catfile($smdir, "smec3.pem"), + "-in", "test.cms", "-out", "smtst.txt" ] + ], + + [ "enveloped content test streaming S/MIME format, ECDH, DES, key identifier", [ "-encrypt", "-keyid", "-in", $smcont, "-stream", "-out", "test.cms", "-recip", catfile($smdir, "smec1.pem") ], @@ -442,10 +469,9 @@ subtest "CMS <=> CMS consistency tests, modified key parameters\n" => sub { SKIP: { skip("Zlib not supported: compression tests skipped", scalar @smime_cms_comp_tests) - unless grep /ZLIB/, run(app(["openssl", "version", "-f"]), - capture => 1); + if $no_zlib; - foreach (@smime_cms_param_tests) { + foreach (@smime_cms_comp_tests) { SKIP: { my $skip_reason = check_availability($$_[0]); skip $skip_reason, 1 if $skip_reason; @@ -467,10 +493,19 @@ sub check_availability { my $tnam = shift; return "$tnam: skipped, EC disabled\n" - if ($no_ec && $tnam =~ /ECDH/); + if ($no_ec && $tnam =~ /ECDH/); return "$tnam: skipped, ECDH disabled\n" - if ($no_ecdh && $tnam =~ /ECDH/); + if ($no_ec && $tnam =~ /ECDH/); return "$tnam: skipped, EC2M disabled\n" - if ($no_ec2m && $tnam =~ /K-283/); + if ($no_ec2m && $tnam =~ /K-283/); + return "$tnam: skipped, DH disabled\n" + if ($no_dh && $tnam =~ /X9\.42/); + return "$tnam: skipped, RC2 disabled\n" + if ($no_rc2 && $tnam =~ /RC2/); + return "$tnam: skipped, DES disabled\n" + if ($no_des && $tnam =~ /DES/); + return "$tnam: skipped, DSA disabled\n" + if ($no_dsa && $tnam =~ / DSA/); + return ""; }