]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/mdc2_internal_test.c
Fix various typos, repeated words, align some spelling to LDP.
[thirdparty/openssl.git] / test / mdc2_internal_test.c
CommitLineData
97f1e971 1/*
33388b44 2 * Copyright 2016-2020 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
33ee9ae0
P
12/*
13 * MDC2 low level APIs are deprecated for public use, but still ok for
14 * internal use.
15 */
16#include "internal/deprecated.h"
17
97f1e971
RL
18#include <stdio.h>
19#include <string.h>
20
21#include <openssl/mdc2.h>
22#include "testutil.h"
176db6dc 23#include "internal/nelem.h"
97f1e971
RL
24
25typedef struct {
26 const char *input;
27 const unsigned char expected[MDC2_DIGEST_LENGTH];
28} TESTDATA;
29
97f1e971
RL
30
31/**********************************************************************
32 *
33 * Test driver
34 *
35 ***/
36
37static TESTDATA tests[] = {
38 {
39 "Now is the time for all ",
40 {
41 0x42, 0xE5, 0x0C, 0xD2, 0x24, 0xBA, 0xCE, 0xBA,
42 0x76, 0x0B, 0xDD, 0x2B, 0xD4, 0x09, 0x28, 0x1A
43 }
44 }
45};
46
d836d71b
EK
47/**********************************************************************
48 *
49 * Test of mdc2 internal functions
50 *
51 ***/
52
53static int test_mdc2(int idx)
97f1e971 54{
d836d71b
EK
55 unsigned char md[MDC2_DIGEST_LENGTH];
56 MDC2_CTX c;
57 const TESTDATA testdata = tests[idx];
58
59 MDC2_Init(&c);
60 MDC2_Update(&c, (const unsigned char *)testdata.input,
61 strlen(testdata.input));
62 MDC2_Final(&(md[0]), &c);
63
2fae041d
P
64 if (!TEST_mem_eq(testdata.expected, MDC2_DIGEST_LENGTH,
65 md, MDC2_DIGEST_LENGTH)) {
66 TEST_info("mdc2 test %d: unexpected output", idx);
d836d71b
EK
67 return 0;
68 }
69
70 return 1;
97f1e971
RL
71}
72
3cb7c5cf 73int setup_tests(void)
97f1e971 74{
d836d71b 75 ADD_ALL_TESTS(test_mdc2, OSSL_NELEM(tests));
ad887416 76 return 1;
97f1e971 77}