summaryrefslogtreecommitdiff
path: root/test/regression/nx_secure_test/nx_secure_tls_coverage_3_test.c
blob: 293c2d5acc98bf2ab42e4482d29b05af761579f3 (plain)
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
/***************************************************************************/
/* 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 "nx_api.h"
#include "tls_test_utility.h"
#include "nx_secure_tls_api.h"

static TX_THREAD thread_0;
static VOID thread_0_entry(ULONG thread_input);
static NX_SECURE_TLS_SESSION session_0;

#ifdef CTEST
void test_application_define(void *first_unused_memory);
void test_application_define(void *first_unused_memory)
#else
void nx_secure_tls_coverage_3_test_application_define(void *first_unused_memory)
#endif
{
    tx_thread_create(&thread_0, "Thread 0", thread_0_entry, 0,
        first_unused_memory, 4096,
        8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);
}

static VOID thread_0_entry(ULONG thread_input)
{
UINT status;
UCHAR buffer[100];
USHORT id;

    /* Print out test information banner.  */
    printf("NetX Secure Test:   TLS 1.3 Coverage 3 Test............................");

    _nx_secure_tls_get_signature_algorithm_id(NX_SECURE_TLS_SIGNATURE_RSA_MD5, &id);
    EXPECT_EQ(NX_SECURE_TLS_X509_TYPE_RSA_MD5, id);

    _nx_secure_tls_get_signature_algorithm_id(NX_SECURE_TLS_SIGNATURE_RSA_SHA1, &id);
    EXPECT_EQ(NX_SECURE_TLS_X509_TYPE_RSA_SHA_1, id);

    _nx_secure_tls_get_signature_algorithm_id(NX_SECURE_TLS_SIGNATURE_RSA_SHA384, &id);
    EXPECT_EQ(NX_SECURE_TLS_X509_TYPE_RSA_SHA_384, id);

    _nx_secure_tls_get_signature_algorithm_id(NX_SECURE_TLS_SIGNATURE_RSA_SHA512, &id);
    EXPECT_EQ(NX_SECURE_TLS_X509_TYPE_RSA_SHA_512, id);

    _nx_secure_tls_get_signature_algorithm_id(NX_SECURE_TLS_SIGNATURE_ECDSA_SHA224, &id);
    EXPECT_EQ(NX_SECURE_TLS_X509_TYPE_ECDSA_SHA_224, id);

    _nx_secure_tls_get_signature_algorithm_id(NX_SECURE_TLS_SIGNATURE_ECDSA_SHA384, &id);
    EXPECT_EQ(NX_SECURE_TLS_X509_TYPE_ECDSA_SHA_384, id);

    _nx_secure_tls_get_signature_algorithm_id(NX_SECURE_TLS_SIGNATURE_ECDSA_SHA512, &id);
    EXPECT_EQ(NX_SECURE_TLS_X509_TYPE_ECDSA_SHA_512, id);

    id = 0;
    _nx_secure_tls_get_signature_algorithm_id(0, &id);
    EXPECT_EQ(0, id);

    /* Tests for 4-byte alignment. */
    _nx_secure_tls_session_packet_buffer_set(&session_0, &buffer[1], 7);
    EXPECT_EQ(session_0.nx_secure_tls_packet_buffer, &buffer[4]);
    EXPECT_EQ(session_0.nx_secure_tls_packet_buffer_size, 4);

    printf("SUCCESS!\n");
    test_control_return(0);
};