Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
#define NX_SECURE_SOURCE_CODE
#include "nx_secure_x509.h"
...
...
_nx_secure_x509_wildcard_compare(const UCHAR *, UINT, const UCHAR *, UINT)
Files
loading (3/7)...
SourceVuSTM32 Libraries and Samplesnetxduonx_secure/src/nx_secure_x509_wildcard_compare.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** NetX Secure Component */ /** */ /** X.509 Digital Certificates */ /** */... /**************************************************************************/ /**************************************************************************/ #define NX_SECURE_SOURCE_CODE #include "nx_secure_x509.h" ... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_secure_x509_wildcard_compare PORTABLE C */ /* 6.1.6 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function compares a name (string) against a name string using */ /* wildcards as found in the Common Name and subjectAltName fields of */ /* an X.509 certificate. This is primarily used when checking a DNS */ /* name against an X.509 certificate provided by a remote host. */ /* */ /* INPUT */ /* */ /* dns_name Name to check */ /* dns_name_len Length of name */ /* wildcard_name String with name or wildcard */ /* wildcard_len Length of wildcard */ /* */ /* OUTPUT */ /* */ /* compare value 0 if equal, else non-zero */ /* */ /* CALLS */ /* */ /* None */ /* */ /* CALLED BY */ /* */ /* _nx_secure_x509_common_name_dns_check Check Common Name by DNS */ /* _nx_secure_x509_subject_alt_names_find */ /* Find subject alt names */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* resulting in version 6.1 */ /* 04-02-2021 Timothy Stapko Modified comment(s), */ /* removed dependency on TLS, */ /* resulting in version 6.1.6 */ /* */... /**************************************************************************/ INT _nx_secure_x509_wildcard_compare(const UCHAR *dns_name, UINT dns_name_len, const UCHAR *wildcard_name, UINT wildcard_len) { INT dns_offset; INT wildcard_offset; dns_offset = (INT)dns_name_len - 1; wildcard_offset = (INT)wildcard_len - 1; /* Walk backwards through each name. */ while (dns_offset >= 0 && wildcard_offset >= 0) { /* Check each character. */ if (dns_name[dns_offset] != wildcard_name[wildcard_offset]) { /* Characters do not match, check for wildcard. */ if (wildcard_name[wildcard_offset] == '*') { if (wildcard_offset != 0 || wildcard_name[1] != '.') { /* Only match wildcard character when it is the only character of the left-most label. *//* ... */ return(1); }if (wildcard_offset != 0 || wildcard_name[1] != '.') { ... } while (dns_offset >= 0) { if (dns_name[dns_offset] == '.') { /* Wildcard does not match full stops. */ return(1); }if (dns_name[dns_offset] == '.') { ... } dns_offset--; }while (dns_offset >= 0) { ... } /* Wildcard match, they are OK. */ return(0); }if (wildcard_name[wildcard_offset] == '*') { ... } /* No match and no wildcard. */ return(1); }if (dns_name[dns_offset] != wildcard_name[wildcard_offset]) { ... } /* Adjust offsets. */ dns_offset--; wildcard_offset--; }while (dns_offset >= 0 && wildcard_offset >= 0) { ... } if (dns_offset != -1 || wildcard_offset != -1) { /* Length mismatch. */ return(1); }if (dns_offset != -1 || wildcard_offset != -1) { ... } /* Both names are exactly the same. */ return(0); }{ ... }
Details
Show:
from
Types: Columns: