1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** NetX Secure Component                                                 */
17 /**                                                                       */
18 /**    Transport Layer Security (TLS)                                     */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define NX_SECURE_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "nx_secure_tls.h"
29 
30 /**************************************************************************/
31 /*                                                                        */
32 /*  FUNCTION                                               RELEASE        */
33 /*                                                                        */
34 /*    _nx_secure_tls_session_alert_value_get              PORTABLE C      */
35 /*                                                           6.1          */
36 /*  AUTHOR                                                                */
37 /*                                                                        */
38 /*    Timothy Stapko, Microsoft Corporation                               */
39 /*                                                                        */
40 /*  DESCRIPTION                                                           */
41 /*                                                                        */
42 /*    This function checks for errors in the TLS alert value              */
43 /*    informational API.                                                  */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    tls_session                           Pointer to TLS Session        */
48 /*    alert_value                           Return alert value            */
49 /*    alert_level                           Return alert level            */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    status                                Completion status             */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    None                                                                */
58 /*                                                                        */
59 /*  CALLED BY                                                             */
60 /*                                                                        */
61 /*    Application Code                                                    */
62 /*                                                                        */
63 /*  RELEASE HISTORY                                                       */
64 /*                                                                        */
65 /*    DATE              NAME                      DESCRIPTION             */
66 /*                                                                        */
67 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
68 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
69 /*                                            resulting in version 6.1    */
70 /*                                                                        */
71 /**************************************************************************/
_nx_secure_tls_session_alert_value_get(NX_SECURE_TLS_SESSION * tls_session,UINT * alert_level,UINT * alert_value)72 UINT  _nx_secure_tls_session_alert_value_get(NX_SECURE_TLS_SESSION *tls_session,
73                                              UINT *alert_level, UINT *alert_value)
74 {
75 
76     /* Get the protection. */
77     tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
78 
79     /* Return the current alert value and level to the caller. */
80     *(alert_value) = tls_session -> nx_secure_tls_received_alert_value;
81     *(alert_level) = tls_session -> nx_secure_tls_received_alert_level;
82 
83     /* Release the protection. */
84     tx_mutex_put(&_nx_secure_tls_protection);
85 
86     /* Return completion status.  */
87     return(NX_SUCCESS);
88 }
89 
90