Skip to content

Commit e2ea4e4

Browse files
author
Mika Leppänen
committed
Disabled BR (TLS server) EC calculation queue
Queue is not needed, since on BR HW EC calculation is made in a one go.
1 parent 5759851 commit e2ea4e4

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

source/Security/protocols/tls_sec_prot/tls_sec_prot.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,20 @@ typedef struct {
6969
bool timer_running : 1; /**< TLS timer running */
7070
bool finished : 1; /**< TLS finished */
7171
bool calculating : 1; /**< TLS is calculating */
72+
#ifdef SERVER_TLS_EC_CALC_QUEUE
7273
bool queued : 1; /**< TLS is queued */
74+
#endif
7375
bool library_init : 1; /**< TLS library has been initialized */
7476
tls_sec_prot_lib_int_t *tls_sec_inst; /**< TLS security library storage, SHALL BE THE LAST FIELD */
7577
} tls_sec_prot_int_t;
7678

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
7781
typedef struct {
7882
ns_list_link_t link; /**< Link */
7983
sec_prot_t *prot; /**< Protocol instance */
8084
} tls_sec_prot_queue_t;
85+
#endif
8186

8287
static uint16_t tls_sec_prot_size(void);
8388
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);
102107

103108
static int8_t tls_sec_prot_tls_configure_and_connect(sec_prot_t *prot, bool is_server);
104109

110+
#ifdef SERVER_TLS_EC_CALC_QUEUE
105111
static bool tls_sec_prot_queue_check(sec_prot_t *prot);
106112
static bool tls_sec_prot_queue_process(sec_prot_t *prot);
107113
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 */
108118

109119
static uint16_t tls_sec_prot_send_buffer_size_get(sec_prot_t *prot);
110120

111121
#define tls_sec_prot_get(prot) (tls_sec_prot_int_t *) &prot->data
112122

123+
#ifdef SERVER_TLS_EC_CALC_QUEUE
113124
static NS_LIST_DEFINE(tls_sec_prot_queue, tls_sec_prot_queue_t, link);
125+
#endif
114126

115127
int8_t client_tls_sec_prot_register(kmp_service_t *service)
116128
{
@@ -168,7 +180,9 @@ static int8_t client_tls_sec_prot_init(sec_prot_t *prot)
168180
data->fin_timer_timeout = false;
169181
data->timer_running = false;
170182
data->calculating = false;
183+
#ifdef SERVER_TLS_EC_CALC_QUEUE
171184
data->queued = false;
185+
#endif
172186
data->library_init = false;
173187
return 0;
174188
}
@@ -198,7 +212,9 @@ static int8_t server_tls_sec_prot_init(sec_prot_t *prot)
198212
data->fin_timer_timeout = false;
199213
data->timer_running = false;
200214
data->calculating = false;
215+
#ifdef SERVER_TLS_EC_CALC_QUEUE
201216
data->queued = false;
217+
#endif
202218
data->library_init = false;
203219
return 0;
204220
}
@@ -281,7 +297,11 @@ static void tls_sec_prot_timer_timeout(sec_prot_t *prot, uint16_t ticks)
281297
if (data->fin_timer_timeout) {
282298
data->fin_timer_timeout = false;
283299
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+
) {
285305
prot->state_machine(prot);
286306
}
287307
}
@@ -385,7 +405,9 @@ static void server_tls_sec_prot_state_machine(sec_prot_t *prot)
385405
{
386406
tls_sec_prot_int_t *data = tls_sec_prot_get(prot);
387407
int8_t result;
408+
#ifdef SERVER_TLS_EC_CALC_QUEUE
388409
bool client_hello = false;
410+
#endif
389411

390412
switch (sec_prot_state_get(&data->common)) {
391413
case TLS_STATE_INIT:
@@ -400,7 +422,9 @@ static void server_tls_sec_prot_state_machine(sec_prot_t *prot)
400422
case TLS_STATE_CLIENT_HELLO:
401423
tr_debug("TLS: start, eui-64: %s", trace_array(sec_prot_remote_eui_64_addr_get(prot), 8));
402424

425+
#ifdef SERVER_TLS_EC_CALC_QUEUE
403426
client_hello = true;
427+
#endif
404428

405429
sec_prot_state_set(prot, &data->common, TLS_STATE_CREATE_RESP);
406430

@@ -430,13 +454,15 @@ static void server_tls_sec_prot_state_machine(sec_prot_t *prot)
430454
break;
431455

432456
case TLS_STATE_PROCESS:
457+
#ifdef SERVER_TLS_EC_CALC_QUEUE
433458
// If not client hello, reserves slot on TLS queue
434459
if (!client_hello && !tls_sec_prot_queue_check(prot)) {
435460
data->queued = true;
436461
return;
437462
} else {
438463
data->queued = false;
439464
}
465+
#endif
440466

441467
result = tls_sec_prot_lib_process((tls_security_t *) &data->tls_sec_inst);
442468

@@ -636,6 +662,7 @@ static int8_t tls_sec_prot_tls_configure_and_connect(sec_prot_t *prot, bool is_s
636662
return 0;
637663
}
638664

665+
#ifdef SERVER_TLS_EC_CALC_QUEUE
639666
static bool tls_sec_prot_queue_check(sec_prot_t *prot)
640667
{
641668
bool queue_add = true;
@@ -703,6 +730,7 @@ static void tls_sec_prot_queue_remove(sec_prot_t *prot)
703730
}
704731
}
705732
}
733+
#endif
706734

707735
static uint16_t tls_sec_prot_send_buffer_size_get(sec_prot_t *prot)
708736
{

0 commit comments

Comments
 (0)