[openssl] master update

Richard Levitte levitte at openssl.org
Fri Oct 16 17:08:18 UTC 2020


The branch master has been updated
       via  b40498c6e7c6726cc4fc8fef5346f743fdd48aaf (commit)
      from  372e72b19ee0b3584370fdea85e8be7dcf8b445b (commit)


- Log -----------------------------------------------------------------
commit b40498c6e7c6726cc4fc8fef5346f743fdd48aaf
Author: Richard Levitte <levitte at openssl.org>
Date:   Thu Oct 15 16:53:29 2020 +0200

    TEST: modify tconversion.pl for forensics
    
    In the interest of finding out what went wrong with a test by looking
    at its output, tconversion.pl is modified to take arguments in option
    form, and gets an additional -prefix option that callers can use to
    ensure output files are uniquely named.
    
    Test recipes are modified to use these new options.
    
    Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
    (Merged from https://github.com/openssl/openssl/pull/13147)

-----------------------------------------------------------------------

Summary of changes:
 test/recipes/15-test_dsa.t   | 17 ++++++++++------
 test/recipes/15-test_ec.t    | 48 +++++++++++++++++++++++++++++---------------
 test/recipes/15-test_rsa.t   | 12 +++++++----
 test/recipes/25-test_crl.t   |  2 +-
 test/recipes/25-test_pkcs7.t |  6 ++++--
 test/recipes/25-test_req.t   |  3 ++-
 test/recipes/25-test_sid.t   |  3 ++-
 test/recipes/25-test_x509.t  |  9 ++++++---
 test/recipes/tconversion.pl  | 35 ++++++++++++++++++++------------
 9 files changed, 88 insertions(+), 47 deletions(-)

diff --git a/test/recipes/15-test_dsa.t b/test/recipes/15-test_dsa.t
index c99b320a5c..b2747e3d46 100644
--- a/test/recipes/15-test_dsa.t
+++ b/test/recipes/15-test_dsa.t
@@ -26,17 +26,22 @@ ok(run(test(["dsa_no_digest_size_test"])),
    "running dsa_no_digest_size_test");
 
 subtest "dsa conversions using 'openssl dsa' -- private key" => sub {
-    tconversion("dsa", srctop_file("test","testdsa.pem"));
+    tconversion( -type => 'dsa', -prefix => 'dsa-priv',
+                 -in => srctop_file("test","testdsa.pem") );
 };
 subtest "dsa conversions using 'openssl dsa' -- public key" => sub {
-    tconversion("msb", srctop_file("test","testdsapub.pem"), "dsa",
-                "-pubin", "-pubout");
+    tconversion( -type => 'msb', -prefix => 'dsa-msb-pub',
+                 -in => srctop_file("test","testdsapub.pem"),
+                 -args => ["dsa", "-pubin", "-pubout"] );
 };
 
 subtest "dsa conversions using 'openssl pkey' -- private key PKCS#8" => sub {
-    tconversion("dsa", srctop_file("test","testdsa.pem"), "pkey");
+    tconversion( -type => 'dsa', -prefix => 'dsa-pkcs8',
+                 -in => srctop_file("test","testdsa.pem"),
+                 -args => ["pkey"] );
 };
 subtest "dsa conversions using 'openssl pkey' -- public key" => sub {
-    tconversion("dsa", srctop_file("test","testdsapub.pem"), "pkey",
-                "-pubin", "-pubout");
+    tconversion( -type => 'dsa', -prefix => 'dsa-pkey-pub',
+                 -in => srctop_file("test","testdsapub.pem"),
+                 -args => ["pkey", "-pubin", "-pubout"] );
 };
diff --git a/test/recipes/15-test_ec.t b/test/recipes/15-test_ec.t
index c65814f602..5a042d1d4d 100644
--- a/test/recipes/15-test_ec.t
+++ b/test/recipes/15-test_ec.t
@@ -30,14 +30,18 @@ SKIP: {
         if disabled("ec");
 
     subtest 'EC conversions -- private key' => sub {
-        tconversion("ec", srctop_file("test","testec-p256.pem"));
+        tconversion( -type => 'ec', -prefix => 'ec-priv',
+                     -in => srctop_file("test","testec-p256.pem") );
     };
     subtest 'EC conversions -- private key PKCS#8' => sub {
-        tconversion("ec", srctop_file("test","testec-p256.pem"), "pkey");
+        tconversion( -type => 'ec', -prefix => 'ec-pkcs8',
+                     -in => srctop_file("test","testec-p256.pem"),
+                     -args => "pkey" );
     };
     subtest 'EC conversions -- public key' => sub {
-        tconversion("ec", srctop_file("test","testecpub-p256.pem"),
-                    "ec", "-pubin", "-pubout");
+        tconversion( -type => 'ec', -prefix => 'ec-pub',
+                     -in => srctop_file("test","testecpub-p256.pem"),
+                     -args => [ "ec", "-pubin", "-pubout" ] );
     };
 }
 
@@ -46,14 +50,18 @@ SKIP: {
         if disabled("ec");
 
     subtest 'PKEY conversions -- private key' => sub {
-        tconversion("pkey", srctop_file("test","testec-p256.pem"));
+        tconversion( -type => 'pkey', -prefix => 'ec-pkey-priv',
+                     -in => srctop_file("test","testec-p256.pem") );
     };
     subtest 'PKEY conversions -- private key PKCS#8' => sub {
-        tconversion("pkey", srctop_file("test","testec-p256.pem"), "pkey");
+        tconversion( -type => 'pkey', -prefix => 'ec-pkey-pkcs8',
+                     -in => srctop_file("test","testec-p256.pem"),
+                     -args => "pkey" );
     };
     subtest 'PKEY conversions -- public key' => sub {
-        tconversion("pkey", srctop_file("test","testecpub-p256.pem"),
-                    "pkey", "-pubin", "-pubout");
+        tconversion( -type => 'pkey', -prefix => 'ec-pkey-pub',
+                     -in => srctop_file("test","testecpub-p256.pem"),
+                     -args => [ "pkey", "-pubin", "-pubout" ] );
     };
 }
 
@@ -62,24 +70,32 @@ SKIP: {
         if disabled("ec");
 
     subtest 'Ed25519 conversions -- private key' => sub {
-        tconversion("pkey", srctop_file("test", "tested25519.pem"));
+        tconversion( -type => "pkey", -prefix => "ed25519-pkey-priv",
+                     -in => srctop_file("test", "tested25519.pem") );
     };
     subtest 'Ed25519 conversions -- private key PKCS#8' => sub {
-        tconversion("pkey", srctop_file("test", "tested25519.pem"), "pkey");
+        tconversion( -type => "pkey", -prefix => "ed25519-pkey-pkcs8",
+                     -in => srctop_file("test", "tested25519.pem"),
+                     -args => ["pkey"] );
     };
     subtest 'Ed25519 conversions -- public key' => sub {
-        tconversion("pkey", srctop_file("test", "tested25519pub.pem"),
-                    "pkey", "-pubin", "-pubout");
+        tconversion( -type => "pkey", -prefix => "ed25519-pkey-pub",
+                     -in => srctop_file("test", "tested25519pub.pem"),
+                     -args => ["pkey", "-pubin", "-pubout"] );
     };
 
     subtest 'Ed448 conversions -- private key' => sub {
-        tconversion("pkey", srctop_file("test", "tested448.pem"));
+        tconversion( -type => "pkey", -prefix => "ed448-pkey-priv",
+                     -in => srctop_file("test", "tested448.pem") );
     };
     subtest 'Ed448 conversions -- private key PKCS#8' => sub {
-        tconversion("pkey", srctop_file("test", "tested448.pem"), "pkey");
+        tconversion( -type => "pkey", -prefix => "ed448-pkey-pkcs8",
+                     -in => srctop_file("test", "tested448.pem"),
+                     -args => ["pkey"] );
     };
     subtest 'Ed448 conversions -- public key' => sub {
-        tconversion("pkey", srctop_file("test", "tested448pub.pem"),
-                    "pkey", "-pubin", "-pubout");
+        tconversion( -type => "pkey", -prefix => "ed448-pkey-pub",
+                     -in => srctop_file("test", "tested448pub.pem"),
+                     -args => ["pkey", "-pubin", "-pubout"] );
     };
 }
diff --git a/test/recipes/15-test_rsa.t b/test/recipes/15-test_rsa.t
index 2f94e6b088..7e554579d8 100644
--- a/test/recipes/15-test_rsa.t
+++ b/test/recipes/15-test_rsa.t
@@ -37,10 +37,13 @@ sub run_rsa_tests {
 	     if disabled("rsa");
 
          subtest "$cmd conversions -- private key" => sub {
-	     tconversion($cmd, srctop_file("test", "testrsa.pem"));
+	     tconversion( -type => $cmd, -prefix => "$cmd-priv",
+                          -in => srctop_file("test", "testrsa.pem") );
          };
          subtest "$cmd conversions -- private key PKCS#8" => sub {
-	     tconversion($cmd, srctop_file("test", "testrsa.pem"), "pkey");
+	     tconversion( -type => $cmd, -prefix => "$cmd-pkcs8",
+                          -in => srctop_file("test", "testrsa.pem"),
+                          -args => ["pkey"] );
          };
     }
 
@@ -49,8 +52,9 @@ sub run_rsa_tests {
 	     if disabled($cmd) || disabled("dsa") || $cmd == 'pkey';
 
          subtest "$cmd conversions -- public key" => sub {
-	     tconversion("msb", srctop_file("test", "testrsapub.pem"), "rsa",
-		         "-pubin", "-pubout");
+	     tconversion( -type => 'msb', -prefix => "$cmd-msb-pub",
+                          -in => srctop_file("test", "testrsapub.pem"),
+                          -args => ["rsa", "-pubin", "-pubout"] );
          };
     }
 }
