]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/mdc2_internal_test.c
Fix SSL_check_chain()
[thirdparty/openssl.git] / test / mdc2_internal_test.c
CommitLineData
97f1e971 1/*
83cf7abf 2 * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
97f1e971 3 *
909f1a2e 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
97f1e971
RL
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"
176db6dc 17#include "internal/nelem.h"
97f1e971
RL
18
19typedef struct {
20 const char *input;
21 const unsigned char expected[MDC2_DIGEST_LENGTH];
22} TESTDATA;
23
97f1e971
RL
24
25/**********************************************************************
26 *
27 * Test driver
28 *
29 ***/
30
31static TESTDATA tests[] = {
32 {
33 "Now is the time for all ",
34 {
35 0x42, 0xE5, 0x0C, 0xD2, 0x24, 0xBA, 0xCE, 0xBA,
36 0x76, 0x0B, 0xDD, 0x2B, 0xD4, 0x09, 0x28, 0x1A
37 }
38 }
39};
40
d836d71b
EK
41/**********************************************************************
42 *
43 * Test of mdc2 internal functions
44 *
45 ***/
46
47static int test_mdc2(int idx)
97f1e971 48{
d836d71b
EK
49 unsigned char md[MDC2_DIGEST_LENGTH];
50 MDC2_CTX c;
51 const TESTDATA testdata = tests[idx];
52
53 MDC2_Init(&c);
54 MDC2_Update(&c, (const unsigned char *)testdata.input,
55 strlen(testdata.input));
56 MDC2_Final(&(md[0]), &c);
57
2fae041d
P
58 if (!TEST_mem_eq(testdata.expected, MDC2_DIGEST_LENGTH,
59 md, MDC2_DIGEST_LENGTH)) {
60 TEST_info("mdc2 test %d: unexpected output", idx);
d836d71b
EK
61 return 0;
62 }
63
64 return 1;
97f1e971
RL
65}
66
3cb7c5cf 67int setup_tests(void)
97f1e971 68{
d836d71b 69 ADD_ALL_TESTS(test_mdc2, OSSL_NELEM(tests));
ad887416 70 return 1;
97f1e971 71}