mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/sae_auth_and_pmk_issues_v4.3' into 'release/v4.3'
Fix SAE open auth and PMK issues (Backport v4.3) See merge request espressif/esp-idf!21920
This commit is contained in:
commit
80dd246b14
@ -1 +1 @@
|
||||
Subproject commit 4357a7bf06fe1da91bf067891a3c7ef2e9c4298f
|
||||
Subproject commit 22878be3b2f9e518c517df3f827323aa5a04e354
|
@ -118,6 +118,13 @@ static inline int wpa_key_mgmt_cckm(int akm)
|
||||
return akm == WPA_KEY_MGMT_CCKM;
|
||||
}
|
||||
|
||||
#ifdef ESP_SUPPLICANT
|
||||
static inline int wpa_key_mgmt_supports_caching(int akm)
|
||||
{
|
||||
return wpa_key_mgmt_wpa_ieee8021x(akm) ||
|
||||
wpa_key_mgmt_sae(akm);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define WPA_PROTO_WPA BIT(0)
|
||||
#define WPA_PROTO_RSN BIT(1)
|
||||
|
@ -18,7 +18,7 @@ static struct wpabuf *g_sae_commit = NULL;
|
||||
static struct wpabuf *g_sae_confirm = NULL;
|
||||
int g_allowed_groups[] = { IANA_SECP256R1, 0 };
|
||||
|
||||
static esp_err_t wpa3_build_sae_commit(u8 *bssid)
|
||||
static esp_err_t wpa3_build_sae_commit(u8 *bssid, size_t *sae_msg_len)
|
||||
{
|
||||
int default_group = IANA_SECP256R1;
|
||||
u32 len = 0;
|
||||
@ -33,6 +33,7 @@ static esp_err_t wpa3_build_sae_commit(u8 *bssid)
|
||||
|
||||
if (wpa_sta_cur_pmksa_matches_akm()) {
|
||||
wpa_printf(MSG_INFO, "wpa3: Skip SAE and use cached PMK instead");
|
||||
*sae_msg_len = 0;
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
@ -151,7 +152,7 @@ static u8 *wpa3_build_sae_msg(u8 *bssid, u32 sae_msg_type, size_t *sae_msg_len)
|
||||
if (esp_wifi_get_wps_status_internal() != WPS_STATUS_DISABLE) {
|
||||
return NULL;
|
||||
}
|
||||
if (ESP_OK != wpa3_build_sae_commit(bssid))
|
||||
if (ESP_OK != wpa3_build_sae_commit(bssid, sae_msg_len))
|
||||
return NULL;
|
||||
*sae_msg_len = wpabuf_len(g_sae_commit);
|
||||
buf = wpabuf_mhead_u8(g_sae_commit);
|
||||
|
@ -2326,7 +2326,7 @@ int wpa_set_bss(char *macddr, char * bssid, u8 pairwise_cipher, u8 group_cipher,
|
||||
{
|
||||
int res = 0;
|
||||
struct wpa_sm *sm = &gWpaSm;
|
||||
bool use_pmk_cache = true;
|
||||
bool use_pmk_cache = !esp_wifi_skip_supp_pmkcaching();
|
||||
u8 assoc_rsnxe[20];
|
||||
size_t assoc_rsnxe_len = sizeof(assoc_rsnxe);
|
||||
|
||||
@ -2351,27 +2351,19 @@ int wpa_set_bss(char *macddr, char * bssid, u8 pairwise_cipher, u8 group_cipher,
|
||||
sm->use_ext_key_id = (sm->proto == WPA_PROTO_WPA);
|
||||
pmksa_cache_clear_current(sm);
|
||||
|
||||
if (sm->key_mgmt == WPA_KEY_MGMT_SAE ||
|
||||
is_wpa2_enterprise_connection()) {
|
||||
if (!esp_wifi_skip_supp_pmkcaching() && use_pmk_cache) {
|
||||
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;
|
||||
|
||||
if (sm->pmksa) {
|
||||
entry = pmksa_cache_get(sm->pmksa, (const u8 *)bssid, NULL, NULL);
|
||||
}
|
||||
if (entry) {
|
||||
pmksa_cache_flush(sm->pmksa, NULL, entry->pmk, entry->pmk_len);
|
||||
}
|
||||
struct rsn_pmksa_cache_entry *pmksa = NULL;
|
||||
if (use_pmk_cache) {
|
||||
pmksa = pmksa_cache_get(sm->pmksa, (const u8 *)bssid, NULL, NULL);
|
||||
if (pmksa && (pmksa->akmp != sm->key_mgmt)) {
|
||||
use_pmk_cache = false;
|
||||
}
|
||||
}
|
||||
if (wpa_key_mgmt_supports_caching(sm->key_mgmt) && use_pmk_cache) {
|
||||
pmksa_cache_set_current(sm, NULL, (const u8*) bssid, 0, 0);
|
||||
wpa_sm_set_pmk_from_pmksa(sm);
|
||||
} else {
|
||||
if (pmksa) {
|
||||
pmksa_cache_flush(sm->pmksa, NULL, pmksa->pmk, pmksa->pmk_len);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user