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 /*                                                                        */
29 /*  FUNCTION                                               RELEASE        */
30 /*                                                                        */
31 /*    _nx_secure_tls_send_hellorequest                    PORTABLE C      */
32 /*                                                           6.1          */
33 /*  AUTHOR                                                                */
34 /*                                                                        */
35 /*    Timothy Stapko, Microsoft Corporation                               */
36 /*                                                                        */
37 /*  DESCRIPTION                                                           */
38 /*                                                                        */
39 /*    This function generates a HelloRequest message, which is used by a  */
40 /*    TLS server to indicate to the remote TLS client host that it wishes */
41 /*    to perform a re-negotiation handshake. The client should respond    */
42 /*    with a ClientHello as long as the active TLS session is valid.      */
43 /*                                                                        */
44 /*  INPUT                                                                 */
45 /*                                                                        */
46 /*    tls_session                           TLS control block             */
47 /*    send_packet                           Packet used to send message   */
48 /*                                                                        */
49 /*  OUTPUT                                                                */
50 /*                                                                        */
51 /*    status                                Completion status             */
52 /*                                                                        */
53 /*  CALLS                                                                 */
54 /*                                                                        */
55 /*    None                                                                */
56 /*                                                                        */
57 /*  CALLED BY                                                             */
58 /*                                                                        */
59 /*    _nx_secure_tls_session_renegotiate    Renegotiate TLS session       */
60 /*                                                                        */
61 /*  RELEASE HISTORY                                                       */
62 /*                                                                        */
63 /*    DATE              NAME                      DESCRIPTION             */
64 /*                                                                        */
65 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
66 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
67 /*                                            fixed renegotiation bug,    */
68 /*                                            resulting in version 6.1    */
69 /*                                                                        */
70 /**************************************************************************/
71 #ifndef NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION
_nx_secure_tls_send_hellorequest(NX_SECURE_TLS_SESSION * tls_session,NX_PACKET * send_packet)72 UINT _nx_secure_tls_send_hellorequest(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET *send_packet)
73 {
74     NX_PARAMETER_NOT_USED(tls_session);
75     NX_PARAMETER_NOT_USED(send_packet);
76 
77 #ifndef NX_SECURE_TLS_SERVER_DISABLED
78     /* Indicate that we have initiated a renegotiation by sending a HelloRequest to the remote client. */
79     tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_HELLO_REQUEST;
80 #endif
81 
82     return(NX_SECURE_TLS_SUCCESS);
83 }
84 #endif /* NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION */
85