diff --git a/test/recipes/25-test_crl.t b/test/recipes/25-test_crl.t
index b7e805cbc9..4b487867f5 100644
--- a/test/recipes/25-test_crl.t
+++ b/test/recipes/25-test_crl.t
@@ -24,7 +24,7 @@ my $out = "cyrillic_crl.out";
 my $utf = srctop_file("test/certs", "cyrillic_crl.utf8");
 
 subtest 'crl conversions' => sub {
-    tconversion("crl", srctop_file("test","testcrl.pem"));
+    tconversion( -type => "crl", -in => srctop_file("test","testcrl.pem") );
 };
 
 ok(run(test(['crltest'])));
diff --git a/test/recipes/25-test_pkcs7.t b/test/recipes/25-test_pkcs7.t
index df15545c39..1d2a757d9f 100644
--- a/test/recipes/25-test_pkcs7.t
+++ b/test/recipes/25-test_pkcs7.t
@@ -20,8 +20,10 @@ plan tests => 3;
 require_ok(srctop_file('test','recipes','tconversion.pl'));
 
 subtest 'pkcs7 conversions -- pkcs7' => sub {
-    tconversion("p7", srctop_file("test", "testp7.pem"), "pkcs7");
+    tconversion( -type => 'p7', -in => srctop_file("test", "testp7.pem"),
+                 -args => ["pkcs7"] );
 };
 subtest 'pkcs7 conversions -- pkcs7d' => sub {
-    tconversion("p7d", srctop_file("test", "pkcs7-1.pem"), "pkcs7");
+    tconversion( -type => 'p7d', -in => srctop_file("test", "pkcs7-1.pem"),
+                 -args => ["pkcs7"] );
 };
