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 /* Bring in externs for caller checking code.  */
27 
28 NX_SECURE_CALLER_CHECKING_EXTERNS
29 
30 /**************************************************************************/
31 /*                                                                        */
32 /*  FUNCTION                                               RELEASE        */
33 /*                                                                        */
34 /*    _nxe_secure_x509_crl_revocation_check               PORTABLE C      */
35 /*                                                           6.1.6        */
36 /*  AUTHOR                                                                */
37 /*                                                                        */
38 /*    Timothy Stapko, Microsoft Corporation                               */
39 /*                                                                        */
40 /*  DESCRIPTION                                                           */
41 /*                                                                        */
42 /*    This function checks for errors in the X.509 CRL revocation check.  */
43 /*                                                                        */
44 /*  INPUT                                                                 */
45 /*                                                                        */
46 /*    crl_data                              Pointer to DER-encoded CRL    */
47 /*    crl_length                            Length of CRL data in buffer  */
48 /*    store                                 Certificate store to be used  */
49 /*    certificate                           The certificate being checked */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    status                                Completion status             */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    _nx_secure_x509_crl_revocation_check                                */
58 /*                                          Actual X509 CRL revocation    */
59 /*                                            check call                  */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*                                                                        */
64 /*  RELEASE HISTORY                                                       */
65 /*                                                                        */
66 /*    DATE              NAME                      DESCRIPTION             */
67 /*                                                                        */
68 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
69 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
70 /*                                            resulting in version 6.1    */
71 /*  04-02-2021     Timothy Stapko           Modified comment(s),          */
72 /*                                            removed dependency on TLS,  */
73 /*                                            resulting in version 6.1.6  */
74 /*                                                                        */
75 /**************************************************************************/
_nxe_secure_x509_crl_revocation_check(const UCHAR * crl_data,UINT crl_length,NX_SECURE_X509_CERTIFICATE_STORE * store,NX_SECURE_X509_CERT * certificate)76 UINT _nxe_secure_x509_crl_revocation_check(const UCHAR *crl_data, UINT crl_length,
77                                            NX_SECURE_X509_CERTIFICATE_STORE *store,
78                                            NX_SECURE_X509_CERT *certificate)
79 {
80 UINT status;
81 
82     /* Check for pointer errors. */
83     if ((certificate == NX_CRYPTO_NULL) || (crl_data == NX_CRYPTO_NULL) || (crl_length == 0) || (store == NX_CRYPTO_NULL))
84     {
85 #ifdef NX_CRYPTO_STANDALONE_ENABLE
86         return(NX_CRYPTO_PTR_ERROR);
87 #else
88         return(NX_PTR_ERROR);
89 #endif /* NX_CRYPTO_STANDALONE_ENABLE */
90     }
91 
92     /* Check for appropriate caller.  */
93     NX_THREADS_ONLY_CALLER_CHECKING
94 
95     /* Make the actual call. */
96     status = _nx_secure_x509_crl_revocation_check(crl_data, crl_length, store, certificate);
97 
98     return(status);
99 }
100 
101