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 /** X.509 Digital Certificates */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 #define NX_SECURE_SOURCE_CODE 23 24 #include "nx_secure_x509.h" 25 26 /**************************************************************************/ 27 /* */ 28 /* FUNCTION RELEASE */ 29 /* */ 30 /* _nx_secure_x509_free_certificate_get PORTABLE C */ 31 /* 6.1.6 */ 32 /* AUTHOR */ 33 /* */ 34 /* Timothy Stapko, Microsoft Corporation */ 35 /* */ 36 /* DESCRIPTION */ 37 /* */ 38 /* This function returns a pointer to a "free" certificate structure, */ 39 /* which has been previously allocated by the application. This */ 40 /* structure is removed from the free list and can be placed into */ 41 /* one of the other X509 store locations. */ 42 /* */ 43 /* INPUT */ 44 /* */ 45 /* store Pointer to certificate store */ 46 /* certificate Pointer to cert pointer */ 47 /* */ 48 /* OUTPUT */ 49 /* */ 50 /* status Completion status */ 51 /* */ 52 /* CALLS */ 53 /* */ 54 /* None */ 55 /* */ 56 /* CALLED BY */ 57 /* */ 58 /* _nx_secure_tls_process_remote_certificate */ 59 /* Process server certificate */ 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 /* resulting in version 6.1 */ 68 /* 04-02-2021 Timothy Stapko Modified comment(s), */ 69 /* removed dependency on TLS, */ 70 /* resulting in version 6.1.6 */ 71 /* */ 72 /**************************************************************************/ _nx_secure_x509_free_certificate_get(NX_SECURE_X509_CERTIFICATE_STORE * store,NX_SECURE_X509_CERT ** certificate)73UINT _nx_secure_x509_free_certificate_get(NX_SECURE_X509_CERTIFICATE_STORE *store, 74 NX_SECURE_X509_CERT **certificate) 75 { 76 NX_SECURE_X509_CERT *list_head; 77 78 /* Get the first certificate in the remote store. */ 79 list_head = store -> nx_secure_x509_free_certificates; 80 81 if (list_head == NX_CRYPTO_NULL) 82 { 83 /* No certificates in this store! */ 84 return(NX_SECURE_X509_NO_CERT_SPACE_ALLOCATED); 85 } 86 87 /* Use first entry in store. */ 88 *certificate = list_head; 89 90 /* Remove the certificate from the store. */ 91 store -> nx_secure_x509_free_certificates = (*certificate) -> nx_secure_x509_next_certificate; 92 (*certificate) -> nx_secure_x509_next_certificate = NX_CRYPTO_NULL; 93 94 return(NX_SECURE_X509_SUCCESS); 95 } 96 97