[openssl] master update

Richard Levitte levitte at openssl.org
Wed Dec 11 17:45:58 UTC 2019


The branch master has been updated
       via  ef1e59ed833e8ed1d5f4de5b0c734da8561890e3 (commit)
       via  81722fdf2e01cfa71c46abbcc19e65aa003e083f (commit)
      from  098404128383ded87ba390dd74ecd9e2ffa6f530 (commit)


- Log -----------------------------------------------------------------
commit ef1e59ed833e8ed1d5f4de5b0c734da8561890e3
Author: Nicola Tuveri <nic.tuv at gmail.com>
Date:   Mon Nov 11 15:52:52 2019 +0200

    More testing for sign/verify through `dgst` and `pkeyutl`
    
    Add tests for signature generation and verification with `dgst` and
    `pkeyutl` CLI for common key types:
    - RSA
    - DSA
    - ECDSA
    - EdDSA
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/10410)

commit 81722fdf2e01cfa71c46abbcc19e65aa003e083f
Author: Nicola Tuveri <nic.tuv at gmail.com>
Date:   Mon Nov 11 12:13:10 2019 +0200

    More testing for CLI usage of Ed25519 and Ed448 keys
    
    Add testing for the `req` app and explicit conversion tests similar to
    what is done for ECDSA keys.
    
    The included test keys for Ed25519 are from the examples in RFC 8410
    (Sec. 10)
    
    The key for Ed448 is derived from the first of the test vectors in
    RFC 8032 (Sec. 7.4) using OpenSSL to encode it into PEM format.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/10410)

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

Summary of changes:
 test/recipes/15-test_ec.t                          |  56 ++++++++---
 test/recipes/20-test_dgst.t                        | 104 ++++++++++++++++++++
 test/recipes/20-test_pkeyutl.t                     | 105 ++++++++++++++++++++-
 test/recipes/25-test_req.t                         |  42 ++++++++-
 .../root-ed25519.privkey.pem => tested25519.pem}   |   0
 .../root-ed25519.pubkey.pem => tested25519pub.pem} |   0
 test/tested448.pem                                 |   4 +
 test/tested448pub.pem                              |   4 +
 8 files changed, 299 insertions(+), 16 deletions(-)
 create mode 100644 test/recipes/20-test_dgst.t
 copy test/{certs/root-ed25519.privkey.pem => tested25519.pem} (100%)
 copy test/{certs/root-ed25519.pubkey.pem => tested25519pub.pem} (100%)
 create mode 100644 test/tested448.pem
 create mode 100644 test/tested448pub.pem

diff --git a/test/recipes/15-test_ec.t b/test/recipes/15-test_ec.t
index 34846e2d33..327a8850e0 100644
--- a/test/recipes/15-test_ec.t
+++ b/test/recipes/15-test_ec.t
@@ -16,23 +16,51 @@ use OpenSSL::Test::Utils;
 
 setup("test_ec");
 
-plan tests => 5;
+plan tests => 11;
 
 require_ok(srctop_file('test','recipes','tconversion.pl'));
 
 ok(run(test(["ectest"])), "running ectest");
 
