]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/mdc2_internal_test.c
Re-enable some BoringSSL tests
[thirdparty/openssl.git] / test / mdc2_internal_test.c
CommitLineData
97f1e971
RL
1/*
2 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
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
8 */
9
10/* Internal tests for the mdc2 module */
11
12#include <stdio.h>
13#include <string.h>
14
15#include <openssl/mdc2.h>
16#include "testutil.h"
e364c3b2 17#include "test_main.h"
97f1e971
RL
18#include "e_os.h"
19
20typedef struct {
21 const char *input;
22 const unsigned char expected[MDC2_DIGEST_LENGTH];
23} TESTDATA;
24
97f1e971
RL
25
26/**********************************************************************
27 *
28 * Test driver
29 *
30 ***/
31
32static TESTDATA tests[] = {
33 {
34 "Now is the time for all ",
35 {
36 0x42, 0xE5, 0x0C, 0xD2, 0x24, 0xBA, 0xCE, 0xBA,
37 0x76, 0x0B, 0xDD, 0x2B, 0xD4, 0x09, 0x28, 0x1A
38 }
39 }
40};
41
d836d71b
EK
42/**********************************************************************
43 *
44 * Test of mdc2 internal functions
45 *
46 ***/
47
48static int test_mdc2(int idx)
97f1e971 49{
d836d71b
EK
50 unsigned char md[MDC2_DIGEST_LENGTH];
51 MDC2_CTX c;
52 const TESTDATA testdata = tests[idx];
53
54 MDC2_Init(&c);
55 MDC2_Update(&c, (const unsigned char *)testdata.input,
56 strlen(testdata.input));
57 MDC2_Final(&(md[0]), &c);
58
59 if (memcmp(testdata.expected, md, MDC2_DIGEST_LENGTH)) {
60 fprintf(stderr, "mdc2 test %d: unexpected output\n", idx);
61 return 0;
62 }
63
64 return 1;
97f1e971
RL
65}
66
e364c3b2 67void register_tests()
97f1e971 68{
d836d71b 69 ADD_ALL_TESTS(test_mdc2, OSSL_NELEM(tests));
97f1e971 70}