From bb98101bd4acd48f1d0654a7c15840cde0a01d78 Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Thu, 29 Nov 2018 14:41:39 -0800 Subject: [PATCH] eap-tls-common: Handle response retransmission --- src/eap-tls-common.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ src/eap-tls-common.h | 2 ++ 2 files changed, 47 insertions(+) diff --git a/src/eap-tls-common.c b/src/eap-tls-common.c index a2c66270..680f69b7 100644 --- a/src/eap-tls-common.c +++ b/src/eap-tls-common.c @@ -608,6 +608,51 @@ error: eap_method_error(eap); } +void eap_tls_common_handle_retransmit(struct eap_state *eap, + const uint8_t *pkt, size_t len) +{ + struct eap_tls_state *eap_tls = eap_get_data(eap); + uint8_t flags_version; + + if (len < 1) { + l_error("%s: Request packet is too short.", + eap_get_method_name(eap)); + goto error; + } + + flags_version = pkt[0]; + + if (!eap_tls_validate_version(eap, flags_version)) { + l_error("%s: Version negotiation has failed.", + eap_get_method_name(eap)); + goto error; + } + + if (flags_version & EAP_TLS_FLAG_M) { + if (!eap_tls->rx_pdu_buf) + goto error; + + eap_tls_send_fragmented_request_ack(eap); + + return; + } + + if (!eap_tls->tx_pdu_buf || !eap_tls->tx_pdu_buf->data || + !eap_tls->tx_pdu_buf->len) + goto error; + + if (EAP_TLS_HEADER_LEN + eap_tls->tx_pdu_buf->len > eap_get_mtu(eap)) + eap_tls_send_fragment(eap); + else + eap_tls_send_response(eap, eap_tls->tx_pdu_buf->data, + eap_tls->tx_pdu_buf->len); + + return; + +error: + eap_method_error(eap); +} + int eap_tls_common_settings_check(struct l_settings *settings, struct l_queue *secrets, const char *prefix, diff --git a/src/eap-tls-common.h b/src/eap-tls-common.h index 57320491..fe2d897c 100644 --- a/src/eap-tls-common.h +++ b/src/eap-tls-common.h @@ -56,6 +56,8 @@ void eap_tls_common_set_phase2_faild(struct eap_state *eap); void eap_tls_common_handle_request(struct eap_state *eap, const uint8_t *pkt, size_t len); +void eap_tls_common_handle_retransmit(struct eap_state *eap, + const uint8_t *pkt, size_t len); int eap_tls_common_settings_check(struct l_settings *settings, struct l_queue *secrets,