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 /** Datagram Transport Layer Security (DTLS) */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 #define NX_SECURE_SOURCE_CODE 23 24 #include "nx_secure_dtls.h" 25 26 /**************************************************************************/ 27 /* */ 28 /* FUNCTION RELEASE */ 29 /* */ 30 /* _nxe_secure_dtls_server_local_certificate_add PORTABLE C */ 31 /* 6.1 */ 32 /* AUTHOR */ 33 /* */ 34 /* Timothy Stapko, Microsoft Corporation */ 35 /* */ 36 /* DESCRIPTION */ 37 /* */ 38 /* This function checks for errors when adding a local identity */ 39 /* certificate to a DTLS server. */ 40 /* */ 41 /* INPUT */ 42 /* */ 43 /* server_ptr DTLS server control block */ 44 /* certificate Pointer to identity cert */ 45 /* cert_id Numeric ID for cert */ 46 /* */ 47 /* OUTPUT */ 48 /* */ 49 /* status Completion status */ 50 /* */ 51 /* CALLS */ 52 /* */ 53 /* _nx_secure_tls_server_certificate_add Actual function call */ 54 /* */ 55 /* CALLED BY */ 56 /* */ 57 /* Application Code */ 58 /* */ 59 /* RELEASE HISTORY */ 60 /* */ 61 /* DATE NAME DESCRIPTION */ 62 /* */ 63 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ 64 /* 09-30-2020 Timothy Stapko Modified comment(s), */ 65 /* resulting in version 6.1 */ 66 /* */ 67 /**************************************************************************/ _nxe_secure_dtls_server_local_certificate_add(NX_SECURE_DTLS_SERVER * server_ptr,NX_SECURE_X509_CERT * certificate,UINT cert_id)68UINT _nxe_secure_dtls_server_local_certificate_add(NX_SECURE_DTLS_SERVER *server_ptr, 69 NX_SECURE_X509_CERT *certificate, UINT cert_id) 70 { 71 #ifdef NX_SECURE_ENABLE_DTLS 72 UINT status; 73 74 /* Check pointers. */ 75 if(server_ptr == NX_NULL || certificate == NX_NULL) 76 { 77 return(NX_PTR_ERROR); 78 } 79 80 /* We don't want to add server identity certificates without an ID. */ 81 if(cert_id == 0) 82 { 83 return(NX_INVALID_PARAMETERS); 84 } 85 86 /* Call actual function. */ 87 status = _nx_secure_dtls_server_local_certificate_add(server_ptr, certificate, cert_id); 88 89 return(status); 90 #else 91 NX_PARAMETER_NOT_USED(server_ptr); 92 NX_PARAMETER_NOT_USED(certificate); 93 NX_PARAMETER_NOT_USED(cert_id); 94 95 return(NX_NOT_SUPPORTED); 96 #endif /* NX_SECURE_ENABLE_DTLS */ 97 } 98 99