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
113
114
115
116
117
118
119
120
121
122
126
127
128
133
134
135
139
140
143
144
145
146
147
148
...
...
...
#define NX_SECURE_SOURCE_CODE
#include "nx_secure_x509.h"
...
...
UINT _nx_secure_x509_key_usage_extension_parse(NX_SECURE_X509_CERT *certificate, USHORT *bitfield)
{
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;
NX_SECURE_X509_EXTENSION key_usage_extension;
/* ... */
status = _nx_secure_x509_extension_find(certificate, &key_usage_extension, NX_SECURE_TLS_X509_TYPE_KEY_USAGE);
if (status != NX_SECURE_X509_SUCCESS)
{
return(status);
}if (status != NX_SECURE_X509_SUCCESS) { ... }
current_buffer = key_usage_extension.nx_secure_x509_extension_data;
length = key_usage_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_BIT_STRING))
{
return(NX_SECURE_X509_INVALID_EXTENSION_SEQUENCE);
}if (!(tlv_type_class == NX_SECURE_ASN_TAG_CLASS_UNIVERSAL && tlv_type == NX_SECURE_ASN_TAG_BIT_STRING)) { ... }
if (tlv_length > sizeof(USHORT) || tlv_length < 2)
{
return(NX_SECURE_X509_INVALID_EXTENSION_SEQUENCE);
}if (tlv_length > sizeof(USHORT) || tlv_length < 2) { ... }
/* ... */
*bitfield = (USHORT)((tlv_data[1] << 8) + tlv_data[0]);
return(NX_SECURE_X509_SUCCESS);
}{ ... }