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_common_name_dns_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 DNS name check. */
43 /* */
44 /* INPUT */
45 /* */
46 /* certificate Pointer to certificate */
47 /* dns_tld Top-level domain name */
48 /* dns_tld_length Length of TLD in bytes */
49 /* */
50 /* OUTPUT */
51 /* */
52 /* status Validity of certificate */
53 /* */
54 /* CALLS */
55 /* */
56 /* _nx_secure_x509_common_name_dns_check */
57 /* Actual X509 DNS name check */
58 /* call */
59 /* */
60 /* CALLED BY */
61 /* */
62 /* Application code */
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_common_name_dns_check(NX_SECURE_X509_CERT * certificate,const UCHAR * dns_tld,UINT dns_tld_length)76 UINT _nxe_secure_x509_common_name_dns_check(NX_SECURE_X509_CERT *certificate, const UCHAR *dns_tld,
77 UINT dns_tld_length)
78 {
79 UINT status;
80
81 /* Check for pointer errors. */
82 if ((certificate == NX_CRYPTO_NULL) || (dns_tld == NX_CRYPTO_NULL) || (dns_tld_length == 0))
83 {
84 #ifdef NX_CRYPTO_STANDALONE_ENABLE
85 return(NX_CRYPTO_PTR_ERROR);
86 #else
87 return(NX_PTR_ERROR);
88 #endif /* NX_CRYPTO_STANDALONE_ENABLE */
89 }
90
91 /* Check for appropriate caller. */
92 NX_THREADS_ONLY_CALLER_CHECKING
93
94 /* Make the actual call. */
95 status = _nx_secure_x509_common_name_dns_check(certificate, dns_tld, dns_tld_length);
96
97 return(status);
98 }
99
100