esp_wifi: Flush PMK caching if bss akm has changed
@@ -2316,8 +2316,15 @@ int wpa_set_bss(char *macddr, char * bssid, u8 pairwise_cipher, u8 group_cipher,
sm->key_mgmt == WPA_KEY_MGMT_OWE ||
is_wpa2_enterprise_connection()) {
if (!esp_wifi_skip_supp_pmkcaching() && use_pmk_cache) {
- pmksa_cache_set_current(sm, NULL, (const u8*) bssid, 0, 0);
+ if (pmksa_cache_set_current(sm, NULL, (const u8*) bssid, 0, 0) == 0) {
+ struct rsn_pmksa_cache_entry *pmksa = pmksa_cache_get_current(sm);
+ if (pmksa && (pmksa->akmp != sm->key_mgmt)) {
+ pmksa_cache_clear_current(sm);
+ pmksa_cache_flush(sm->pmksa, NULL, pmksa->pmk, pmksa->pmk_len);
+ }
+ } else {
wpa_sm_set_pmk_from_pmksa(sm);
+ }
} else {
struct rsn_pmksa_cache_entry *entry = NULL;
