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 #include "nx_secure_tls.h"
26 
27 #ifdef NX_SECURE_KEY_CLEAR
28 /**************************************************************************/
29 /*                                                                        */
30 /*  FUNCTION                                               RELEASE        */
31 /*                                                                        */
32 /*    _nx_secure_tls_packet_release                       PORTABLE C      */
33 /*                                                           6.1          */
34 /*  AUTHOR                                                                */
35 /*                                                                        */
36 /*    Timothy Stapko, Microsoft Corporation                               */
37 /*                                                                        */
38 /*  DESCRIPTION                                                           */
39 /*                                                                        */
40 /*    This function releases packet with all data in the packet cleared.  */
41 /*                                                                        */
42 /*  INPUT                                                                 */
43 /*                                                                        */
44 /*    packet_ptr                            NX_PACKET to release          */
45 /*                                                                        */
46 /*  OUTPUT                                                                */
47 /*                                                                        */
48 /*    status                                Completion status             */
49 /*                                                                        */
50 /*  CALLS                                                                 */
51 /*                                                                        */
52 /*    nx_packet_release                     Release packet                */
53 /*                                                                        */
54 /*  CALLED BY                                                             */
55 /*                                                                        */
56 /*    nx_secure_dtls_client_handshake.c                                   */
57 /*    nx_secure_dtls_process_record.c                                     */
58 /*    nx_secure_dtls_receive_callback.c                                   */
59 /*    nx_secure_dtls_retransmit_queue_flush.c                             */
60 /*    nx_secure_dtls_send_handshake_record.c                              */
61 /*    nx_secure_dtls_send_record.c                                        */
62 /*    nx_secure_dtls_session_end.c                                        */
63 /*    nx_secure_dtls_session_receive.c                                    */
64 /*    nx_secure_dtls_session_reset.c                                      */
65 /*    nx_secure_dtls_session_start.c                                      */
66 /*    nx_secure_tls_1_3_client_handshake.c                                */
67 /*    nx_secure_tls_1_3_server_handshake.c                                */
68 /*    nx_secure_tls_client_handshake.c                                    */
69 /*    nx_secure_tls_handshake_process.c                                   */
70 /*    nx_secure_tls_packet_release.c                                      */
71 /*    nx_secure_tls_process_record.c                                      */
72 /*    nx_secure_tls_record_payload_decrypt.c                              */
73 /*    nx_secure_tls_send_handshake_record.c                               */
74 /*    nx_secure_tls_server_handshake.c                                    */
75 /*    nx_secure_tls_session_end.c                                         */
76 /*    nx_secure_tls_session_receive_records.c                             */
77 /*    nx_secure_tls_session_renegotiate.c                                 */
78 /*    nx_secure_tls_session_start.c                                       */
79 /*                                                                        */
80 /*  RELEASE HISTORY                                                       */
81 /*                                                                        */
82 /*    DATE              NAME                      DESCRIPTION             */
83 /*                                                                        */
84 /*  05-19-2020     Timothy Stapko           Initial Version 6.1           */
85 /*                                                                        */
86 /**************************************************************************/
_nx_secure_tls_packet_release(NX_PACKET * packet_ptr)87 UINT _nx_secure_tls_packet_release(NX_PACKET *packet_ptr)
88 {
89 NX_PACKET *current_packet;
90 
91     /* Clear all data in chained packet. */
92     current_packet = packet_ptr;
93     while (current_packet)
94     {
95         NX_SECURE_MEMSET(current_packet -> nx_packet_data_start, 0,
96                          (ULONG)current_packet -> nx_packet_data_end -
97                          (ULONG)current_packet -> nx_packet_data_start);
98         current_packet = current_packet -> nx_packet_next;
99     }
100     return(nx_packet_release(packet_ptr));
101 }
102 #endif /* NX_SECURE_KEY_CLEAR */
103 
104