forked from espressif/esp-idf
wpa_supplicant: Fix EAP Re-authentication issue
EAP reauth frames are dropped at various stages due to current implementation of WPA2 ENT states and EAP SM init/deinit logic. Route EAPOL frames based on EAP pkt type and maintain EAP SM to facilitate EAP re-authentication process.
This commit is contained in:
Submodule components/esp_wifi/lib_esp32 updated: 78c0f85ad4...2d738fb92a
@@ -511,7 +511,7 @@ out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wpa2_sm_rx_eapol(u8 *src_addr, u8 *buf, u32 len, uint8_t *bssid)
|
static int eap_sm_rx_eapol(u8 *src_addr, u8 *buf, u32 len, uint8_t *bssid)
|
||||||
{
|
{
|
||||||
struct eap_sm *sm = gEapSm;
|
struct eap_sm *sm = gEapSm;
|
||||||
|
|
||||||
@@ -545,6 +545,30 @@ static int wpa2_sm_rx_eapol(u8 *src_addr, u8 *buf, u32 len, uint8_t *bssid)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int wpa2_ent_rx_eapol(u8 *src_addr, u8 *buf, u32 len, uint8_t *bssid)
|
||||||
|
{
|
||||||
|
struct ieee802_1x_hdr *hdr;
|
||||||
|
int ret = ESP_OK;
|
||||||
|
|
||||||
|
hdr = (struct ieee802_1x_hdr *) buf;
|
||||||
|
|
||||||
|
switch (hdr->type) {
|
||||||
|
case IEEE802_1X_TYPE_EAPOL_START:
|
||||||
|
case IEEE802_1X_TYPE_EAP_PACKET:
|
||||||
|
case IEEE802_1X_TYPE_EAPOL_LOGOFF:
|
||||||
|
ret = eap_sm_rx_eapol(src_addr, buf, len, bssid);
|
||||||
|
break;
|
||||||
|
case IEEE802_1X_TYPE_EAPOL_KEY:
|
||||||
|
ret = wpa_sm_rx_eapol(src_addr, buf, len);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
wpa_printf(MSG_ERROR, "Unknown EAPOL packet type - %d\n", hdr->type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int eap_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len, uint8_t *bssid)
|
static int eap_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len, uint8_t *bssid)
|
||||||
{
|
{
|
||||||
struct eap_sm *sm = gEapSm;
|
struct eap_sm *sm = gEapSm;
|
||||||
@@ -613,6 +637,11 @@ static int eap_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len, uint8_t *bss
|
|||||||
#ifdef EAP_PEER_METHOD
|
#ifdef EAP_PEER_METHOD
|
||||||
switch (ehdr->code) {
|
switch (ehdr->code) {
|
||||||
case EAP_CODE_REQUEST:
|
case EAP_CODE_REQUEST:
|
||||||
|
/* Handle EAP-reauthentication case */
|
||||||
|
if (sm->finish_state == WPA2_ENT_EAP_STATE_SUCCESS) {
|
||||||
|
wpa_printf(MSG_INFO, ">>>>>wpa2 EAP Re-authentication in progress\n");
|
||||||
|
wpa2_set_eap_state(WPA2_ENT_EAP_STATE_IN_PROGRESS);
|
||||||
|
}
|
||||||
req = wpabuf_alloc_copy((u8 *)ehdr, len - sizeof(*hdr));
|
req = wpabuf_alloc_copy((u8 *)ehdr, len - sizeof(*hdr));
|
||||||
ret = eap_sm_process_request(sm, req);
|
ret = eap_sm_process_request(sm, req);
|
||||||
break;
|
break;
|
||||||
@@ -627,6 +656,7 @@ static int eap_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len, uint8_t *bss
|
|||||||
wpa_printf(MSG_INFO, ">>>>>wpa2 FINISH\n");
|
wpa_printf(MSG_INFO, ">>>>>wpa2 FINISH\n");
|
||||||
ret = WPA2_ENT_EAP_STATE_SUCCESS;
|
ret = WPA2_ENT_EAP_STATE_SUCCESS;
|
||||||
wpa2_set_eap_state(WPA2_ENT_EAP_STATE_SUCCESS);
|
wpa2_set_eap_state(WPA2_ENT_EAP_STATE_SUCCESS);
|
||||||
|
eap_deinit_prev_method(sm, "EAP Success");
|
||||||
} else {
|
} else {
|
||||||
wpa_printf(MSG_INFO, ">>>>>wpa2 FAILED, receive EAP_SUCCESS but pmk is empty, potential attack!\n");
|
wpa_printf(MSG_INFO, ">>>>>wpa2 FAILED, receive EAP_SUCCESS but pmk is empty, potential attack!\n");
|
||||||
ret = WPA2_ENT_EAP_STATE_FAIL;
|
ret = WPA2_ENT_EAP_STATE_FAIL;
|
||||||
@@ -825,7 +855,7 @@ esp_err_t esp_wifi_sta_wpa2_ent_enable_fn(void *arg)
|
|||||||
return ESP_ERR_NO_MEM;
|
return ESP_ERR_NO_MEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
wpa2_cb->wpa2_sm_rx_eapol = wpa2_sm_rx_eapol;
|
wpa2_cb->wpa2_sm_rx_eapol = wpa2_ent_rx_eapol;
|
||||||
wpa2_cb->wpa2_start = wpa2_start_eapol;
|
wpa2_cb->wpa2_start = wpa2_start_eapol;
|
||||||
wpa2_cb->wpa2_init = eap_peer_sm_init;
|
wpa2_cb->wpa2_init = eap_peer_sm_init;
|
||||||
wpa2_cb->wpa2_deinit = eap_peer_sm_deinit;
|
wpa2_cb->wpa2_deinit = eap_peer_sm_deinit;
|
||||||
|
Reference in New Issue
Block a user