Merge branch 'feature/disable_pmk_caching' into 'master'

feat(esp_wifi): Provide API to disable PMK caching

See merge request espressif/esp-idf!29902
This commit is contained in:
Jiang Jiang Jian 2024-04-02 16:15:34 +08:00
commit 1bcd5bca14
3 changed files with 28 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -57,6 +57,22 @@ esp_err_t esp_supplicant_init(void);
*/ */
esp_err_t esp_supplicant_deinit(void); esp_err_t esp_supplicant_deinit(void);
/**
* @brief Disable or enable the caching of Pairwise Master Keys (PMK) in the supplicant.
*
* This function allows disabling or enabling the caching of Pairwise Master Keys (PMK).
* PMK caching is used in Wi-Fi Protected Access (WPA/WPA2/WPA3) networks to speed up the reconnection process
* by storing the PMK generated during the initial connection. Disabling PMK caching may result in slightly
* longer reconnection times. PMK caching is enabled by default, this configuration has been provided
* in case the AP is known not to support PMK caching or has a buggy implementation for PMK caching.
*
* @param disable Boolean indicating whether to disable (true) or enable (false) PMK caching.
* @return
* - ESP_OK: Success
* - An error code if disabling or enabling PMK caching fails.
*/
esp_err_t esp_supplicant_disable_pmk_caching(bool disable);
/** /**
* @} * @}
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@ -48,6 +48,7 @@
#include "esp_dpp_i.h" #include "esp_dpp_i.h"
#endif #endif
bool g_wpa_pmk_caching_disabled = 0;
const wifi_osi_funcs_t *wifi_funcs; const wifi_osi_funcs_t *wifi_funcs;
struct wpa_funcs *wpa_cb; struct wpa_funcs *wpa_cb;
@ -298,6 +299,9 @@ static void wpa_sta_disconnected_cb(uint8_t reason_code)
wpa_sm_notify_disassoc(&gWpaSm); wpa_sm_notify_disassoc(&gWpaSm);
break; break;
default: default:
if (g_wpa_pmk_caching_disabled) {
wpa_sta_clear_curr_pmksa();
}
break; break;
} }
#ifdef CONFIG_OWE_STA #ifdef CONFIG_OWE_STA
@ -487,3 +491,9 @@ int esp_supplicant_deinit(void)
wpa_cb = NULL; wpa_cb = NULL;
return esp_wifi_unregister_wpa_cb_internal(); return esp_wifi_unregister_wpa_cb_internal();
} }
esp_err_t esp_supplicant_disable_pmk_caching(bool disable)
{
g_wpa_pmk_caching_disabled = disable;
return ESP_OK;
}