From f3f08fa713190ad527dcf7bcb4113b82f809f4bf Mon Sep 17 00:00:00 2001 From: liu zhifu Date: Mon, 8 Jul 2019 16:23:33 +0800 Subject: [PATCH] esp_wifi/supplicant: fix some supplicant bugs Closes IDFGH-1455 Closes IDF-774 --- components/esp_wifi/lib_esp32 | 2 +- components/wpa_supplicant/Kconfig | 27 ------------------- components/wpa_supplicant/component.mk | 2 +- .../port/include/supplicant_opt.h | 12 --------- .../src/esp_supplicant/esp_wifi_driver.h | 4 ++- .../src/esp_supplicant/esp_wpa2.c | 4 --- .../src/esp_supplicant/esp_wps.c | 6 ++--- components/wpa_supplicant/src/rsn_supp/wpa.c | 7 ++--- 8 files changed, 11 insertions(+), 53 deletions(-) diff --git a/components/esp_wifi/lib_esp32 b/components/esp_wifi/lib_esp32 index 7c7c2e3f9..e214daa32 160000 --- a/components/esp_wifi/lib_esp32 +++ b/components/esp_wifi/lib_esp32 @@ -1 +1 @@ -Subproject commit 7c7c2e3f978ddaeadb1365a0f8fbbcb423886d97 +Subproject commit e214daa325ede0981d0bd380306d4edd5a9fcc80 diff --git a/components/wpa_supplicant/Kconfig b/components/wpa_supplicant/Kconfig index 3d57c76e0..927dc0165 100644 --- a/components/wpa_supplicant/Kconfig +++ b/components/wpa_supplicant/Kconfig @@ -1,32 +1,5 @@ menu "Supplicant" - config WPA_ENTERPRISE - bool "Enable WPA/WPA2-Enterprise" - default n - help - Select this option to enable WiFi WPA/WPA2-Enterprise authentication. - - config WPA_EAP_TLS - bool "Enable EAP-TLS" - depends on WPA_ENTERPRISE - default y - help - Select this option to support EAP-TLS. - - config WPA_EAP_TTLS - bool "Enable EAP-TTLS" - depends on WPA_ENTERPRISE - default y - help - Select this option to support EAP-TTLS. - - config WPA_EAP_PEAP - bool "Enable EAP-PEAP" - depends on WPA_ENTERPRISE - default y - help - Select this option to support EAP-PEAP. - config WPA_MBEDTLS_CRYPTO bool "Use MbedTLS crypto API's" default y diff --git a/components/wpa_supplicant/component.mk b/components/wpa_supplicant/component.mk index 1320854b9..e85e9979f 100644 --- a/components/wpa_supplicant/component.mk +++ b/components/wpa_supplicant/component.mk @@ -2,4 +2,4 @@ COMPONENT_ADD_INCLUDEDIRS := include port/include include/esp_supplicant COMPONENT_PRIV_INCLUDEDIRS := src COMPONENT_SRCDIRS := port src/ap src/common src/crypto src/eap_peer src/rsn_supp src/tls src/utils src/esp_supplicant src/wps -CFLAGS += -DESP_SUPPLICANT -DIEEE8021X_EAPOL -DEAP_PEER_METHOD -DEAP_MSCHAPv2 -DUSE_WPA2_TASK -DCONFIG_WPS2 -DCONFIG_WPS_PIN -DUSE_WPS_TASK -DESPRESSIF_USE -DESP32_WORKAROUND -DCONFIG_ECC -D__ets__ -Wno-strict-aliasing +CFLAGS += -DESP_SUPPLICANT -DIEEE8021X_EAPOL -DEAP_PEER_METHOD -DEAP_TLS -DEAP_TTLS -DEAP_PEAP -DEAP_MSCHAPv2 -DUSE_WPA2_TASK -DCONFIG_WPS2 -DCONFIG_WPS_PIN -DUSE_WPS_TASK -DESPRESSIF_USE -DESP32_WORKAROUND -DCONFIG_ECC -D__ets__ -Wno-strict-aliasing diff --git a/components/wpa_supplicant/port/include/supplicant_opt.h b/components/wpa_supplicant/port/include/supplicant_opt.h index 446dda0b0..12d607add 100644 --- a/components/wpa_supplicant/port/include/supplicant_opt.h +++ b/components/wpa_supplicant/port/include/supplicant_opt.h @@ -17,18 +17,6 @@ #include "sdkconfig.h" -#if CONFIG_WPA_EAP_TLS -#define EAP_TLS 1 -#endif - -#if CONFIG_WPA_EAP_TTLS -#define EAP_TTLS 1 -#endif - -#if CONFIG_WPA_EAP_PEAP -#define EAP_PEAP 1 -#endif - #if CONFIG_WPA_MBEDTLS_CRYPTO #define USE_MBEDTLS_CRYPTO 1 #endif diff --git a/components/wpa_supplicant/src/esp_supplicant/esp_wifi_driver.h b/components/wpa_supplicant/src/esp_supplicant/esp_wifi_driver.h index fdef1d350..62d2d6246 100644 --- a/components/wpa_supplicant/src/esp_supplicant/esp_wifi_driver.h +++ b/components/wpa_supplicant/src/esp_supplicant/esp_wifi_driver.h @@ -168,7 +168,6 @@ struct wifi_ssid *esp_wifi_ap_get_prof_ap_ssid_internal(void); uint8_t esp_wifi_ap_get_prof_authmode_internal(void); uint8_t esp_wifi_sta_get_prof_authmode_internal(void); uint8_t *esp_wifi_ap_get_prof_password_internal(void); -uint8_t *esp_wifi_sta_get_prof_pmk_internal(void); struct wifi_ssid *esp_wifi_sta_get_prof_ssid_internal(void); uint8_t esp_wifi_sta_get_reset_param_internal(void); uint8_t esp_wifi_sta_get_pairwise_cipher_internal(void); @@ -216,5 +215,8 @@ bool esp_wifi_enable_sta_privacy_internal(void); uint8_t esp_wifi_get_user_init_flag_internal(void); esp_err_t esp_wifi_send_event_internal(system_event_t *evt); esp_err_t esp_wifi_internal_supplicant_header_md5_check(const char *md5); +int esp_wifi_sta_update_ap_info_internal(void); +uint8_t *esp_wifi_sta_get_ap_info_prof_pmk_internal(void); +esp_err_t esp_wifi_set_wps_start_flag_internal(bool start); #endif /* _ESP_WIFI_DRIVER_H_ */ diff --git a/components/wpa_supplicant/src/esp_supplicant/esp_wpa2.c b/components/wpa_supplicant/src/esp_supplicant/esp_wpa2.c index de7a3552a..584b2acc1 100644 --- a/components/wpa_supplicant/src/esp_supplicant/esp_wpa2.c +++ b/components/wpa_supplicant/src/esp_supplicant/esp_wpa2.c @@ -808,8 +808,6 @@ static void eap_peer_sm_deinit(void) gEapSm = NULL; } -uint8_t wpa2_machine_start = 0; - esp_err_t esp_wifi_sta_wpa2_ent_enable_fn(void *arg) { struct wpa2_funcs *wpa2_cb; @@ -837,7 +835,6 @@ esp_err_t esp_wifi_sta_wpa2_ent_enable_fn(void *arg) wpa_printf(MSG_ERROR, "Register EAP Peer methods Failure\n"); } #endif - wpa2_machine_start = 1; return ESP_OK; } @@ -886,7 +883,6 @@ esp_err_t esp_wifi_sta_wpa2_ent_disable_fn(void *param) eap_peer_unregister_methods(); #endif - wpa2_machine_start = 0; return ESP_OK; } diff --git a/components/wpa_supplicant/src/esp_supplicant/esp_wps.c b/components/wpa_supplicant/src/esp_supplicant/esp_wps.c index c666de305..cbcd35197 100644 --- a/components/wpa_supplicant/src/esp_supplicant/esp_wps.c +++ b/components/wpa_supplicant/src/esp_supplicant/esp_wps.c @@ -1831,7 +1831,6 @@ void wifi_wps_scan(void) #endif } -uint8_t wps_start = 0; int wifi_station_wps_start(void) { struct wps_sm *sm = wps_sm_get(); @@ -1862,8 +1861,7 @@ int wifi_station_wps_start(void) default: break; } - wps_start = 1; - + esp_wifi_set_wps_start_flag_internal(true); return ESP_OK; } @@ -2125,7 +2123,7 @@ int esp_wifi_wps_disable(void) } esp_wifi_disconnect(); - wps_start = 0; + esp_wifi_set_wps_start_flag_internal(false); wps_task_deinit(); s_wps_enabled = false; API_MUTEX_GIVE(); diff --git a/components/wpa_supplicant/src/rsn_supp/wpa.c b/components/wpa_supplicant/src/rsn_supp/wpa.c index 29d79bbc6..2ce7bbebe 100644 --- a/components/wpa_supplicant/src/rsn_supp/wpa.c +++ b/components/wpa_supplicant/src/rsn_supp/wpa.c @@ -1778,18 +1778,19 @@ wpa_set_passphrase(char * passphrase, u8 *ssid, size_t ssid_len) if (esp_wifi_sta_get_reset_param_internal() != 0) { // check it's psk if (strlen((char *)esp_wifi_sta_get_prof_password_internal()) == 64) { - hexstr2bin((char *)esp_wifi_sta_get_prof_password_internal(), esp_wifi_sta_get_prof_pmk_internal(), PMK_LEN); + hexstr2bin((char *)esp_wifi_sta_get_prof_password_internal(), esp_wifi_sta_get_ap_info_prof_pmk_internal(), PMK_LEN); } else { pbkdf2_sha1((char *)esp_wifi_sta_get_prof_password_internal(), (char *)sta_ssid->ssid, (size_t)sta_ssid->len, - 4096, esp_wifi_sta_get_prof_pmk_internal(), PMK_LEN); + 4096, esp_wifi_sta_get_ap_info_prof_pmk_internal(), PMK_LEN); } + esp_wifi_sta_update_ap_info_internal(); esp_wifi_sta_set_reset_param_internal(0); } if (sm->key_mgmt == WPA_KEY_MGMT_IEEE8021X) { /* TODO nothing */ } else { - memcpy(sm->pmk, esp_wifi_sta_get_prof_pmk_internal(), PMK_LEN); + memcpy(sm->pmk, esp_wifi_sta_get_ap_info_prof_pmk_internal(), PMK_LEN); } sm->pmk_len = PMK_LEN; }