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 /* Bring in externs for caller checking code.  */
27 
28 NX_SECURE_CALLER_CHECKING_EXTERNS
29 
30 /**************************************************************************/
31 /*                                                                        */
32 /*  FUNCTION                                               RELEASE        */
33 /*                                                                        */
34 /*    _nxe_secure_tls_session_renegotiate                  PORTABLE C     */
35 /*                                                           6.1          */
36 /*  AUTHOR                                                                */
37 /*                                                                        */
38 /*    Timothy Stapko, Microsoft Corporation                               */
39 /*                                                                        */
40 /*  DESCRIPTION                                                           */
41 /*                                                                        */
42 /*    This function checks for errors when the application requests a TLS */
43 /*    session renegotiation.                                              */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    tls_session                           TLS control block             */
48 /*    wait_option                           Suspension option             */
49 /*                                                                        */
50 /*  OUTPUT                                                                */
51 /*                                                                        */
52 /*    status                                Completion status             */
53 /*                                                                        */
54 /*  CALLS                                                                 */
55 /*                                                                        */
56 /*    _nx_secure_tls_session_renegotiate    Actual re-negotiation call    */
57 /*                                                                        */
58 /*  CALLED BY                                                             */
59 /*                                                                        */
60 /*    Application Code                                                    */
61 /*                                                                        */
62 /*  RELEASE HISTORY                                                       */
63 /*                                                                        */
64 /*    DATE              NAME                      DESCRIPTION             */
65 /*                                                                        */
66 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
67 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
68 /*                                            fixed renegotiation bug,    */
69 /*                                            resulting in version 6.1    */
70 /*                                                                        */
71 /**************************************************************************/
72 #ifndef NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION
_nxe_secure_tls_session_renegotiate(NX_SECURE_TLS_SESSION * tls_session,UINT wait_option)73 UINT _nxe_secure_tls_session_renegotiate(NX_SECURE_TLS_SESSION *tls_session, UINT wait_option)
74 {
75 UINT status = NX_SUCCESS;
76 
77     if (tls_session == NX_NULL)
78     {
79         return(NX_PTR_ERROR);
80     }
81 
82     /* Make sure the session is initialized. */
83     if(tls_session -> nx_secure_tls_id != NX_SECURE_TLS_ID)
84     {
85         return(NX_SECURE_TLS_SESSION_UNINITIALIZED);
86     }
87 
88     /* Check for appropriate caller.  */
89     NX_THREADS_ONLY_CALLER_CHECKING
90 
91     status = _nx_secure_tls_session_renegotiate(tls_session, wait_option);
92 
93     return(status);
94 }
95 #endif /* NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION */
96 
97