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_session_packet_buffer_set 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 session packet buffer */ 46 /* set call. */ 47 /* */ 48 /* INPUT */ 49 /* */ 50 /* session_ptr TLS control block */ 51 /* buffer_ptr Pointer to buffer */ 52 /* buffer_size Buffer area size */ 53 /* */ 54 /* OUTPUT */ 55 /* */ 56 /* status Completion status */ 57 /* */ 58 /* CALLS */ 59 /* */ 60 /* _nx_secure_tls_session_packet_buffer_set */ 61 /* Actual TLS session buffer */ 62 /* set call */ 63 /* */ 64 /* CALLED BY */ 65 /* */ 66 /* Application Code */ 67 /* */ 68 /* RELEASE HISTORY */ 69 /* */ 70 /* DATE NAME DESCRIPTION */ 71 /* */ 72 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ 73 /* 09-30-2020 Timothy Stapko Modified comment(s), */ 74 /* resulting in version 6.1 */ 75 /* */ 76 /**************************************************************************/ _nxe_secure_tls_session_packet_buffer_set(NX_SECURE_TLS_SESSION * session_ptr,UCHAR * buffer_ptr,ULONG buffer_size)77UINT _nxe_secure_tls_session_packet_buffer_set(NX_SECURE_TLS_SESSION *session_ptr, 78 UCHAR *buffer_ptr, ULONG buffer_size) 79 { 80 UINT status; 81 82 if (session_ptr == NX_NULL || buffer_ptr == NX_NULL) 83 { 84 return(NX_PTR_ERROR); 85 } 86 87 if (buffer_size < NX_SECURE_TLS_MINIMUM_MESSAGE_BUFFER_SIZE) 88 { 89 return(NX_INVALID_PARAMETERS); 90 } 91 92 /* Make sure the session is initialized. */ 93 if(session_ptr -> nx_secure_tls_id != NX_SECURE_TLS_ID) 94 { 95 return(NX_SECURE_TLS_SESSION_UNINITIALIZED); 96 } 97 98 /* Check for appropriate caller. */ 99 NX_THREADS_ONLY_CALLER_CHECKING 100 101 status = _nx_secure_tls_session_packet_buffer_set(session_ptr, buffer_ptr, buffer_size); 102 103 /* Return completion status. */ 104 return(status); 105 } 106 107