2 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 /* Internal tests for the mdc2 module */
15 #include <openssl/mdc2.h>
21 const unsigned char expected[MDC2_DIGEST_LENGTH];
25 const char *case_name;
30 /**********************************************************************
32 * Test of mdc2 internal functions
36 static SIMPLE_FIXTURE setup_mdc2(const char *const test_case_name)
38 SIMPLE_FIXTURE fixture;
39 fixture.case_name = test_case_name;
43 static int execute_mdc2(SIMPLE_FIXTURE fixture)
45 unsigned char md[MDC2_DIGEST_LENGTH];
49 MDC2_Update(&c, (const unsigned char *)fixture.data->input,
50 strlen(fixture.data->input));
51 MDC2_Final(&(md[0]), &c);
53 if (memcmp(fixture.data->expected, md, MDC2_DIGEST_LENGTH)) {
54 fprintf(stderr, "mdc2 test %d: unexpected output\n", fixture.num);
61 static void teardown_mdc2(SIMPLE_FIXTURE fixture)
63 ERR_print_errors_fp(stderr);
66 /**********************************************************************
72 static TESTDATA tests[] = {
74 "Now is the time for all ",
76 0x42, 0xE5, 0x0C, 0xD2, 0x24, 0xBA, 0xCE, 0xBA,
77 0x76, 0x0B, 0xDD, 0x2B, 0xD4, 0x09, 0x28, 0x1A
82 static int drive_tests(int idx)
84 SETUP_TEST_FIXTURE(SIMPLE_FIXTURE, setup_mdc2);
86 fixture.data = &tests[idx];
87 EXECUTE_TEST(execute_mdc2, teardown_mdc2);
90 int main(int argc, char **argv)
92 ADD_ALL_TESTS(drive_tests, OSSL_NELEM(tests));
94 return run_tests(argv[0]);