summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-12-02 22:08:25 +0100
committerTomas Mraz <tomas@openssl.org>2021-12-06 16:39:20 +0100
commitd635d7481b66a6326087196f616d09c240126b74 (patch)
tree7a5ae47adcb2d7752b0e922f19e5fdc48982b0c8
parent13f0d76361b000ee8cfec0d08cb2a84bacf7fb8b (diff)
test_rsa: Test for PVK format conversion
Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17181) (cherry picked from commit a44eb8421d0e84c069a5fa55ced796878e6b0966)
-rw-r--r--test/recipes/15-test_rsa.t20
-rw-r--r--test/recipes/tconversion.pl6
2 files changed, 21 insertions, 5 deletions
diff --git a/test/recipes/15-test_rsa.t b/test/recipes/15-test_rsa.t
index 301368b69b..420a57f8c1 100644
--- a/test/recipes/15-test_rsa.t
+++ b/test/recipes/15-test_rsa.t
@@ -16,7 +16,7 @@ use OpenSSL::Test::Utils;
setup("test_rsa");
-plan tests => 10;
+plan tests => 12;
require_ok(srctop_file('test', 'recipes', 'tconversion.pl'));
@@ -32,7 +32,7 @@ sub run_rsa_tests {
ok(run(app([ 'openssl', $cmd, '-check', '-in', srctop_file('test', 'testrsa.pem'), '-noout'])),
"$cmd -check" );
- SKIP: {
+ SKIP: {
skip "Skipping $cmd conversion test", 3
if disabled("rsa");
@@ -47,7 +47,7 @@ sub run_rsa_tests {
};
}
- SKIP: {
+ SKIP: {
skip "Skipping msblob conversion test", 1
if disabled($cmd) || $cmd eq 'pkey';
@@ -57,4 +57,18 @@ sub run_rsa_tests {
-args => ["rsa", "-pubin", "-pubout"] );
};
}
+ SKIP: {
+ skip "Skipping PVK conversion test", 1
+ if disabled($cmd) || $cmd eq 'pkey' || disabled("rc4")
+ || disabled ("legacy");
+
+ subtest "$cmd conversions -- private key" => sub {
+ tconversion( -type => 'pvk', -prefix => "$cmd-pvk",
+ -in => srctop_file("test", "testrsa.pem"),
+ -args => ["rsa", "-passin", "pass:testpass",
+ "-passout", "pass:testpass",
+ "-provider", "default",
+ "-provider", "legacy"] );
+ };
+ }
}
diff --git a/test/recipes/tconversion.pl b/test/recipes/tconversion.pl
index 87b037b34d..78be03178c 100644
--- a/test/recipes/tconversion.pl
+++ b/test/recipes/tconversion.pl
@@ -19,6 +19,7 @@ my %conversionforms = (
# specific test types as key.
"*" => [ "d", "p" ],
"msb" => [ "d", "p", "msblob" ],
+ "pvk" => [ "d", "p", "pvk" ],
);
sub tconversion {
my %opts = @_;
@@ -45,8 +46,9 @@ sub tconversion {
+ $n # initial conversions from p to all forms (A)
+ $n*$n # conversion from result of A to all forms (B)
+ 1 # comparing original test file to p form of A
- + $n*($n-1); # comparing first conversion to each fom in A with B
+ + $n*($n-1); # comparing first conversion to each form in A with B
$totaltests-- if ($testtype eq "p7d"); # no comparison of original test file
+ $totaltests -= $n if ($testtype eq "pvk"); # no comparisons of the pvk form
plan tests => $totaltests;
my @cmd = ("openssl", @openssl_args);
@@ -91,7 +93,7 @@ sub tconversion {
}
foreach my $to (@conversionforms) {
- next if $to eq "d";
+ next if $to eq "d" or $to eq "pvk";
foreach my $from (@conversionforms) {
is(cmp_text("$prefix-f.$to", "$prefix-ff.$from$to"), 0,
"comparing $to to $from$to");