Skip to content

Commit 6845ab8

Browse files
author
Mika Leppänen
committed
Corrected EAP-TLS retries and ids and initial EAPOL-Key handling
On authenticator, if supplicant has already send a reply with an identifier and the same identifier is received again (e.g. message repeated on lower layers), EAP-TLS now ignores the message. Corrected identifier for EAP Success and Failure messages, shall be same as in last EAP Response. Disabled EAP-TLS retries from supplicant. If after authenticator has terminated EAP-TLS, supplicant sends EAP-TLS packet, authenticator now ignores the packet correctly and does not handle it as initial EAPOL-Key packet.
1 parent 50961c9 commit 6845ab8

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

source/Security/protocols/eap_tls_sec_prot/auth_eap_tls_sec_prot.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ typedef struct {
6060
tls_data_t tls_send; /**< EAP-TLS send buffer */
6161
tls_data_t tls_recv; /**< EAP-TLS receive buffer */
6262
uint8_t eap_id_seq; /**< EAP sequence */
63+
uint8_t recv_eap_id_seq; /**< Last received EAP sequence */
6364
uint8_t eap_code; /**< Received EAP code */
6465
uint8_t eap_type; /**< Received EAP type */
6566
int8_t tls_result; /**< Result of TLS operation */
@@ -129,6 +130,7 @@ static int8_t auth_eap_tls_sec_prot_init(sec_prot_t *prot)
129130

130131
data->tls_prot = NULL;
131132
data->eap_id_seq = 0;
133+
data->recv_eap_id_seq = 0;
132134
data->eap_code = 0;
133135
data->eap_type = 0;
134136
eap_tls_sec_prot_lib_message_init(&data->tls_recv);
@@ -188,8 +190,14 @@ static int8_t auth_eap_tls_sec_prot_message_handle(sec_prot_t *prot)
188190
uint16_t length = data->recv_eapol_pdu.msg.eap.length;
189191

190192
bool new_seq_id = false;
191-
// Confirmation that supplicant has received the message, proceed with protocol
192-
if (data->recv_eapol_pdu.msg.eap.id_seq == data->eap_id_seq) {
193+
bool old_seq_id = false;
194+
195+
// Already received sequence ID is received again, ignore
196+
if (data->recv_eapol_pdu.msg.eap.id_seq < data->eap_id_seq) {
197+
old_seq_id = true;
198+
} else if (data->recv_eapol_pdu.msg.eap.id_seq == data->eap_id_seq) {
199+
// Confirmation that supplicant has received the message, proceed with protocol
200+
data->recv_eap_id_seq = data->recv_eapol_pdu.msg.eap.id_seq;
193201
data->eap_id_seq++;
194202
new_seq_id = true;
195203
}
@@ -198,6 +206,10 @@ static int8_t auth_eap_tls_sec_prot_message_handle(sec_prot_t *prot)
198206
data->eap_type == EAP_IDENTITY ? "IDENTITY" : "TLS", data->recv_eapol_pdu.msg.eap.id_seq,
199207
length >= 6 ? data_ptr[0] : 0, length, trace_array(sec_prot_remote_eui_64_addr_get(prot), 8));
200208

209+
if (old_seq_id) {
210+
return EAP_TLS_MSG_DECODE_ERROR;
211+
}
212+
201213
if (data->eap_type == EAP_IDENTITY) {
202214
return EAP_TLS_MSG_IDENTITY;
203215
}
@@ -227,7 +239,10 @@ static int8_t auth_eap_tls_sec_prot_message_send(sec_prot_t *prot, uint8_t eap_c
227239
eap_tls_sec_prot_lib_message_allocate(&data->tls_send, TLS_HEAD_LEN, 0);
228240
flags = EAP_TLS_START;
229241
}
230-
} else if (eap_code != EAP_SUCCESS && eap_code != EAP_FAILURE) {
242+
} else if (eap_code == EAP_SUCCESS || eap_code == EAP_FAILURE) {
243+
// Send Success and Failure with same identifier as received in EAP Response
244+
data->eap_id_seq = data->recv_eap_id_seq;
245+
} else {
231246
return -1;
232247
}
233248

source/Security/protocols/eap_tls_sec_prot/supp_eap_tls_sec_prot.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,8 @@ static void supp_eap_tls_sec_prot_state_machine(sec_prot_t *prot)
403403
case EAP_TLS_STATE_REQUEST_TLS_EAP:
404404
// On timeout
405405
if (sec_prot_result_timeout_check(&data->common)) {
406-
// Re-send EAP response, Identity
407-
supp_eap_tls_sec_prot_message_send(prot, EAP_RESPONSE, EAP_IDENTITY, EAP_TLS_EXCHANGE_NONE);
406+
/* Waits for next trickle expire. If trickle expirations reach the limit,
407+
terminates EAP-TLS */
408408
return;
409409
}
410410

@@ -436,8 +436,8 @@ static void supp_eap_tls_sec_prot_state_machine(sec_prot_t *prot)
436436
case EAP_TLS_STATE_REQUEST:
437437
// On timeout
438438
if (sec_prot_result_timeout_check(&data->common)) {
439-
// Re-send EAP response
440-
supp_eap_tls_sec_prot_message_send(prot, EAP_RESPONSE, EAP_TLS, EAP_TLS_EXCHANGE_ONGOING);
439+
/* Waits for next trickle expire. If trickle expirations reach the limit,
440+
terminates EAP-TLS */
441441
return;
442442
}
443443

source/Security/protocols/key_sec_prot/key_sec_prot.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ static int8_t key_sec_prot_receive(sec_prot_t *prot, void *pdu, uint16_t size)
198198

199199
// Decoding is successful
200200
if (eapol_parse_pdu_header(pdu, size, &eapol_pdu)) {
201+
if (eapol_pdu.packet_type != EAPOL_KEY_TYPE) {
202+
tr_info("not EAPOL-Key packet");
203+
prot->finished(prot);
204+
return -1;
205+
}
206+
201207
uint16_t kde_len;
202208
uint8_t *kde = sec_prot_lib_message_handle(prot->sec_keys->ptk, &kde_len, &eapol_pdu);
203209
if (!kde) {

0 commit comments

Comments
 (0)