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
93
95
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
168
169
170
171
172
173
174
175
176
177
178
179
180
184
185
189
190
195
196
197
198
199
200
206
207
212
213
217
228
229
230
231
232
233
234
...
...
...
#define NX_SECURE_SOURCE_CODE
#include "nx_secure_tls.h"
extern const NX_SECURE_VERSIONS_LIST nx_secure_supported_versions_list[];
...
...
VOID _nx_secure_tls_newest_supported_version(NX_SECURE_TLS_SESSION *session_ptr,
USHORT *protocol_version, UINT id)
{
INT i;
NX_PARAMETER_NOT_USED(session_ptr);
#ifndef NX_SECURE_TLS_SERVER_DISABLED
if(session_ptr -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_SERVER &&
session_ptr -> nx_secure_tls_protocol_version_override != 0)
{
/* ... */
(*protocol_version) = session_ptr -> nx_secure_tls_protocol_version_override;
return;
}if (session_ptr -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_SERVER && session_ptr -> nx_secure_tls_protocol_version_override != 0) { ... }
/* ... */#endif
/* ... */
for (i = (INT)(nx_secure_supported_versions_list[id].nx_secure_versions_list_count - 1); i >= 0; --i)
{
if (nx_secure_supported_versions_list[id].nx_secure_versions_list[i].nx_secure_tls_is_supported)
{
(*protocol_version) = nx_secure_supported_versions_list[id].nx_secure_versions_list[i].nx_secure_tls_protocol_version;
return;
}if (nx_secure_supported_versions_list[id].nx_secure_versions_list[i].nx_secure_tls_is_supported) { ... }
}for (i = (INT)(nx_secure_supported_versions_list[id].nx_secure_versions_list_count - 1); i >= 0; --i) { ... }
(*protocol_version) = 0x0;
return;
}{ ... }
...
...
void _nx_secure_tls_highest_supported_version_negotiate(NX_SECURE_TLS_SESSION *session_ptr,
USHORT *protocol_version, UINT id)
{
INT i;
USHORT highest_version = 0;
USHORT lowest_version = 0xFF;
USHORT highest_version_not_greater_than_client_version = 0;
NX_PARAMETER_NOT_USED(session_ptr);
#ifndef NX_SECURE_TLS_SERVER_DISABLED
if(session_ptr -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_SERVER &&
session_ptr -> nx_secure_tls_negotiated_highest_protocol_version != 0)
{
/* ... */
(*protocol_version) = session_ptr -> nx_secure_tls_negotiated_highest_protocol_version;
return;
}if (session_ptr -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_SERVER && session_ptr -> nx_secure_tls_negotiated_highest_protocol_version != 0) { ... }
/* ... */#endif
for (i = (INT)(nx_secure_supported_versions_list[id].nx_secure_versions_list_count - 1); i >= 0; --i)
{
if (nx_secure_supported_versions_list[id].nx_secure_versions_list[i].nx_secure_tls_is_supported)
{
if (highest_version < nx_secure_supported_versions_list[id].nx_secure_versions_list[i].nx_secure_tls_protocol_version)
{
highest_version = nx_secure_supported_versions_list[id].nx_secure_versions_list[i].nx_secure_tls_protocol_version;
}if (highest_version < nx_secure_supported_versions_list[id].nx_secure_versions_list[i].nx_secure_tls_protocol_version) { ... }
if (lowest_version > nx_secure_supported_versions_list[id].nx_secure_versions_list[i].nx_secure_tls_protocol_version)
{
lowest_version = nx_secure_supported_versions_list[id].nx_secure_versions_list[i].nx_secure_tls_protocol_version;
}if (lowest_version > nx_secure_supported_versions_list[id].nx_secure_versions_list[i].nx_secure_tls_protocol_version) { ... }
if (!highest_version_not_greater_than_client_version &&
(*protocol_version) >= nx_secure_supported_versions_list[id].nx_secure_versions_list[i].nx_secure_tls_protocol_version)
{
highest_version_not_greater_than_client_version = nx_secure_supported_versions_list[id].nx_secure_versions_list[i].nx_secure_tls_protocol_version;
}if (!highest_version_not_greater_than_client_version && (*protocol_version) >= nx_secure_supported_versions_list[id].nx_secure_versions_list[i].nx_secure_tls_protocol_version) { ... }
}if (nx_secure_supported_versions_list[id].nx_secure_versions_list[i].nx_secure_tls_is_supported) { ... }
}for (i = (INT)(nx_secure_supported_versions_list[id].nx_secure_versions_list_count - 1); i >= 0; --i) { ... }
if (highest_version == 0)
{
(*protocol_version) = 0;
session_ptr -> nx_secure_tls_negotiated_highest_protocol_version = 0;
return;
}if (highest_version == 0) { ... }
/* ... */
if ((*protocol_version) > highest_version)
{
(*protocol_version) = highest_version;
}if ((*protocol_version) > highest_version) { ... }
else
{
if ((*protocol_version) < highest_version && (*protocol_version) > lowest_version)
{
(*protocol_version) = highest_version_not_greater_than_client_version;
}if ((*protocol_version) < highest_version && (*protocol_version) > lowest_version) { ... }
else
{
(*protocol_version) = 0;
}else { ... }
}else { ... }
session_ptr -> nx_secure_tls_negotiated_highest_protocol_version = (*protocol_version);
return;
}{ ... }
...