esp32s3/wifi: add support to WPA3 on Station Mode

Add support to select WPA3-SAE while connecting to an AP. Please
note that STA mode sets a security threshold, i.e, it was able to
connect to a WPA3-SAE network prior to this change because it
connects to an equally or more secure network than the set
threshold. Considering this patch, the device is now able to
ignore WPA2-PSK APs when WPA3 is set.
This commit is contained in:
Tiago Medicci Serrano 2023-04-27 11:07:07 -03:00 committed by Xiang Xiao
parent a86a9dc09e
commit 9ede7d4650

View File

@ -4030,6 +4030,11 @@ static int esp_wifi_auth_trans(uint32_t wifi_auth)
auth_mode = IW_AUTH_WPA_VERSION_WPA2;
break;
case WIFI_AUTH_WPA3_PSK:
case WIFI_AUTH_WPA2_WPA3_PSK:
auth_mode = IW_AUTH_WPA_VERSION_WPA3;
break;
default:
wlerr("Failed to transfer wireless authmode: %d", wifi_auth);
break;
@ -5408,6 +5413,10 @@ int esp_wifi_sta_auth(struct iwreq *iwr, bool set)
wifi_cfg.sta.threshold.authmode = WIFI_AUTH_WPA2_PSK;
break;
case IW_AUTH_WPA_VERSION_WPA3:
wifi_cfg.sta.threshold.authmode = WIFI_AUTH_WPA3_PSK;
break;
default:
wlerr("Invalid wpa version %" PRId32 "\n",
iwr->u.param.value);
@ -5431,12 +5440,8 @@ int esp_wifi_sta_auth(struct iwreq *iwr, bool set)
break;
case IW_AUTH_CIPHER_TKIP:
wifi_cfg.sta.threshold.authmode = WIFI_AUTH_WPA_PSK;
break;
case IW_AUTH_CIPHER_CCMP:
case IW_AUTH_CIPHER_AES_CMAC:
wifi_cfg.sta.threshold.authmode = WIFI_AUTH_WPA2_PSK;
break;
default:
@ -6194,37 +6199,10 @@ int esp_wifi_softap_password(struct iwreq *iwr, bool set)
/* Clear the password field and copy the user password to it */
memset(wifi_cfg.ap.password, 0x0, PWD_MAX_LEN);
if (len)
if (ext->alg != IW_ENCODE_ALG_NONE)
{
memcpy(wifi_cfg.ap.password, pdata, len);
switch (ext->alg)
{
case IW_ENCODE_ALG_NONE:
wifi_cfg.ap.authmode = WIFI_AUTH_OPEN;
break;
case IW_ENCODE_ALG_WEP:
wifi_cfg.ap.authmode = WIFI_AUTH_WEP;
break;
case IW_ENCODE_ALG_TKIP:
wifi_cfg.ap.authmode = WIFI_AUTH_WPA_PSK;
break;
case IW_ENCODE_ALG_CCMP:
wifi_cfg.ap.authmode = WIFI_AUTH_WPA2_PSK;
break;
case IW_ENCODE_ALG_PMK:
case IW_ENCODE_ALG_AES_CMAC:
wifi_cfg.ap.authmode = WIFI_AUTH_WPA_WPA2_PSK;
break;
default:
wlerr("Failed to transfer wireless authmode: %d",
ext->alg);
return -EINVAL;
}
memcpy(wifi_cfg.sta.password, pdata, len);
}
if (g_softap_started)
@ -6505,12 +6483,8 @@ int esp_wifi_softap_auth(struct iwreq *iwr, bool set)
break;
case IW_AUTH_CIPHER_TKIP:
wifi_cfg.ap.authmode = WIFI_AUTH_WPA_PSK;
break;
case IW_AUTH_CIPHER_CCMP:
case IW_AUTH_CIPHER_AES_CMAC:
wifi_cfg.ap.authmode = WIFI_AUTH_WPA2_PSK;
break;
default: