1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** NetX Secure Component */
16 /** */
17 /** Datagram Transport Layer Security (DTLS) */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define NX_SECURE_SOURCE_CODE
23
24 #include "nx_secure_dtls.h"
25
26 /**************************************************************************/
27 /* */
28 /* FUNCTION RELEASE */
29 /* */
30 /* _nxe_secure_dtls_ecc_initialize PORTABLE C */
31 /* 6.1 */
32 /* AUTHOR */
33 /* */
34 /* Timothy Stapko, Microsoft Corporation */
35 /* */
36 /* DESCRIPTION */
37 /* */
38 /* This function checks for errors when initializing ECC for DTLS. */
39 /* */
40 /* INPUT */
41 /* */
42 /* dtls_session DTLS session control block */
43 /* supported_groups List of supported groups */
44 /* supported_group_count Number of supported groups */
45 /* curves List of curve methods */
46 /* */
47 /* OUTPUT */
48 /* */
49 /* status Completion status */
50 /* */
51 /* CALLS */
52 /* */
53 /* _nx_secure_dtls_ecc_initialize Actual function call */
54 /* */
55 /* CALLED BY */
56 /* */
57 /* Application Code */
58 /* */
59 /* RELEASE HISTORY */
60 /* */
61 /* DATE NAME DESCRIPTION */
62 /* */
63 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */
64 /* 09-30-2020 Timothy Stapko Modified comment(s), */
65 /* resulting in version 6.1 */
66 /* */
67 /**************************************************************************/
_nxe_secure_dtls_ecc_initialize(NX_SECURE_DTLS_SESSION * dtls_session,const USHORT * supported_groups,USHORT supported_group_count,const NX_CRYPTO_METHOD ** curves)68 UINT _nxe_secure_dtls_ecc_initialize(NX_SECURE_DTLS_SESSION *dtls_session,
69 const USHORT *supported_groups, USHORT supported_group_count,
70 const NX_CRYPTO_METHOD **curves)
71 {
72 #if defined(NX_SECURE_ENABLE_DTLS) && defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE)
73 UINT status;
74
75 /* Check pointers. */
76 if (dtls_session == NX_NULL)
77 {
78 return(NX_PTR_ERROR);
79 }
80
81 if (supported_group_count > 0 &&
82 (supported_groups == NX_NULL || curves == NX_NULL))
83 {
84 return(NX_PTR_ERROR);
85 }
86
87 /* Call actual function. */
88 status = _nx_secure_dtls_ecc_initialize(dtls_session, supported_groups, supported_group_count, curves);
89
90 return(status);
91 #else
92 NX_PARAMETER_NOT_USED(dtls_session);
93 NX_PARAMETER_NOT_USED(supported_groups);
94 NX_PARAMETER_NOT_USED(supported_group_count);
95 NX_PARAMETER_NOT_USED(curves);
96
97 return(NX_NOT_SUPPORTED);
98 #endif /* NX_SECURE_ENABLE_DTLS && NX_SECURE_ENABLE_ECC_CIPHERSUITE */
99 }
100
101