- SKIP: {
-     skip "Skipping ec conversion test", 3
-	 if disabled("ec");
-
-     subtest 'ec conversions -- private key' => sub {
-	 tconversion("ec", srctop_file("test","testec-p256.pem"));
-     };
-     subtest 'ec conversions -- private key PKCS#8' => sub {
-	 tconversion("ec", srctop_file("test","testec-p256.pem"), "pkey");
-     };
-     subtest 'ec conversions -- public key' => sub {
-	 tconversion("ec", srctop_file("test","testecpub-p256.pem"), "ec", "-pubin", "-pubout");
-     };
+SKIP: {
+    skip "Skipping EC conversion test", 3
+        if disabled("ec");
+
+    subtest 'EC conversions -- private key' => sub {
+        tconversion("ec", srctop_file("test","testec-p256.pem"));
+    };
+    subtest 'EC conversions -- private key PKCS#8' => sub {
+        tconversion("ec", srctop_file("test","testec-p256.pem"), "pkey");
+    };
+    subtest 'EC conversions -- public key' => sub {
+        tconversion("ec", srctop_file("test","testecpub-p256.pem"),
+                    "ec", "-pubin", "-pubout");
+    };
+}
+
+SKIP: {
+    skip "Skipping EdDSA conversion test", 6
+        if disabled("ec");
+
+    subtest 'Ed25519 conversions -- private key' => sub {
+        tconversion("pkey", srctop_file("test","tested25519.pem"));
+    };
+    subtest 'Ed25519 conversions -- private key PKCS#8' => sub {
+        tconversion("pkey", srctop_file("test","tested25519.pem"), "pkey");
+    };
+    subtest 'Ed25519 conversions -- public key' => sub {
+        tconversion("pkey", srctop_file("test","tested25519pub.pem"),
+                    "pkey", "-pubin", "-pubout");
+    };
+
+    subtest 'Ed448 conversions -- private key' => sub {
+        tconversion("pkey", srctop_file("test","tested448.pem"));
+    };
+    subtest 'Ed448 conversions -- private key PKCS#8' => sub {
+        tconversion("pkey", srctop_file("test","tested448.pem"), "pkey");
+    };
+    subtest 'Ed448 conversions -- public key' => sub {
+        tconversion("pkey", srctop_file("test","tested448pub.pem"),
+                    "pkey", "-pubin", "-pubout");
+    };
 }
diff --git a/test/recipes/20-test_dgst.t b/test/recipes/20-test_dgst.t
new file mode 100644
index 0000000000..1080770f53
--- /dev/null
+++ b/test/recipes/20-test_dgst.t
@@ -0,0 +1,104 @@
+#! /usr/bin/env perl
+# Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the Apache License 2.0 (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;
+
+use File::Spec;
+use OpenSSL::Test qw/:DEFAULT with srctop_file/;
+use OpenSSL::Test::Utils;
+
+setup("test_dgst");
+
+plan tests => 5;
+
+sub tsignverify {
+    my $testtext = shift;
+    my $privkey = shift;
+    my $pubkey = shift;
+
+    my $data_to_sign = srctop_file('test', 'README');
+    my $other_data = srctop_file('test', 'README.external');
+
+    plan tests => 4;
+
+    ok(run(app(['openssl', 'dgst', '-sign', $privkey,
+                '-out', 'testdgst.sig',
+                $data_to_sign])),
+       $testtext.": Generating signature");
+
+    ok(run(app(['openssl', 'dgst', '-prverify', $privkey,
+                '-signature', 'testdgst.sig',
+                $data_to_sign])),
+       $testtext.": Verify signature with private key");
+
+    ok(run(app(['openssl', 'dgst', '-verify', $pubkey,
+                '-signature', 'testdgst.sig',
+                $data_to_sign])),
+       $testtext.": Verify signature with public key");
+
+    ok(!run(app(['openssl', 'dgst', '-verify', $pubkey,
+                 '-signature', 'testdgst.sig',
+                 $other_data])),
+       $testtext.": Expect failure verifying mismatching data");
+
+    unlink 'testdgst.sig';
+}
+
+SKIP: {
+    skip "RSA is not supported by this OpenSSL build", 1
+        if disabled("rsa");
+
+    subtest "RSA signature generation and verification with `dgst` CLI" => sub {
+        tsignverify("RSA",
+                    srctop_file("test","testrsa.pem"),
+                    srctop_file("test","testrsapub.pem"));
+    };
+}
+
+SKIP: {
+    skip "DSA is not supported by this OpenSSL build", 1
+        if disabled("dsa");
+
+    subtest "DSA signature generation and verification with `dgst` CLI" => sub {
+        tsignverify("DSA",
+                    srctop_file("test","testdsa.pem"),
+                    srctop_file("test","testdsapub.pem"));
+    };
+}
+
+SKIP: {
+    skip "ECDSA is not supported by this OpenSSL build", 1
+        if disabled("ec");
+
+    subtest "ECDSA signature generation and verification with `dgst` CLI" => sub {
+        tsignverify("ECDSA",
+                    srctop_file("test","testec-p256.pem"),
+                    srctop_file("test","testecpub-p256.pem"));
+    };
+}
+
+SKIP: {
+    skip "EdDSA is not supported by this OpenSSL build", 2
+        if disabled("ec");
+
+    skip "EdDSA is not supported with `dgst` CLI", 2;
+
+    subtest "Ed25519 signature generation and verification with `dgst` CLI" => sub {
+        tsignverify("Ed25519",
+                    srctop_file("test","tested25519.pem"),
+                    srctop_file("test","tested25519pub.pem"));
+    };
+
+    subtest "Ed448 signature generation and verification with `dgst` CLI" => sub {
+        tsignverify("Ed448",
+                    srctop_file("test","tested448.pem"),
+                    srctop_file("test","tested448pub.pem"));
+    };
+}
diff --git a/test/recipes/20-test_pkeyutl.t b/test/recipes/20-test_pkeyutl.t
index 83804d69ad..0f82b1f21a 100644
--- a/test/recipes/20-test_pkeyutl.t
+++ b/test/recipes/20-test_pkeyutl.t
@@ -15,7 +15,7 @@ use OpenSSL::Test::Utils;
 
 setup("test_pkeyutl");
 
-plan tests => 6;
+plan tests => 11;
 
 # For the tests below we use the cert itself as the TBS file
 
@@ -68,3 +68,106 @@ SKIP: {
 }
 
 unlink 'signature.dat';
+
+sub tsignverify {
+    my $testtext = shift;
+    my $privkey = shift;
+    my $pubkey = shift;
+    my @extraopts = @_;
+
+    my $data_to_sign = srctop_file('test', 'README');
+    my $other_data = srctop_file('test', 'README.external');
+    my $sigfile = 'testpkeyutl.sig';
+
+    my @args = ();
+    plan tests => 4;
+
+    @args = ('openssl', 'pkeyutl', '-sign',
+             '-inkey', $privkey,
+             '-out', $sigfile,
+             '-in', $data_to_sign);
+    push(@args, @extraopts);
+    ok(run(app([@args])),
+       $testtext.": Generating signature");
+
+    @args = ('openssl', 'pkeyutl', '-verify',
+             '-inkey', $privkey,
+             '-sigfile', $sigfile,
+             '-in', $data_to_sign);
+    push(@args, @extraopts);
+    ok(run(app([@args])),
+       $testtext.": Verify signature with private key");
+
+    @args = ('openssl', 'pkeyutl', '-verify',
+             '-inkey', $pubkey, '-pubin',
+             '-sigfile', $sigfile,
+             '-in', $data_to_sign);
+    push(@args, @extraopts);
+    ok(run(app([@args])),
+       $testtext.": Verify signature with public key");
+
+    @args = ('openssl', 'pkeyutl', '-verify',
+             '-inkey', $pubkey, '-pubin',
+             '-sigfile', $sigfile,
+             '-in', $other_data);
+    push(@args, @extraopts);
+    ok(!run(app([@args])),
+       $testtext.": Expect failure verifying mismatching data");
+
+    unlink $sigfile;
+}
+
+SKIP: {
+    skip "RSA is not supported by this OpenSSL build", 1
+        if disabled("rsa");
+
+    subtest "RSA CLI signature generation and verification" => sub {
+        tsignverify("RSA",
+                    srctop_file("test","testrsa.pem"),
+                    srctop_file("test","testrsapub.pem"),
+                    "-rawin", "-digest", "sha256");
+    };
+}
+
+SKIP: {
+    skip "DSA is not supported by this OpenSSL build", 1
+        if disabled("dsa");
+
+    subtest "DSA CLI signature generation and verification" => sub {
+        tsignverify("DSA",
+                    srctop_file("test","testdsa.pem"),
+                    srctop_file("test","testdsapub.pem"),
+                    "-rawin", "-digest", "sha256");
+    };
+}
+
+SKIP: {
+    skip "ECDSA is not supported by this OpenSSL build", 1
+        if disabled("ec");
+
+    subtest "ECDSA CLI signature generation and verification" => sub {
+        tsignverify("ECDSA",
+                    srctop_file("test","testec-p256.pem"),
+                    srctop_file("test","testecpub-p256.pem"),
+                    "-rawin", "-digest", "sha256");
+    };
+}
+
+SKIP: {
+    skip "EdDSA is not supported by this OpenSSL build", 2
+        if disabled("ec");
+
+    subtest "Ed2559 CLI signature generation and verification" => sub {
+        tsignverify("Ed25519",
+                    srctop_file("test","tested25519.pem"),
+                    srctop_file("test","tested25519pub.pem"),
+                    "-rawin");
+    };
+
+    subtest "Ed448 CLI signature generation and verification" => sub {
+        tsignverify("Ed448",
+                    srctop_file("test","tested448.pem"),
+                    srctop_file("test","tested448pub.pem"),
+                    "-rawin");
+    };
+}
diff --git a/test/recipes/25-test_req.t b/test/recipes/25-test_req.t
index 0e085b435d..075c09db6d 100644
--- a/test/recipes/25-test_req.t
+++ b/test/recipes/25-test_req.t
@@ -15,7 +15,7 @@ use OpenSSL::Test qw/:DEFAULT srctop_file/;
 
 setup("test_req");
 
-plan tests => 13;
+plan tests => 15;
 
 require_ok(srctop_file('test','recipes','tconversion.pl'));
 
@@ -102,6 +102,46 @@ subtest "generating certificate requests with ECDSA" => sub {
     }
 };
 
