[openssl] master update

Dr. Paul Dale pauli at openssl.org
Sun Jan 19 01:32:19 UTC 2020


The branch master has been updated
       via  ed5cb1776b4759b745984c0c67c2d6453345c0a1 (commit)
      from  08bff785fc2370f743ea5baabd44524412711ae8 (commit)


- Log -----------------------------------------------------------------
commit ed5cb1776b4759b745984c0c67c2d6453345c0a1
Author: Pauli <paul.dale at oracle.com>
Date:   Tue Jan 14 08:01:34 2020 +1000

    mdc2: use evp_test instead of a separate test application.
    
    One of the MDC2 test applications can be done using evp_test.
    This makes it so.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/10831)

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

Summary of changes:
 test/evp_test.c                              | 15 +++++++++++++++
 test/recipes/05-test_mdc2.t                  | 24 ------------------------
 test/recipes/30-test_evp.t                   |  3 +++
 test/recipes/30-test_evp_data/evpmd_mdc2.txt | 27 +++++++++++++++++++++++++++
 4 files changed, 45 insertions(+), 24 deletions(-)
 delete mode 100644 test/recipes/05-test_mdc2.t
 create mode 100644 test/recipes/30-test_evp_data/evpmd_mdc2.txt

diff --git a/test/evp_test.c b/test/evp_test.c
index 43d6c48e84..e4d30fb20d 100644
--- a/test/evp_test.c
+++ b/test/evp_test.c
@@ -331,6 +331,8 @@ typedef struct digest_data_st {
     /* Expected output */
     unsigned char *output;
     size_t output_len;
+    /* Padding type */
+    int pad_type;
 } DIGEST_DATA;
 
 static int digest_test_init(EVP_TEST *t, const char *alg)
@@ -353,6 +355,7 @@ static int digest_test_init(EVP_TEST *t, const char *alg)
     t->data = mdat;
     mdat->digest = digest;
     mdat->fetched_digest = fetched_digest;
+    mdat->pad_type = 0;
     if (fetched_digest != NULL)
         TEST_info("%s is fetched", alg);
     return 1;
@@ -380,6 +383,8 @@ static int digest_test_parse(EVP_TEST *t,
         return evp_test_buffer_set_count(value, mdata->input);
     if (strcmp(keyword, "Ncopy") == 0)
         return evp_test_buffer_ncopy(value, mdata->input);
+    if (strcmp(keyword, "Padding") == 0)
+        return (mdata->pad_type = atoi(value)) > 0;
     return 0;
 }
 
@@ -394,6 +399,7 @@ static int digest_test_run(EVP_TEST *t)
     EVP_MD_CTX *mctx;
     unsigned char *got = NULL;
     unsigned int got_len;
+    OSSL_PARAM params[2];
 
     t->err = "TEST_FAILURE";
     if (!TEST_ptr(mctx = EVP_MD_CTX_new()))
@@ -408,6 +414,15 @@ static int digest_test_run(EVP_TEST *t)
         t->err = "DIGESTINIT_ERROR";
         goto err;
     }
+    if (expected->pad_type > 0) {
+        params[0] = OSSL_PARAM_construct_int(OSSL_DIGEST_PARAM_PAD_TYPE,
+                                              &expected->pad_type);
+        params[1] = OSSL_PARAM_construct_end();
+        if (!TEST_int_gt(EVP_MD_CTX_set_params(mctx, params), 0)) {
+            t->err = "PARAMS_ERROR";
+            goto err;
+        }
+    }
     if (!evp_test_buffer_do(expected->input, digest_update_fn, mctx)) {
         t->err = "DIGESTUPDATE_ERROR";
         goto err;
diff --git a/test/recipes/05-test_mdc2.t b/test/recipes/05-test_mdc2.t
deleted file mode 100644
index 18d9539ddb..0000000000
--- a/test/recipes/05-test_mdc2.t
+++ /dev/null
@@ -1,24 +0,0 @@
-#! /usr/bin/env perl
-# Copyright 2015-2016 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 OpenSSL::Test qw/:DEFAULT bldtop_dir/;
-use OpenSSL::Test::Utils;
-
-setup("test_mdc2");
-
-if (disabled("mdc2") || disabled("legacy")) {
-    plan skip_all => "mdc2 is not supported by this OpenSSL build";
-}
-
-plan tests => 1;
-
-ok(run(test(["mdc2test"])), "running mdc2test");
diff --git a/test/recipes/30-test_evp.t b/test/recipes/30-test_evp.t
index e7759bf5dc..5567cafb3e 100644
--- a/test/recipes/30-test_evp.t
+++ b/test/recipes/30-test_evp.t
@@ -70,6 +70,9 @@ push @defltfiles, @bffiles unless disabled("bf");
 my @bffiles = qw( evpmd_md2.txt );
 push @defltfiles, @bffiles unless disabled("md2");
 
+my @bffiles = qw( evpmd_mdc2.txt );
+push @defltfiles, @bffiles unless disabled("mdc2");
+
 plan tests =>
     ($no_fips ? 0 : 1)          # FIPS install test
     + (scalar(@configs) * scalar(@files))
diff --git a/test/recipes/30-test_evp_data/evpmd_mdc2.txt b/test/recipes/30-test_evp_data/evpmd_mdc2.txt
new file mode 100644
index 0000000000..c0d0544af3
--- /dev/null
+++ b/test/recipes/30-test_evp_data/evpmd_mdc2.txt
@@ -0,0 +1,27 @@
+#
+# Copyright 2020 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
+
+
+Title = MDC2 test vectors
+
+Digest = MDC2
+Availablein = default
+Input = "Now is the time for all "
+Output = 42e50cd224baceba760bdd2bd409281a
+
+Digest = MDC2
+Availablein = default
+Padding = 1
+Input = "Now is the time for all "
+Output = 42e50cd224baceba760bdd2bd409281a
+
+Digest = MDC2
+Availablein = default
+Padding = 2
+Input = "Now is the time for all "
+Output = 2e4679b5add9ca7535d87afeab33bee2


More information about the openssl-commits mailing list