1
10
13
14
20
21
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
130
131
132
138
139
140
141
142
143
144
145
146
147
148
149
150
151
155
156
157
163
164
165
166
168
172
173
174
175
176
181
182
183
184
185
186
187
188
189
192
193
194
195
196
197
198
203
204
205
206
207
208
209
...
...
...
#define NX_SECURE_SOURCE_CODE
#include "nx_secure_x509.h"
...
...
UINT _nx_secure_x509_subject_alt_names_find(NX_SECURE_X509_EXTENSION *extension, const UCHAR *name,
UINT name_length, USHORT name_type)
{
USHORT tlv_type;
USHORT tlv_type_class;
ULONG tlv_length;
const UCHAR *tlv_data;
const UCHAR *current_buffer;
ULONG length;
ULONG header_length;
UINT status;
const UCHAR *compare_name;
ULONG compare_length;
INT compare_value;
/* ... */
current_buffer = extension -> nx_secure_x509_extension_data;
length = extension -> nx_secure_x509_extension_data_length;
status = _nx_secure_x509_asn1_tlv_block_parse(current_buffer, &length, &tlv_type, &tlv_type_class, &tlv_length, &tlv_data, &header_length);
if (status != 0)
{
return(status);
}if (status != 0) { ... }
if (!(tlv_type_class == NX_SECURE_ASN_TAG_CLASS_UNIVERSAL && tlv_type == NX_SECURE_ASN_TAG_SEQUENCE))
{
/* ... */
return(NX_SECURE_X509_INVALID_EXTENSION_SEQUENCE);
}if (!(tlv_type_class == NX_SECURE_ASN_TAG_CLASS_UNIVERSAL && tlv_type == NX_SECURE_ASN_TAG_SEQUENCE)) { ... }
current_buffer = tlv_data;
length = tlv_length;
while (length > 0)
{
status = _nx_secure_x509_asn1_tlv_block_parse(current_buffer, &length, &tlv_type, &tlv_type_class, &tlv_length, &tlv_data, &header_length);
if (status != 0)
{
return(status);
}if (status != 0) { ... }
if (!(tlv_type_class == NX_SECURE_ASN_TAG_CLASS_CONTEXT))
{
/* ... */
return(NX_SECURE_X509_ALT_NAME_NOT_FOUND);
}if (!(tlv_type_class == NX_SECURE_ASN_TAG_CLASS_CONTEXT)) { ... }
current_buffer += header_length;
/* ... */
if (tlv_type != name_type)
{
continue;
}if (tlv_type != name_type) { ... }
switch (tlv_type)
{
case NX_SECURE_X509_SUB_ALT_NAME_TAG_DNSNAME:
compare_name = tlv_data;
compare_length = tlv_length;
break;case NX_SECURE_X509_SUB_ALT_NAME_TAG_DNSNAME:
case NX_SECURE_X509_SUB_ALT_NAME_TAG_OTHERNAME:
case NX_SECURE_X509_SUB_ALT_NAME_TAG_RFC822NAME:
case NX_SECURE_X509_SUB_ALT_NAME_TAG_X400ADDRESS:
case NX_SECURE_X509_SUB_ALT_NAME_TAG_DIRECTORYNAME:
case NX_SECURE_X509_SUB_ALT_NAME_TAG_EDIPARTYNAME:
case NX_SECURE_X509_SUB_ALT_NAME_TAG_UNIFORMRESOURCEIDENTIFIER:
case NX_SECURE_X509_SUB_ALT_NAME_TAG_IPADDRESS:
case NX_SECURE_X509_SUB_ALT_NAME_TAG_REGISTEREDID:
default:
continue;default
}switch (tlv_type) { ... }
compare_value = _nx_secure_x509_wildcard_compare(name, name_length,
compare_name, compare_length);
if (compare_value == 0)
{
return(NX_SECURE_X509_SUCCESS);
}if (compare_value == 0) { ... }
current_buffer += tlv_length;
}while (length > 0) { ... }
return(NX_SECURE_X509_ALT_NAME_NOT_FOUND);
}{ ... }