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 
25 /* Include necessary system files.  */
26 
27 #include "nx_secure_tls.h"
28 
29 /* Bring in externs for caller checking code.  */
30 
31 NX_SECURE_CALLER_CHECKING_EXTERNS
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _nxe_secure_tls_remote_certificate_free_all         PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Timothy Stapko, Microsoft Corporation                               */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function checks for errors in the TLS remote certificate       */
46 /*    free all call.                                                      */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    tls_session                           Pointer to TLS Session        */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    status                                Completion status             */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    _nx_secure_tls_remote_certificate_free_all                          */
59 /*                                          Actual remote certificate     */
60 /*                                            free call                   */
61 /*                                                                        */
62 /*  CALLED BY                                                             */
63 /*                                                                        */
64 /*    Application Code                                                    */
65 /*                                                                        */
66 /*  RELEASE HISTORY                                                       */
67 /*                                                                        */
68 /*    DATE              NAME                      DESCRIPTION             */
69 /*                                                                        */
70 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
71 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
72 /*                                            resulting in version 6.1    */
73 /*                                                                        */
74 /**************************************************************************/
_nxe_secure_tls_remote_certificate_free_all(NX_SECURE_TLS_SESSION * tls_session)75 UINT _nxe_secure_tls_remote_certificate_free_all(NX_SECURE_TLS_SESSION *tls_session)
76 {
77 UINT status;
78 
79     /* Make sure we have a valid TLS session. */
80     if (tls_session == NX_NULL)
81     {
82         return(NX_PTR_ERROR);
83     }
84 
85     /* Make sure the session is initialized. */
86     if(tls_session -> nx_secure_tls_id != NX_SECURE_TLS_ID)
87     {
88         return(NX_SECURE_TLS_SESSION_UNINITIALIZED);
89     }
90 
91     /* Check for appropriate caller.  */
92     NX_THREADS_ONLY_CALLER_CHECKING
93 
94     /* Call the actual function. */
95     status =  _nx_secure_tls_remote_certificate_free_all(tls_session);
96 
97     /* Return completion status.  */
98     return(status);
99 }
100 
101