@@ -69,15 +69,20 @@ typedef struct {
69
69
bool timer_running : 1 ; /**< TLS timer running */
70
70
bool finished : 1 ; /**< TLS finished */
71
71
bool calculating : 1 ; /**< TLS is calculating */
72
+ #ifdef SERVER_TLS_EC_CALC_QUEUE
72
73
bool queued : 1 ; /**< TLS is queued */
74
+ #endif
73
75
bool library_init : 1 ; /**< TLS library has been initialized */
74
76
tls_sec_prot_lib_int_t * tls_sec_inst ; /**< TLS security library storage, SHALL BE THE LAST FIELD */
75
77
} tls_sec_prot_int_t ;
76
78
79
+ // TLS server EC queue is currently disabled, since EC calculation is made on server in one go
80
+ #ifdef SERVER_TLS_EC_CALC_QUEUE
77
81
typedef struct {
78
82
ns_list_link_t link ; /**< Link */
79
83
sec_prot_t * prot ; /**< Protocol instance */
80
84
} tls_sec_prot_queue_t ;
85
+ #endif
81
86
82
87
static uint16_t tls_sec_prot_size (void );
83
88
static int8_t client_tls_sec_prot_init (sec_prot_t * prot );
@@ -102,15 +107,22 @@ static int8_t tls_sec_prot_tls_get_timer(void *handle);
102
107
103
108
static int8_t tls_sec_prot_tls_configure_and_connect (sec_prot_t * prot , bool is_server );
104
109
110
+ #ifdef SERVER_TLS_EC_CALC_QUEUE
105
111
static bool tls_sec_prot_queue_check (sec_prot_t * prot );
106
112
static bool tls_sec_prot_queue_process (sec_prot_t * prot );
107
113
static void tls_sec_prot_queue_remove (sec_prot_t * prot );
114
+ #else
115
+ #define tls_sec_prot_queue_process (prot ) true
116
+ #define tls_sec_prot_queue_remove (prot )
117
+ #endif /* SERVER_TLS_EC_CALC_QUEUE */
108
118
109
119
static uint16_t tls_sec_prot_send_buffer_size_get (sec_prot_t * prot );
110
120
111
121
#define tls_sec_prot_get (prot ) (tls_sec_prot_int_t *) &prot->data
112
122
123
+ #ifdef SERVER_TLS_EC_CALC_QUEUE
113
124
static NS_LIST_DEFINE (tls_sec_prot_queue , tls_sec_prot_queue_t , link ) ;
125
+ #endif
114
126
115
127
int8_t client_tls_sec_prot_register (kmp_service_t * service )
116
128
{
@@ -168,7 +180,9 @@ static int8_t client_tls_sec_prot_init(sec_prot_t *prot)
168
180
data -> fin_timer_timeout = false;
169
181
data -> timer_running = false;
170
182
data -> calculating = false;
183
+ #ifdef SERVER_TLS_EC_CALC_QUEUE
171
184
data -> queued = false;
185
+ #endif
172
186
data -> library_init = false;
173
187
return 0 ;
174
188
}
@@ -198,7 +212,9 @@ static int8_t server_tls_sec_prot_init(sec_prot_t *prot)
198
212
data -> fin_timer_timeout = false;
199
213
data -> timer_running = false;
200
214
data -> calculating = false;
215
+ #ifdef SERVER_TLS_EC_CALC_QUEUE
201
216
data -> queued = false;
217
+ #endif
202
218
data -> library_init = false;
203
219
return 0 ;
204
220
}
@@ -281,7 +297,11 @@ static void tls_sec_prot_timer_timeout(sec_prot_t *prot, uint16_t ticks)
281
297
if (data -> fin_timer_timeout ) {
282
298
data -> fin_timer_timeout = false;
283
299
prot -> state_machine (prot );
284
- } else if (data -> calculating || data -> queued ) {
300
+ } else if (data -> calculating
301
+ #ifdef SERVER_TLS_EC_CALC_QUEUE
302
+ || data -> queued
303
+ #endif
304
+ ) {
285
305
prot -> state_machine (prot );
286
306
}
287
307
}
@@ -385,7 +405,9 @@ static void server_tls_sec_prot_state_machine(sec_prot_t *prot)
385
405
{
386
406
tls_sec_prot_int_t * data = tls_sec_prot_get (prot );
387
407
int8_t result ;
408
+ #ifdef SERVER_TLS_EC_CALC_QUEUE
388
409
bool client_hello = false;
410
+ #endif
389
411
390
412
switch (sec_prot_state_get (& data -> common )) {
391
413
case TLS_STATE_INIT :
@@ -400,7 +422,9 @@ static void server_tls_sec_prot_state_machine(sec_prot_t *prot)
400
422
case TLS_STATE_CLIENT_HELLO :
401
423
tr_debug ("TLS: start, eui-64: %s" , trace_array (sec_prot_remote_eui_64_addr_get (prot ), 8 ));
402
424
425
+ #ifdef SERVER_TLS_EC_CALC_QUEUE
403
426
client_hello = true;
427
+ #endif
404
428
405
429
sec_prot_state_set (prot , & data -> common , TLS_STATE_CREATE_RESP );
406
430
@@ -430,13 +454,15 @@ static void server_tls_sec_prot_state_machine(sec_prot_t *prot)
430
454
break ;
431
455
432
456
case TLS_STATE_PROCESS :
457
+ #ifdef SERVER_TLS_EC_CALC_QUEUE
433
458
// If not client hello, reserves slot on TLS queue
434
459
if (!client_hello && !tls_sec_prot_queue_check (prot )) {
435
460
data -> queued = true;
436
461
return ;
437
462
} else {
438
463
data -> queued = false;
439
464
}
465
+ #endif
440
466
441
467
result = tls_sec_prot_lib_process ((tls_security_t * ) & data -> tls_sec_inst );
442
468
@@ -636,6 +662,7 @@ static int8_t tls_sec_prot_tls_configure_and_connect(sec_prot_t *prot, bool is_s
636
662
return 0 ;
637
663
}
638
664
665
+ #ifdef SERVER_TLS_EC_CALC_QUEUE
639
666
static bool tls_sec_prot_queue_check (sec_prot_t * prot )
640
667
{
641
668
bool queue_add = true;
@@ -703,6 +730,7 @@ static void tls_sec_prot_queue_remove(sec_prot_t *prot)
703
730
}
704
731
}
705
732
}
733
+ #endif
706
734
707
735
static uint16_t tls_sec_prot_send_buffer_size_get (sec_prot_t * prot )
708
736
{
0 commit comments