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 /* _nx_secure_dtls_server_ecc_initialize PORTABLE C */
31 /* 6.1 */
32 /* AUTHOR */
33 /* */
34 /* Timothy Stapko, Microsoft Corporation */
35 /* */
36 /* DESCRIPTION */
37 /* */
38 /* This function initializes supported curve lists for DTLS server */
39 /* instance. */
40 /* */
41 /* INPUT */
42 /* */
43 /* server_ptr DTLS server control block */
44 /* supported_groups List of supported groups */
45 /* supported_group_count Number of supported groups */
46 /* curves List of curve methods */
47 /* */
48 /* OUTPUT */
49 /* */
50 /* status Completion status */
51 /* */
52 /* CALLS */
53 /* */
54 /* _nx_secure_tls_ecc_initialize Initialize curve lists */
55 /* */
56 /* CALLED BY */
57 /* */
58 /* Application Code */
59 /* */
60 /* RELEASE HISTORY */
61 /* */
62 /* DATE NAME DESCRIPTION */
63 /* */
64 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */
65 /* 09-30-2020 Timothy Stapko Modified comment(s), */
66 /* resulting in version 6.1 */
67 /* */
68 /**************************************************************************/
_nx_secure_dtls_server_ecc_initialize(NX_SECURE_DTLS_SERVER * server_ptr,const USHORT * supported_groups,USHORT supported_group_count,const NX_CRYPTO_METHOD ** curves)69 UINT _nx_secure_dtls_server_ecc_initialize(NX_SECURE_DTLS_SERVER *server_ptr,
70 const USHORT *supported_groups, USHORT supported_group_count,
71 const NX_CRYPTO_METHOD **curves)
72 {
73 #if defined(NX_SECURE_ENABLE_DTLS) && defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE)
74 UINT status;
75 UINT i;
76 NX_SECURE_DTLS_SESSION *current_session;
77 NX_SECURE_TLS_SESSION *tls_session;
78 UINT num_sessions;
79
80 /* Figure out number of sessions. */
81 num_sessions = server_ptr -> nx_dtls_server_sessions_count;
82
83 /* Initialize curve list for all sessions. */
84 for(i = 0; i < num_sessions; ++i)
85 {
86 /* Get the current session. */
87 current_session = &(server_ptr -> nx_dtls_server_sessions[i]);
88
89 /* Get the internal TLS session instance. */
90 tls_session = &(current_session -> nx_secure_dtls_tls_session);
91
92 /* Initialize supported curve list for TLS. */
93 status = _nx_secure_tls_ecc_initialize(tls_session, supported_groups, supported_group_count, curves);
94
95 if(status != NX_SUCCESS)
96 {
97 return(status);
98 }
99 }
100
101 return(NX_SUCCESS);
102 #else
103 NX_PARAMETER_NOT_USED(server_ptr);
104 NX_PARAMETER_NOT_USED(supported_groups);
105 NX_PARAMETER_NOT_USED(supported_group_count);
106 NX_PARAMETER_NOT_USED(curves);
107
108 return(NX_NOT_SUPPORTED);
109 #endif /* NX_SECURE_ENABLE_DTLS && NX_SECURE_ENABLE_ECC_CIPHERSUITE */
110 }
111
112