From 1b60eab5410c5e73adb6b0d816acb15fe60389dd Mon Sep 17 00:00:00 2001 From: Sajia Date: Fri, 15 May 2026 12:10:04 +0530 Subject: [PATCH] refactor(wifi): Improve owe scan time and refactor code --- components/esp_rom/esp32c2/ld/esp32c2.rom.ld | 2 +- components/esp_wifi/include/esp_wifi.h | 24 ++++++++++++++++++- components/esp_wifi/lib | 2 +- .../remote/include/injected/esp_wifi.h | 24 ++++++++++++++++++- components/wpa_supplicant/src/rsn_supp/wpa.c | 9 ++++--- 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld index dd1019d8462..618653ee3d0 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld @@ -693,7 +693,7 @@ hal_agreement_del_rx_ba = 0x40001e14; /*hal_crypto_set_key_entry = 0x40001e18;*/ hal_crypto_get_key_entry = 0x40001e1c; hal_crypto_clr_key_entry = 0x40001e20; -config_get_wifi_task_stack_size = 0x40001e24; +/*config_get_wifi_task_stack_size = 0x40001e24;*/ pp_create_task = 0x40001e28; hal_set_sta_tsf_wakeup = 0x40001e2c; hal_set_rx_beacon_pti = 0x40001e30; diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index fb46cd5ae12..d37c9da0e6e 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -122,6 +122,7 @@ typedef struct { bool dump_hesigb_enable; /**< enable dump sigb field */ bool privacy_enhancements; /**< WiFi privacy enhancements (enables random mac, seq number, dialogue token number, vendor seq number cnt). Supported on station interface only; softAP may be added in future */ uint8_t rmac_auto_reset_int; /**< Random MAC auto-reset interval in hours (1-24) while not connected */ + int wifi_task_stack_size; /**< WIFI task stack size */ int magic; /**< WiFi init magic number, it should be the last field */ } wifi_init_config_t; @@ -298,6 +299,24 @@ extern wifi_osi_funcs_t g_wifi_osi_funcs; #define WIFI_ENABLE_OWE_SOFTAP 0 #endif +#if CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA +#define WIFI_ENABLE_WPA3_OWE_STA (1<<11) +#else +#define WIFI_ENABLE_WPA3_OWE_STA 0 +#endif + +#if CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA || CONFIG_ESP_WIFI_ENABLE_WPA3_SAE +#define WIFI_TASK_STACK_SIZE_BASE 6144 +#else +#define WIFI_TASK_STACK_SIZE_BASE 3072 +#endif + +#if !WIFI_NANO_FORMAT_ENABLED +#define WIFI_TASK_STACK_SIZE (WIFI_TASK_STACK_SIZE_BASE + 512) +#else +#define WIFI_TASK_STACK_SIZE WIFI_TASK_STACK_SIZE_BASE +#endif + #define CONFIG_FEATURE_WPA3_SAE_BIT (1<<0) #define CONFIG_FEATURE_CACHE_TX_BUF_BIT (1<<1) #define CONFIG_FEATURE_FTM_INITIATOR_BIT (1<<2) @@ -309,6 +328,7 @@ extern wifi_osi_funcs_t g_wifi_osi_funcs; #define CONFIG_FEATURE_BSS_MAX_IDLE_BIT (1<<8) #define CONFIG_FEATURE_WIFI_PASSIVE_HIDDEN_AP_BIT (1<<9) #define CONFIG_FEATURE_OWE_SOFTAP_BIT (1<<10) +#define CONFIG_FEATURE_WPA3_OWE_STA_BIT (1<<11) /* Set additional WiFi features and capabilities */ #define WIFI_FEATURE_CAPS (WIFI_ENABLE_WPA3_SAE | \ @@ -321,7 +341,8 @@ extern wifi_osi_funcs_t g_wifi_osi_funcs; WIFI_ENABLE_ENTERPRISE | \ WIFI_ENABLE_BSS_MAX_IDLE | \ WIFI_ENABLE_PASSIVE_HIDDEN_AP | \ - WIFI_ENABLE_OWE_SOFTAP) + WIFI_ENABLE_OWE_SOFTAP | \ + WIFI_ENABLE_WPA3_OWE_STA) #if CONFIG_ESP_WIFI_PRIVACY_ENHANCEMENTS_ENABLED #define WIFI_PRIVACY_ENHANCEMENTS_ENABLED true @@ -363,6 +384,7 @@ extern wifi_osi_funcs_t g_wifi_osi_funcs; .dump_hesigb_enable = WIFI_DUMP_HESIGB_ENABLED, \ .privacy_enhancements = WIFI_PRIVACY_ENHANCEMENTS_ENABLED, \ .rmac_auto_reset_int = WIFI_RMAC_AUTO_RESET_INTERVAL, \ + .wifi_task_stack_size = WIFI_TASK_STACK_SIZE, \ .magic = WIFI_INIT_CONFIG_MAGIC\ } diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 5bf80801f75..de151f5eb98 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 5bf80801f750baff6f8c3c8cffea5788e7a2f7b7 +Subproject commit de151f5eb98969915e4ab56d9d0bbcdf539acf4d diff --git a/components/esp_wifi/remote/include/injected/esp_wifi.h b/components/esp_wifi/remote/include/injected/esp_wifi.h index 10e41489f64..9d91f39cc8d 100644 --- a/components/esp_wifi/remote/include/injected/esp_wifi.h +++ b/components/esp_wifi/remote/include/injected/esp_wifi.h @@ -122,6 +122,7 @@ typedef struct { bool dump_hesigb_enable; /**< enable dump sigb field */ bool privacy_enhancements; /**< WiFi privacy enhancements (enables random mac, seq number, dialogue token number, vendor seq number cnt). Supported on station interface only; softAP may be added in future */ uint8_t rmac_auto_reset_int; /**< Random MAC auto-reset interval in hours (1-24) while not connected */ + int wifi_task_stack_size; /**< WIFI task stack size */ int magic; /**< WiFi init magic number, it should be the last field */ } wifi_init_config_t; @@ -298,6 +299,24 @@ extern wifi_osi_funcs_t g_wifi_osi_funcs; #define WIFI_ENABLE_OWE_SOFTAP 0 #endif +#if CONFIG_WIFI_RMT_ENABLE_WPA3_OWE_STA +#define WIFI_ENABLE_WPA3_OWE_STA (1<<11) +#else +#define WIFI_ENABLE_WPA3_OWE_STA 0 +#endif + +#if CONFIG_WIFI_RMT_ENABLE_WPA3_OWE_STA || CONFIG_WIFI_RMT_ENABLE_WPA3_SAE +#define WIFI_TASK_STACK_SIZE_BASE 6144 +#else +#define WIFI_TASK_STACK_SIZE_BASE 3072 +#endif + +#if !WIFI_NANO_FORMAT_ENABLED +#define WIFI_TASK_STACK_SIZE (WIFI_TASK_STACK_SIZE_BASE + 512) +#else +#define WIFI_TASK_STACK_SIZE WIFI_TASK_STACK_SIZE_BASE +#endif + #define CONFIG_FEATURE_WPA3_SAE_BIT (1<<0) #define CONFIG_FEATURE_CACHE_TX_BUF_BIT (1<<1) #define CONFIG_FEATURE_FTM_INITIATOR_BIT (1<<2) @@ -309,6 +328,7 @@ extern wifi_osi_funcs_t g_wifi_osi_funcs; #define CONFIG_FEATURE_BSS_MAX_IDLE_BIT (1<<8) #define CONFIG_FEATURE_WIFI_PASSIVE_HIDDEN_AP_BIT (1<<9) #define CONFIG_FEATURE_OWE_SOFTAP_BIT (1<<10) +#define CONFIG_FEATURE_WPA3_OWE_STA_BIT (1<<11) /* Set additional WiFi features and capabilities */ #define WIFI_FEATURE_CAPS (WIFI_ENABLE_WPA3_SAE | \ @@ -321,7 +341,8 @@ extern wifi_osi_funcs_t g_wifi_osi_funcs; WIFI_ENABLE_ENTERPRISE | \ WIFI_ENABLE_BSS_MAX_IDLE | \ WIFI_ENABLE_PASSIVE_HIDDEN_AP | \ - WIFI_ENABLE_OWE_SOFTAP) + WIFI_ENABLE_OWE_SOFTAP | \ + WIFI_ENABLE_WPA3_OWE_STA) #if CONFIG_WIFI_RMT_PRIVACY_ENHANCEMENTS_ENABLED #define WIFI_PRIVACY_ENHANCEMENTS_ENABLED true @@ -363,6 +384,7 @@ extern wifi_osi_funcs_t g_wifi_osi_funcs; .dump_hesigb_enable = WIFI_DUMP_HESIGB_ENABLED, \ .privacy_enhancements = WIFI_PRIVACY_ENHANCEMENTS_ENABLED, \ .rmac_auto_reset_int = WIFI_RMAC_AUTO_RESET_INTERVAL, \ + .wifi_task_stack_size = WIFI_TASK_STACK_SIZE, \ .magic = WIFI_INIT_CONFIG_MAGIC\ } diff --git a/components/wpa_supplicant/src/rsn_supp/wpa.c b/components/wpa_supplicant/src/rsn_supp/wpa.c index bda26a5747d..33712aebe58 100644 --- a/components/wpa_supplicant/src/rsn_supp/wpa.c +++ b/components/wpa_supplicant/src/rsn_supp/wpa.c @@ -3378,8 +3378,10 @@ int owe_process_assoc_resp(const u8 *rsn_ie, size_t rsn_len, const uint8_t *dh_i wpa_sm_set_pmk_from_pmksa(sm); goto done; } else { - /* If PMKID mismatches, derive keys again */ + /* If PMKID mismatches, abort assoc due to invalid pmkid*/ wpa_printf(MSG_DEBUG, "OWE : Invalid PMKID in response"); + os_free(parsed_rsn_data); + return 1; } } @@ -3392,11 +3394,8 @@ int owe_process_assoc_resp(const u8 *rsn_ie, size_t rsn_len, const uint8_t *dh_i goto fail; } - /* If STA or AP does not have PMKID, or PMKID mismatches, proceed with normal association */ - dh_len += 2; - + dh_len -=1; dh_ie += 3; - dh_len -=3; group = WPA_GET_LE16(dh_ie); /* Only group 19 is supported */