One of the MDC2 test applications can be done using evp_test.
This makes it so.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10831)
/* 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)
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;
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;
}
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()))
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;
+++ /dev/null
-#! /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");
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))
--- /dev/null
+#
+# 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