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 /** Transport Layer Security (TLS) */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define NX_SECURE_SOURCE_CODE
23
24 #include "nx_secure_tls.h"
25
26 /**************************************************************************/
27 /* */
28 /* FUNCTION RELEASE */
29 /* */
30 /* _nx_secure_tls_session_create PORTABLE C */
31 /* 6.1 */
32 /* AUTHOR */
33 /* */
34 /* Timothy Stapko, Microsoft Corporation */
35 /* */
36 /* DESCRIPTION */
37 /* */
38 /* This function initializes a TLS session control block for later */
39 /* use in establishing a secure TLS session over a TCP socket or */
40 /* other lower-level networking protocol. */
41 /* */
42 /* To calculate the necessary metadata size, the API */
43 /* nx_secure_tls_metadata_size_calculate may be used. */
44 /* */
45 /* INPUT */
46 /* */
47 /* session_ptr TLS session control block */
48 /* crypto_table crypto method table */
49 /* metadata_buffer Encryption metadata area */
50 /* metadata_size Encryption metadata size */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* status Completion status */
55 /* */
56 /* CALLS */
57 /* */
58 /* _nx_secure_tls_session_reset Clear out the session */
59 /* tx_mutex_get Get protection mutex */
60 /* tx_mutex_put Put protection mutex */
61 /* */
62 /* CALLED BY */
63 /* */
64 /* Application Code */
65 /* _nx_secure_dtls_session_create Create DTLS session */
66 /* */
67 /* RELEASE HISTORY */
68 /* */
69 /* DATE NAME DESCRIPTION */
70 /* */
71 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */
72 /* 09-30-2020 Timothy Stapko Modified comment(s), */
73 /* resulting in version 6.1 */
74 /* */
75 /**************************************************************************/
_nx_secure_tls_session_create(NX_SECURE_TLS_SESSION * session_ptr,const NX_SECURE_TLS_CRYPTO * crypto_table,VOID * metadata_buffer,ULONG metadata_size)76 UINT _nx_secure_tls_session_create(NX_SECURE_TLS_SESSION *session_ptr,
77 const NX_SECURE_TLS_CRYPTO *crypto_table,
78 VOID *metadata_buffer,
79 ULONG metadata_size)
80 {
81 UINT status;
82
83 NX_SECURE_MEMSET(session_ptr, 0, sizeof(NX_SECURE_TLS_SESSION));
84
85 /* Assign the table to the session. */
86 /* Cast away "const" for new API. */
87 session_ptr -> nx_secure_tls_crypto_table = (NX_SECURE_TLS_CRYPTO *)(crypto_table);
88
89 status = _nx_secure_tls_session_create_ext(session_ptr, NX_NULL, 0, NX_NULL, 0, metadata_buffer, metadata_size);
90
91 return(status);
92 }
93
94