1
10
13
14
20
21
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
106
107
108
115
116
117
118
119
120
121
122
123
124
125
126
133
134
141
142
149
150
157
158
165
166
167
168
169
170
177
178
185
186
193
194
201
202
209
210
217
218
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
295
300
301
302
303
...
...
...
#define NX_SECURE_SOURCE_CODE
#include "nx_secure_x509.h"
static INT _nx_secure_x509_distinguished_name_field_compare(const UCHAR *field1, UINT length1,
const UCHAR *field2, UINT length2);
...
...
INT _nx_secure_x509_distinguished_name_compare(NX_SECURE_X509_DISTINGUISHED_NAME *name,
NX_SECURE_X509_DISTINGUISHED_NAME *compare_name,
ULONG compare_fields)
{
INT status = 0;
/* ... */
if (compare_fields & NX_SECURE_X509_NAME_COMMON_NAME)
{
status = _nx_secure_x509_distinguished_name_field_compare(name -> nx_secure_x509_common_name,
name -> nx_secure_x509_common_name_length,
compare_name -> nx_secure_x509_common_name,
compare_name -> nx_secure_x509_common_name_length);
}if (compare_fields & NX_SECURE_X509_NAME_COMMON_NAME) { ... }
#ifdef NX_SECURE_X509_STRICT_NAME_COMPARE
if (compare_fields & NX_SECURE_X509_NAME_COUNTRY)
{
status |= _nx_secure_x509_distinguished_name_field_compare(name -> nx_secure_x509_country,
name -> nx_secure_x509_country_length,
compare_name -> nx_secure_x509_country,
compare_name -> nx_secure_x509_country_length);
}if (compare_fields & NX_SECURE_X509_NAME_COUNTRY) { ... }
if (compare_fields & NX_SECURE_X509_NAME_ORGANIZATION)
{
status |= _nx_secure_x509_distinguished_name_field_compare(name -> nx_secure_x509_organization,
name -> nx_secure_x509_organization_length,
compare_name -> nx_secure_x509_organization,
compare_name -> nx_secure_x509_organization_length);
}if (compare_fields & NX_SECURE_X509_NAME_ORGANIZATION) { ... }
if (compare_fields & NX_SECURE_X509_NAME_ORG_UNIT)
{
status |= _nx_secure_x509_distinguished_name_field_compare(name -> nx_secure_x509_org_unit,
name -> nx_secure_x509_org_unit_length,
compare_name -> nx_secure_x509_org_unit,
compare_name -> nx_secure_x509_org_unit_length);
}if (compare_fields & NX_SECURE_X509_NAME_ORG_UNIT) { ... }
if (compare_fields & NX_SECURE_X509_NAME_QUALIFIER)
{
status |= _nx_secure_x509_distinguished_name_field_compare(name -> nx_secure_x509_distinguished_name_qualifier,
name -> nx_secure_x509_distinguished_name_qualifier_length,
compare_name -> nx_secure_x509_distinguished_name_qualifier,
compare_name -> nx_secure_x509_distinguished_name_qualifier_length);
}if (compare_fields & NX_SECURE_X509_NAME_QUALIFIER) { ... }
if (compare_fields & NX_SECURE_X509_NAME_STATE)
{
status |= _nx_secure_x509_distinguished_name_field_compare(name -> nx_secure_x509_state,
name -> nx_secure_x509_state_length,
compare_name -> nx_secure_x509_state,
compare_name -> nx_secure_x509_state_length);
}if (compare_fields & NX_SECURE_X509_NAME_STATE) { ... }
if (compare_fields & NX_SECURE_X509_NAME_SERIAL_NUMBER)
{
status |= _nx_secure_x509_distinguished_name_field_compare(name -> nx_secure_x509_serial_number,
name -> nx_secure_x509_serial_number_length,
compare_name -> nx_secure_x509_serial_number,
compare_name -> nx_secure_x509_serial_number_length);
}if (compare_fields & NX_SECURE_X509_NAME_SERIAL_NUMBER) { ... }
#ifdef NX_SECURE_X509_USE_EXTENDED_DISTINGUISHED_NAMES
if (compare_fields & NX_SECURE_X509_NAME_LOCALITY)
{
status |= _nx_secure_x509_distinguished_name_field_compare(name -> nx_secure_x509_locality,
name -> nx_secure_x509_locality_length,
compare_name -> nx_secure_x509_locality,
compare_name -> nx_secure_x509_locality_length);
}if (compare_fields & NX_SECURE_X509_NAME_LOCALITY) { ... }
if (compare_fields & NX_SECURE_X509_NAME_TITLE)
{
status |= _nx_secure_x509_distinguished_name_field_compare(name -> nx_secure_x509_title,
name -> nx_secure_x509_title_length,
compare_name -> nx_secure_x509_title,
compare_name -> nx_secure_x509_title_length);
}if (compare_fields & NX_SECURE_X509_NAME_TITLE) { ... }
if (compare_fields & NX_SECURE_X509_NAME_SURNAME)
{
status |= _nx_secure_x509_distinguished_name_field_compare(name -> nx_secure_x509_surname,
name -> nx_secure_x509_surname_length,
compare_name -> nx_secure_x509_surname,
compare_name -> nx_secure_x509_surname_length);
}if (compare_fields & NX_SECURE_X509_NAME_SURNAME) { ... }
if (compare_fields & NX_SECURE_X509_NAME_GIVEN_NAME)
{
status |= _nx_secure_x509_distinguished_name_field_compare(name -> nx_secure_x509_given_name,
name -> nx_secure_x509_given_name_length,
compare_name -> nx_secure_x509_given_name,
compare_name -> nx_secure_x509_given_name_length);
}if (compare_fields & NX_SECURE_X509_NAME_GIVEN_NAME) { ... }
if (compare_fields & NX_SECURE_X509_NAME_INITIALS)
{
status |= _nx_secure_x509_distinguished_name_field_compare(name -> nx_secure_x509_initials,
name -> nx_secure_x509_initials_length,
compare_name -> nx_secure_x509_initials,
compare_name -> nx_secure_x509_initials_length);
}if (compare_fields & NX_SECURE_X509_NAME_INITIALS) { ... }
if (compare_fields & NX_SECURE_X509_NAME_PSEUDONYM)
{
status |= _nx_secure_x509_distinguished_name_field_compare(name -> nx_secure_x509_pseudonym,
name -> nx_secure_x509_pseudonym_length,
compare_name -> nx_secure_x509_pseudonym,
compare_name -> nx_secure_x509_pseudonym_length);
}if (compare_fields & NX_SECURE_X509_NAME_PSEUDONYM) { ... }
if (compare_fields & NX_SECURE_X509_NAME_GENERATION_QUALIFIER)
{
status |= _nx_secure_x509_distinguished_name_field_compare(name -> nx_secure_x509_generation_qualifier,
name -> nx_secure_x509_generation_qualifier_length,
compare_name -> nx_secure_x509_generation_qualifier,
compare_name -> nx_secure_x509_generation_qualifier_length);
}if (compare_fields & NX_SECURE_X509_NAME_GENERATION_QUALIFIER) { ... }
/* ... */#endif/* ... */
#endif
return(status);
}{ ... }
...
...
static INT _nx_secure_x509_distinguished_name_field_compare(const UCHAR *field1, const UINT length1,
const UCHAR *field2, const UINT length2)
{
INT compare_value;
if (length1 == length2)
{
if (length1 == 0)
{
compare_value = 0;
}if (length1 == 0) { ... }
else
{
compare_value = NX_SECURE_MEMCMP(field1, field2, length1);
}else { ... }
}if (length1 == length2) { ... }
else
{
compare_value = 1;
}else { ... }
return(compare_value);
}{ ... }