1
10
13
14
20
21
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
120
125
126
127
141
142
143
144
145
146
147
148
149
150
157
158
159
160
161
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
185
186
187
193
194
195
196
197
198
199
200
201
202
206
207
208
209
210
211
212
...
...
...
#define NX_SECURE_SOURCE_CODE
#include "nx_secure_tls.h"
...
...
UINT _nx_secure_tls_session_start(NX_SECURE_TLS_SESSION *tls_session, NX_TCP_SOCKET *tcp_socket,
UINT wait_option)
{
UINT status = NX_NOT_SUCCESSFUL;
UINT error_return;
#ifndef NX_SECURE_TLS_CLIENT_DISABLED
NX_PACKET *send_packet;
#endif
tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
tls_session -> nx_secure_tls_packet_pool = tcp_socket -> nx_tcp_socket_ip_ptr -> nx_ip_default_packet_pool;
tls_session -> nx_secure_tls_tcp_socket = tcp_socket;
tls_session -> nx_secure_record_queue_header = NX_NULL;
tls_session -> nx_secure_record_decrypted_packet = NX_NULL;
tls_session -> nx_secure_tls_local_session_active = 0;
tls_session -> nx_secure_tls_remote_session_active = 0;
tls_session -> nx_secure_tls_received_remote_credentials = NX_FALSE;
tls_session -> nx_secure_tls_received_alert_level = 0;
tls_session -> nx_secure_tls_received_alert_value = 0;
if (tcp_socket -> nx_tcp_socket_client_type)
{
tls_session -> nx_secure_tls_socket_type = NX_SECURE_TLS_SESSION_TYPE_CLIENT;
}if (tcp_socket -> nx_tcp_socket_client_type) { ... }
else
{
tls_session -> nx_secure_tls_socket_type = NX_SECURE_TLS_SESSION_TYPE_SERVER;
}else { ... }
#if (NX_SECURE_TLS_TLS_1_3_ENABLED)
if(tls_session->nx_secure_tls_1_3)
{
status = _nx_secure_tls_1_3_crypto_init(tls_session);
if(status != NX_SUCCESS)
{
tx_mutex_put(&_nx_secure_tls_protection);
return(status);
}if (status != NX_SUCCESS) { ... }
}if (tls_session->nx_secure_tls_1_3) { ... }
/* ... */#endif
#ifndef NX_SECURE_TLS_CLIENT_DISABLED
if (tls_session -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_CLIENT)
{
status = _nx_secure_tls_allocate_handshake_packet(tls_session, tls_session -> nx_secure_tls_packet_pool, &send_packet, wait_option);
if (status != NX_SUCCESS)
{
tx_mutex_put(&_nx_secure_tls_protection);
return(status);
}if (status != NX_SUCCESS) { ... }
status = _nx_secure_tls_send_clienthello(tls_session, send_packet);
if (status == NX_SUCCESS)
{
status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CLIENT_HELLO, wait_option);
}if (status == NX_SUCCESS) { ... }
if (status != NX_SUCCESS)
{
tx_mutex_put(&_nx_secure_tls_protection);
nx_secure_tls_packet_release(send_packet);
return(status);
}if (status != NX_SUCCESS) { ... }
}if (tls_session -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_CLIENT) { ... }
/* ... */#endif
tx_mutex_put(&_nx_secure_tls_protection);
/* ... */
status = _nx_secure_tls_handshake_process(tls_session, wait_option);
if ((status == NX_CONTINUE) && (wait_option == 0))
{
return(NX_CONTINUE);
}if ((status == NX_CONTINUE) && (wait_option == 0)) { ... }
if(status != NX_SUCCESS)
{
error_return = status;
status = _nx_secure_tls_session_reset(tls_session);
if(status != NX_SUCCESS)
{
return(status);
}if (status != NX_SUCCESS) { ... }
return(error_return);
}if (status != NX_SUCCESS) { ... }
return(status);
}{ ... }