Skip to content

Commit

Permalink
esp_wifi:BDSA related patch updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Shreyas0-7 committed Dec 18, 2022
1 parent e207c60 commit e566e0b
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 20 deletions.
31 changes: 21 additions & 10 deletions components/wpa_supplicant/esp_supplicant/src/esp_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include "rsn_supp/wpa_i.h"
#include "rsn_supp/wpa.h"

#if defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R)
struct wpa_supplicant g_wpa_supp;
#if defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R)

#ifdef CONFIG_SUPPLICANT_TASK
static void *s_supplicant_task_hdl = NULL;
Expand Down Expand Up @@ -276,26 +276,32 @@ static int handle_assoc_frame(u8 *frame, size_t len,
return 0;
}
#endif /* CONFIG_IEEE80211R */
#endif /* defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) */

static int ieee80211_handle_rx_frm(u8 type, u8 *frame, size_t len, u8 *sender,
u32 rssi, u8 channel, u64 current_tsf)
{
int ret = 0;

switch (type) {
#if defined(CONFIG_IEEE80211R) || defined(CONFIG_WPA_11KV_SUPPORT)
case WLAN_FC_STYPE_BEACON:
case WLAN_FC_STYPE_PROBE_RESP:
ret = esp_handle_beacon_probe(type, frame, len, sender, rssi, channel, current_tsf);
break;
#endif /* defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) */
#ifdef CONFIG_IEEE80211R
case WLAN_FC_STYPE_AUTH:
ret = handle_auth_frame(frame, len, sender, rssi, channel);
break;
#endif /* CONFIG_IEEE80211R */
case WLAN_FC_STYPE_ASSOC_RESP:
case WLAN_FC_STYPE_REASSOC_RESP:
wpa_sm_notify_assoc(&gWpaSm, sender);
#ifdef CONFIG_IEEE80211R
ret = handle_assoc_frame(frame, len, sender, rssi, channel);
break;
#endif /* CONFIG_IEEE80211R */
break;
#if defined(CONFIG_WPA_11KV_SUPPORT)
case WLAN_FC_STYPE_ACTION:
#ifdef CONFIG_SUPPLICANT_TASK
Expand All @@ -313,6 +319,7 @@ static int ieee80211_handle_rx_frm(u8 type, u8 *frame, size_t len, u8 *sender,
return ret;
}

#if defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R)
#ifdef CONFIG_MBO
bool mbo_bss_profile_match(u8 *bssid)
{
Expand All @@ -338,11 +345,14 @@ bool mbo_bss_profile_match(u8 *bssid)
}
#endif /* CONFIG_MBO */

#endif /* defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) */

int esp_supplicant_common_init(struct wpa_funcs *wpa_cb)
{
struct wpa_supplicant *wpa_s = &g_wpa_supp;
int ret = 0;

#if defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R)
#ifdef CONFIG_SUPPLICANT_TASK
s_supplicant_api_lock = os_recursive_mutex_create();
if (!s_supplicant_api_lock) {
Expand Down Expand Up @@ -376,19 +386,21 @@ int esp_supplicant_common_init(struct wpa_funcs *wpa_cb)
esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED,
&supplicant_sta_disconn_handler, NULL);

#endif /* defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) */
wpa_s->type = 0;
wpa_s->subtype = 0;
#ifdef CONFIG_IEEE80211R
wpa_s->type |= (1 << WLAN_FC_STYPE_ASSOC_RESP) | (1 << WLAN_FC_STYPE_REASSOC_RESP) | (1 << WLAN_FC_STYPE_AUTH);
#endif /* CONFIG_IEEE80211R */
if (esp_wifi_register_mgmt_frame_internal(wpa_s->type, wpa_s->subtype) != ESP_OK) {
ret = -1;
goto err;
}
wpa_cb->wpa_sta_rx_mgmt = ieee80211_handle_rx_frm;

#if defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R)
#ifdef CONFIG_MBO
dl_list_init(&wpa_s->bss_tmp_disallowed);
#endif /* CONFIG_MBO */
#endif /* defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) */
return 0;
err:
esp_supplicant_common_deinit();
Expand All @@ -399,6 +411,7 @@ void esp_supplicant_common_deinit(void)
{
struct wpa_supplicant *wpa_s = &g_wpa_supp;

#if defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R)
esp_scan_deinit(wpa_s);
#ifdef CONFIG_WPA_11KV_SUPPORT
wpas_rrm_reset(wpa_s);
Expand All @@ -408,10 +421,12 @@ void esp_supplicant_common_deinit(void)
&supplicant_sta_conn_handler);
esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED,
&supplicant_sta_disconn_handler);
#endif /* defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) */
if (wpa_s->type) {
wpa_s->type = 0;
esp_wifi_register_mgmt_frame_internal(wpa_s->type, wpa_s->subtype);
}
#if defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R)
#ifdef CONFIG_SUPPLICANT_TASK
if (!s_supplicant_task_hdl && esp_supplicant_post_evt(SIG_SUPPLICANT_DEL_TASK, 0) != 0) {
if (s_supplicant_evt_queue) {
Expand All @@ -424,8 +439,10 @@ void esp_supplicant_common_deinit(void)
}
}
#endif /* CONFIG_SUPPLICANT_TASK */
#endif /* defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) */
}

#if defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R)
#ifdef CONFIG_WPA_11KV_SUPPORT
bool esp_rrm_is_rrm_supported_connection(void)
{
Expand Down Expand Up @@ -817,12 +834,6 @@ int esp_mbo_update_non_pref_chan(struct non_pref_chan_s *non_pref_chan)
return -1;
}
void esp_set_scan_ie(void) { }
int esp_supplicant_common_init(struct wpa_funcs *wpa_cb)
{
wpa_cb->wpa_sta_rx_mgmt = NULL;
return 0;
}
void esp_supplicant_common_deinit(void) { }
#endif /* defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) */

#if defined(CONFIG_WPA_11KV_SUPPORT) || defined(CONFIG_IEEE80211R) || defined(CONFIG_WPA3_SAE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static void wpa_sta_disconnected_cb(uint8_t reason_code)
case WIFI_REASON_CONNECTION_FAIL:
case WIFI_REASON_HANDSHAKE_TIMEOUT:
esp_wpa3_free_sae_data();
wpa_sta_clear_curr_pmksa();
wpa_sm_notify_disassoc(&gWpaSm);
break;
default:
break;
Expand Down
24 changes: 21 additions & 3 deletions components/wpa_supplicant/src/ap/wpa_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,21 @@ SM_STATE(WPA_PTK, AUTHENTICATION2)
}


