Skip to content

Commit d04523e

Browse files
author
Mika Leppänen
committed
Added timer to supplicant to filter EAP-TLS re-transmission bursts
If burst of EAP-TLS re-transmissions arrive in a fast pace (re-transmissions are made by lower layers) ignores those and does not reply. Filtering is made by timer that runs for 5 seconds after a message with fresh sequence id is received. Timer is started again if re-transmission with same sequence id arrives while the timer is running. Also if re-transmission arrives after the timer has timeouted, sends one reply to re-transmission and starts the timer again.
1 parent 3524877 commit d04523e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

source/Security/protocols/eap_tls_sec_prot/supp_eap_tls_sec_prot.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,16 @@ typedef enum {
5353
EAP_TLS_STATE_FINISHED = SEC_STATE_FINISHED
5454
} eap_tls_sec_prot_state_e;
5555

56+
// Filters EAP re-transmission bursts that arrive with same EAP sequence number
57+
#define BURST_FILTER_TIMER_TIMEOUT 5 * 10
58+
5659
typedef struct {
5760
sec_prot_common_t common; /**< Common data */
5861
sec_prot_t *tls_prot; /**< TLS security protocol */
5962
eapol_pdu_t recv_eapol_pdu; /**< Received EAPOL PDU */
6063
tls_data_t tls_send; /**< EAP-TLS send buffer */
6164
tls_data_t tls_recv; /**< EAP-TLS receive buffer */
65+
uint16_t burst_filt_timer; /**< Burst filter timer */
6266
uint8_t eap_id_seq; /**< EAP sequence */
6367
uint8_t eap_code; /**< Received EAP code */
6468
uint8_t eap_type; /**< Received EAP type */
@@ -127,6 +131,7 @@ static int8_t supp_eap_tls_sec_prot_init(sec_prot_t *prot)
127131
sec_prot_state_set(prot, &data->common, EAP_TLS_STATE_INIT);
128132

129133
data->tls_prot = NULL;
134+
data->burst_filt_timer = 0;
130135
data->eap_id_seq = 0;
131136
data->eap_code = 0;
132137
data->eap_type = 0;
@@ -193,7 +198,18 @@ static int8_t supp_eap_tls_sec_prot_message_handle(sec_prot_t *prot)
193198
uint8_t new_seq_id = false;
194199
// New sequence identifier received
195200
if (data->recv_eapol_pdu.msg.eap.id_seq > data->eap_id_seq) {
201+
data->burst_filt_timer = BURST_FILTER_TIMER_TIMEOUT;
196202
new_seq_id = true;
203+
} else if (data->recv_eapol_pdu.msg.eap.id_seq == data->eap_id_seq) {
204+
if (data->burst_filt_timer > 0) {
205+
/* If retransmission arrives when burst filter timer is running, ignores it
206+
and starts timer again */
207+
data->burst_filt_timer = BURST_FILTER_TIMER_TIMEOUT;
208+
return EAP_TLS_MSG_DECODE_ERROR;
209+
} else {
210+
// If retransmission arrives after timeout, starts timer again
211+
data->burst_filt_timer = BURST_FILTER_TIMER_TIMEOUT;
212+
}
197213
} else if (data->recv_eapol_pdu.msg.eap.id_seq < data->eap_id_seq) {
198214
// Already received sequence ID is received again, ignore
199215
return EAP_TLS_MSG_DECODE_ERROR;
@@ -256,6 +272,12 @@ static void supp_eap_tls_sec_prot_timer_timeout(sec_prot_t *prot, uint16_t ticks
256272
{
257273
eap_tls_sec_prot_int_t *data = eap_tls_sec_prot_get(prot);
258274
sec_prot_timer_timeout_handle(prot, &data->common, &eap_tls_trickle_params, ticks);
275+
276+
if (data->burst_filt_timer > ticks) {
277+
data->burst_filt_timer -= ticks;
278+
} else {
279+
data->burst_filt_timer = 0;
280+
}
259281
}
260282

261283
static void supp_eap_tls_sec_prot_tls_create_confirm(sec_prot_t *tls_prot, sec_prot_result_e result)

0 commit comments

Comments
 (0)