1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** NetX Secure Component */ 17 /** */ 18 /** X.509 Digital Certificates */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 #define NX_SECURE_SOURCE_CODE 24 25 #include "nx_secure_x509.h" 26 27 /**************************************************************************/ 28 /* */ 29 /* FUNCTION RELEASE */ 30 /* */ 31 /* _nx_secure_x509_free_certificate_get PORTABLE C */ 32 /* 6.1.6 */ 33 /* AUTHOR */ 34 /* */ 35 /* Timothy Stapko, Microsoft Corporation */ 36 /* */ 37 /* DESCRIPTION */ 38 /* */ 39 /* This function returns a pointer to a "free" certificate structure, */ 40 /* which has been previously allocated by the application. This */ 41 /* structure is removed from the free list and can be placed into */ 42 /* one of the other X509 store locations. */ 43 /* */ 44 /* INPUT */ 45 /* */ 46 /* store Pointer to certificate store */ 47 /* certificate Pointer to cert pointer */ 48 /* */ 49 /* OUTPUT */ 50 /* */ 51 /* status Completion status */ 52 /* */ 53 /* CALLS */ 54 /* */ 55 /* None */ 56 /* */ 57 /* CALLED BY */ 58 /* */ 59 /* _nx_secure_tls_process_remote_certificate */ 60 /* Process server certificate */ 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 /* 04-02-2021 Timothy Stapko Modified comment(s), */ 70 /* removed dependency on TLS, */ 71 /* resulting in version 6.1.6 */ 72 /* */ 73 /**************************************************************************/ _nx_secure_x509_free_certificate_get(NX_SECURE_X509_CERTIFICATE_STORE * store,NX_SECURE_X509_CERT ** certificate)74UINT _nx_secure_x509_free_certificate_get(NX_SECURE_X509_CERTIFICATE_STORE *store, 75 NX_SECURE_X509_CERT **certificate) 76 { 77 NX_SECURE_X509_CERT *list_head; 78 79 /* Get the first certificate in the remote store. */ 80 list_head = store -> nx_secure_x509_free_certificates; 81 82 if (list_head == NX_CRYPTO_NULL) 83 { 84 /* No certificates in this store! */ 85 return(NX_SECURE_X509_NO_CERT_SPACE_ALLOCATED); 86 } 87 88 /* Use first entry in store. */ 89 *certificate = list_head; 90 91 /* Remove the certificate from the store. */ 92 store -> nx_secure_x509_free_certificates = (*certificate) -> nx_secure_x509_next_certificate; 93 (*certificate) -> nx_secure_x509_next_certificate = NX_CRYPTO_NULL; 94 95 return(NX_SECURE_X509_SUCCESS); 96 } 97 98