static int wpa_auth_sm_ptk_update(struct wpa_state_machine *sm)
{
if (random_get_bytes(sm->ANonce, WPA_NONCE_LEN)) {
wpa_printf(MSG_ERROR,
"WPA: Failed to get random data for ANonce");
sm->Disconnect = TRUE;
return -1;
}
wpa_hexdump(MSG_DEBUG, "WPA: Assign new ANonce", sm->ANonce,
WPA_NONCE_LEN);
sm->TimeoutCtr = 0;
return 0;
}


SM_STATE(WPA_PTK, INITPMK)
{
u8 msk[2 * PMK_LEN];
Expand Down Expand Up @@ -1837,9 +1852,12 @@ SM_STEP(WPA_PTK)
SM_ENTER(WPA_PTK, AUTHENTICATION);
else if (sm->ReAuthenticationRequest)
SM_ENTER(WPA_PTK, AUTHENTICATION2);
else if (sm->PTKRequest)
SM_ENTER(WPA_PTK, PTKSTART);
else switch (sm->wpa_ptk_state) {
else if (sm->PTKRequest) {
if (wpa_auth_sm_ptk_update(sm) < 0)
SM_ENTER(WPA_PTK, DISCONNECTED);
else
SM_ENTER(WPA_PTK, PTKSTART);
} else switch (sm->wpa_ptk_state) {
case WPA_PTK_INITIALIZE:
break;
case WPA_PTK_DISCONNECT:
Expand Down
13 changes: 13 additions & 0 deletions components/wpa_supplicant/src/common/wpa_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,21 @@ struct wpa_ptk {
size_t kck_len;
size_t kek_len;
size_t tk_len;
int installed; /* 1 if key has already been installed to driver */
};

struct wpa_gtk {
u8 gtk[WPA_GTK_MAX_LEN];
size_t gtk_len;
};

#ifdef CONFIG_IEEE80211W
struct wpa_igtk {
u8 igtk[WPA_IGTK_MAX_LEN];
size_t igtk_len;
};
#endif /* CONFIG_IEEE80211W */

struct wpa_gtk_data {
enum wpa_alg alg;
int tx, key_rsc_len, keyidx;
Expand Down
Loading

0 comments on commit e566e0b

Please sign in to comment.