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 /* FUNCTION RELEASE */ 29 /* */ 30 /* _nx_secure_tls_send_changecipherspec PORTABLE C */ 31 /* 6.1 */ 32 /* AUTHOR */ 33 /* */ 34 /* Timothy Stapko, Microsoft Corporation */ 35 /* */ 36 /* DESCRIPTION */ 37 /* */ 38 /* This function populates an NX_PACKET with the TLS ChangeCipherSpec */ 39 /* message, which indicates that all further TLS records will be */ 40 /* encrypted ussing the generated session keys. */ 41 /* */ 42 /* INPUT */ 43 /* */ 44 /* tls_session TLS control block */ 45 /* send_packet Packet to be filled */ 46 /* */ 47 /* OUTPUT */ 48 /* */ 49 /* status Completion status */ 50 /* */ 51 /* CALLS */ 52 /* */ 53 /* None */ 54 /* */ 55 /* CALLED BY */ 56 /* */ 57 /* _nx_secure_dtls_client_handshake DTLS client state machine */ 58 /* _nx_secure_dtls_server_handshake DTLS server state machine */ 59 /* _nx_secure_tls_client_handshake TLS client state machine */ 60 /* _nx_secure_tls_server_handshake TLS server state machine */ 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 /* resulting in version 6.1 */ 69 /* */ 70 /**************************************************************************/ _nx_secure_tls_send_changecipherspec(NX_SECURE_TLS_SESSION * tls_session,NX_PACKET * send_packet)71UINT _nx_secure_tls_send_changecipherspec(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET *send_packet) 72 { 73 74 NX_PARAMETER_NOT_USED(tls_session); 75 76 if (((ULONG)(send_packet -> nx_packet_data_end) - (ULONG)(send_packet -> nx_packet_append_ptr)) < 1u) 77 { 78 79 /* Packet buffer is too small to hold random and ID. */ 80 return(NX_SECURE_TLS_PACKET_BUFFER_TOO_SMALL); 81 } 82 83 send_packet -> nx_packet_append_ptr[0] = 0x1; 84 send_packet -> nx_packet_append_ptr = send_packet -> nx_packet_append_ptr + 1; 85 send_packet -> nx_packet_length = 1; 86 87 return(NX_SUCCESS); 88 } 89 90