diff --git a/test/recipes/25-test_req.t b/test/recipes/25-test_req.t
index 8d26be2bf0..b5d63fe1da 100644
--- a/test/recipes/25-test_req.t
+++ b/test/recipes/25-test_req.t
@@ -237,7 +237,8 @@ sub run_conversion {
             plan skip_all => "skipping req conversion test for $reqfile"
                 if grep /Unknown Public Key/, map { s/\R//; } <DATA>;
 
-            tconversion("req", $reqfile, @openssl_args);
+            tconversion( -type => 'req', -in => $reqfile,
+                         -args => [ @openssl_args ] );
         }
         close DATA;
         unlink "req-check.err";
diff --git a/test/recipes/25-test_sid.t b/test/recipes/25-test_sid.t
index 82f567f114..7d35e98c2d 100644
--- a/test/recipes/25-test_sid.t
+++ b/test/recipes/25-test_sid.t
@@ -24,5 +24,6 @@ plan tests => 2;
 require_ok(srctop_file('test','recipes','tconversion.pl'));
 
 subtest 'sid conversions' => sub {
-    tconversion("sid", srctop_file("test","testsid.pem"), "sess_id");
+    tconversion( -type => 'sid', -in => srctop_file("test","testsid.pem"),
+                 -args => ["sess_id"] );
 };
diff --git a/test/recipes/25-test_x509.t b/test/recipes/25-test_x509.t
index f5b4245960..896c5a1e6a 100644
--- a/test/recipes/25-test_x509.t
+++ b/test/recipes/25-test_x509.t
@@ -72,13 +72,16 @@ SKIP: {
 }
 
 subtest 'x509 -- x.509 v1 certificate' => sub {
-    tconversion("x509", srctop_file("test","testx509.pem"));
+    tconversion( -type => 'x509', -prefix => 'x509v1',
+                 -in => srctop_file("test","testx509.pem") );
 };
 subtest 'x509 -- first x.509 v3 certificate' => sub {
-    tconversion("x509", srctop_file("test","v3-cert1.pem"));
+    tconversion( -type => 'x509', -prefix => 'x509v3-1',
+                 -in => srctop_file("test","v3-cert1.pem") );
 };
 subtest 'x509 -- second x.509 v3 certificate' => sub {
-    tconversion("x509", srctop_file("test","v3-cert2.pem"));
+    tconversion( -type => 'x509', -prefix => 'x509v3-2',
+                 -in => srctop_file("test","v3-cert2.pem") );
 };
 
 subtest 'x509 -- pathlen' => sub {
diff --git a/test/recipes/tconversion.pl b/test/recipes/tconversion.pl
index 828c822c9c..d3b64590da 100644
--- a/test/recipes/tconversion.pl
+++ b/test/recipes/tconversion.pl
@@ -21,14 +21,23 @@ my %conversionforms = (
     "msb"	=> [ "d", "p", "msblob" ],
     );
 sub tconversion {
-    my $testtype = shift;
-    my $t = shift;
+    my %opts = @_;
+
+    die "Missing option -type" unless $opts{-type};
+    die "Missing option -in" unless $opts{-in};
+    my $testtype = $opts{-type};
+    my $t = $opts{-in};
+    my $prefix = $opts{-prefix} // $testtype;
     my @conversionforms =
 	defined($conversionforms{$testtype}) ?
 	@{$conversionforms{$testtype}} :
 	@{$conversionforms{"*"}};
-    my @openssl_args = @_;
-    if (!@openssl_args) { @openssl_args = ($testtype); }
+    my @openssl_args;
+    if (defined $opts{-args}) {
+        @openssl_args = @{$opts{-args}} if ref $opts{-args} eq 'ARRAY';
+        @openssl_args = ($opts{-args}) if ref $opts{-args} eq '';
+    }
+    @openssl_args = ($testtype) unless @openssl_args;
 
     my $n = scalar @conversionforms;
     my $totaltests =
@@ -44,13 +53,13 @@ sub tconversion {
 
     my $init;
     if (scalar @openssl_args > 0 && $openssl_args[0] eq "pkey") {
-	$init = ok(run(app([@cmd, "-in", $t, "-out", "$testtype-fff.p"])),
+	$init = ok(run(app([@cmd, "-in", $t, "-out", "$prefix-fff.p"])),
 		   'initializing');
     } else {
-	$init = ok(copy($t, "$testtype-fff.p"), 'initializing');
+	$init = ok(copy($t, "$prefix-fff.p"), 'initializing');
     }
     if (!$init) {
-	diag("Trying to copy $t to $testtype-fff.p : $!");
+	diag("Trying to copy $t to $prefix-fff.p : $!");
     }
 
   SKIP: {
@@ -58,9 +67,9 @@ sub tconversion {
 
       foreach my $to (@conversionforms) {
 	  ok(run(app([@cmd,
-		      "-in", "$testtype-fff.p",
+		      "-in", "$prefix-fff.p",
 		      "-inform", "p",
-		      "-out", "$testtype-f.$to",
+		      "-out", "$prefix-f.$to",
 		      "-outform", $to])),
 	     "p -> $to");
       }
@@ -68,23 +77,23 @@ sub tconversion {
       foreach my $to (@conversionforms) {
 	  foreach my $from (@conversionforms) {
 	      ok(run(app([@cmd,
-			  "-in", "$testtype-f.$from",
+			  "-in", "$prefix-f.$from",
 			  "-inform", $from,
-			  "-out", "$testtype-ff.$from$to",
+			  "-out", "$prefix-ff.$from$to",
 			  "-outform", $to])),
 		 "$from -> $to");
 	  }
       }
 
       if ($testtype ne "p7d") {
-	  is(cmp_text("$testtype-fff.p", "$testtype-f.p"), 0,
+	  is(cmp_text("$prefix-fff.p", "$prefix-f.p"), 0,
 	     'comparing orig to p');
       }
 
       foreach my $to (@conversionforms) {
 	  next if $to eq "d";
 	  foreach my $from (@conversionforms) {
-	      is(cmp_text("$testtype-f.$to", "$testtype-ff.$from$to"), 0,
+	      is(cmp_text("$prefix-f.$to", "$prefix-ff.$from$to"), 0,
 		 "comparing $to to $from$to");
 	  }
       }


More information about the openssl-commits mailing list