+subtest "generating certificate requests with Ed25519" => sub {
+    plan tests => 2;
+
+    SKIP: {
+        skip "Ed25519 is not supported by this OpenSSL build", 2
+            if disabled("ec");
+
+        ok(run(app(["openssl", "req",
+                    "-config", srctop_file("test", "test.cnf"),
+                    "-new", "-out", "testreq.pem", "-utf8",
+                    "-key", srctop_file("test", "tested25519.pem")])),
+           "Generating request");
+
+        ok(run(app(["openssl", "req",
+                    "-config", srctop_file("test", "test.cnf"),
+                    "-verify", "-in", "testreq.pem", "-noout"])),
+           "Verifying signature on request");
+    }
+};
+
+subtest "generating certificate requests with Ed448" => sub {
+    plan tests => 2;
+
+    SKIP: {
+        skip "Ed448 is not supported by this OpenSSL build", 2
+            if disabled("ec");
+
+        ok(run(app(["openssl", "req",
+                    "-config", srctop_file("test", "test.cnf"),
+                    "-new", "-out", "testreq.pem", "-utf8",
+                    "-key", srctop_file("test", "tested448.pem")])),
+           "Generating request");
+
+        ok(run(app(["openssl", "req",
+                    "-config", srctop_file("test", "test.cnf"),
+                    "-verify", "-in", "testreq.pem", "-noout"])),
+           "Verifying signature on request");
+    }
+};
+
 subtest "generating certificate requests" => sub {
     plan tests => 2;
 
diff --git a/test/certs/root-ed25519.privkey.pem b/test/tested25519.pem
similarity index 100%
copy from test/certs/root-ed25519.privkey.pem
copy to test/tested25519.pem
diff --git a/test/certs/root-ed25519.pubkey.pem b/test/tested25519pub.pem
similarity index 100%
copy from test/certs/root-ed25519.pubkey.pem
copy to test/tested25519pub.pem
diff --git a/test/tested448.pem b/test/tested448.pem
new file mode 100644
index 0000000000..98af16420a
--- /dev/null
+++ b/test/tested448.pem
@@ -0,0 +1,4 @@
+-----BEGIN PRIVATE KEY-----
+MEcCAQAwBQYDK2VxBDsEOWyCpWLLgI0Q1jK+ichRPr9skp803fqMn2PJlg7240ij
+UoyKP8wvBE45o/xblEkvjwMudUmiAJj5Ww==
+-----END PRIVATE KEY-----
diff --git a/test/tested448pub.pem b/test/tested448pub.pem
new file mode 100644
index 0000000000..640da6f2be
--- /dev/null
+++ b/test/tested448pub.pem
@@ -0,0 +1,4 @@
+-----BEGIN PUBLIC KEY-----
+MEMwBQYDK2VxAzoAX9dEm1m0Yf0s54fsYWrUah2hNCSFpw4fig6nXYDpZ3jt8SR2
+m0bHBhvWeD3x5Q9s0foavq/oJWGA
+-----END PUBLIC KEY-----


More information about the openssl-commits mailing list