1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/***************************************************************************/
/* Copyright (c) 2024 Microsoft Corporation */
/* Copyright (c) 2026 Eclipse ThreadX contributors */
/* */
/* This program and the accompanying materials are made available under */
/* the terms of the MIT License which is available at */
/* https://opensource.org/licenses/MIT. */
/* */
/* SPDX-License-Identifier: MIT */
/***************************************************************************/
#include <stdio.h>
#include "nx_crypto_sha2.h"
#include "tls_test_utility.h"
#define MAXIMUM_PLAIN_BYTES 256
#include "nx_secure_sha224_test_data.c"
/* Define software SHA224 method. */
extern NX_CRYPTO_METHOD crypto_method_sha224;
/* SHA context. */
static NX_CRYPTO_SHA256 sha224_ctx;
/* Output. */
static ULONG output[7];
#ifndef NX_CRYPTO_STANDALONE_ENABLE
static TX_THREAD thread_0;
#endif
static VOID thread_0_entry(ULONG thread_input);
#ifdef CTEST
void test_application_define(void *first_unused_memory);
void test_application_define(void *first_unused_memory)
#else
void nx_secure_sha224_test_application_define(void *first_unused_memory)
#endif
{
#ifndef NX_CRYPTO_STANDALONE_ENABLE
tx_thread_create(&thread_0, "Thread 0", thread_0_entry, 0,
first_unused_memory, 4096,
16, 16, 4, TX_AUTO_START);
#else
thread_0_entry(0);
#endif
}
static VOID thread_0_entry(ULONG thread_input)
{
UINT i;
/* Print out test information banner. */
printf("NetX Secure Test: SHA224 Test........................................");
for (i = 0; i < sizeof(sha224_data) / sizeof(SHA224_DATA); i++)
{
/* Authentication. */
memset(output, 0xFF, sizeof(output));
crypto_method_sha224.nx_crypto_operation(NX_CRYPTO_AUTHENTICATE,
NX_CRYPTO_NULL,
&crypto_method_sha224,
NX_CRYPTO_NULL,
0,
sha224_data[i].plain,
sha224_data[i].plain_len,
NX_CRYPTO_NULL,
(UCHAR *)output,
sizeof(output),
&sha224_ctx,
sizeof(sha224_ctx),
NX_CRYPTO_NULL, NX_CRYPTO_NULL);
EXPECT_EQ(0, memcmp(output, sha224_data[i].secret, sizeof(output)));
}
printf("SUCCESS!\n");
test_control_return(0);
}
|