Skip to content

Commit 28361a2

Browse files
tmediccixiaoxiang781216
authored andcommitted
esp32/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.
1 parent 6e76229 commit 28361a2

File tree

1 file changed

+12
-39
lines changed

1 file changed

+12
-39
lines changed

arch/xtensa/src/esp32/esp32_wifi_adapter.c

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4177,6 +4177,11 @@ static int esp_wifi_auth_trans(uint32_t wifi_auth)
41774177
auth_mode = IW_AUTH_WPA_VERSION_WPA2;
41784178
break;
41794179

4180+
case WIFI_AUTH_WPA3_PSK:
4181+
case WIFI_AUTH_WPA2_WPA3_PSK:
4182+
auth_mode = IW_AUTH_WPA_VERSION_WPA3;
4183+
break;
4184+
41804185
default:
41814186
wlerr("Failed to transfer wireless authmode: %d", wifi_auth);
41824187
break;
@@ -5576,6 +5581,10 @@ int esp_wifi_sta_auth(struct iwreq *iwr, bool set)
55765581
wifi_cfg.sta.threshold.authmode = WIFI_AUTH_WPA2_PSK;
55775582
break;
55785583

5584+
case IW_AUTH_WPA_VERSION_WPA3:
5585+
wifi_cfg.sta.threshold.authmode = WIFI_AUTH_WPA3_PSK;
5586+
break;
5587+
55795588
default:
55805589
wlerr("Invalid wpa version %" PRId32 "\n",
55815590
iwr->u.param.value);
@@ -5599,12 +5608,8 @@ int esp_wifi_sta_auth(struct iwreq *iwr, bool set)
55995608
break;
56005609

56015610
case IW_AUTH_CIPHER_TKIP:
5602-
wifi_cfg.sta.threshold.authmode = WIFI_AUTH_WPA_PSK;
5603-
break;
5604-
56055611
case IW_AUTH_CIPHER_CCMP:
56065612
case IW_AUTH_CIPHER_AES_CMAC:
5607-
wifi_cfg.sta.threshold.authmode = WIFI_AUTH_WPA2_PSK;
56085613
break;
56095614

56105615
default:
@@ -6362,40 +6367,12 @@ int esp_wifi_softap_password(struct iwreq *iwr, bool set)
63626367
/* Clear the password field and copy the user password to it */
63636368

63646369
memset(wifi_cfg.ap.password, 0x0, PWD_MAX_LEN);
6365-
if (len)
6370+
if (ext->alg != IW_ENCODE_ALG_NONE)
63666371
{
6367-
memcpy(wifi_cfg.ap.password, pdata, len);
6368-
switch (ext->alg)
6369-
{
6370-
case IW_ENCODE_ALG_NONE:
6371-
wifi_cfg.ap.authmode = WIFI_AUTH_OPEN;
6372-
break;
6373-
6374-
case IW_ENCODE_ALG_WEP:
6375-
wifi_cfg.ap.authmode = WIFI_AUTH_WEP;
6376-
break;
6377-
6378-
case IW_ENCODE_ALG_TKIP:
6379-
wifi_cfg.ap.authmode = WIFI_AUTH_WPA_PSK;
6380-
break;
6381-
6382-
case IW_ENCODE_ALG_CCMP:
6383-
wifi_cfg.ap.authmode = WIFI_AUTH_WPA2_PSK;
6384-
break;
6385-
6386-
case IW_ENCODE_ALG_PMK:
6387-
case IW_ENCODE_ALG_AES_CMAC:
6388-
wifi_cfg.ap.authmode = WIFI_AUTH_WPA_WPA2_PSK;
6389-
break;
6390-
6391-
default:
6392-
wlerr("Failed to transfer wireless authmode: %d",
6393-
ext->alg);
6394-
return -EINVAL;
6395-
}
6372+
memcpy(wifi_cfg.sta.password, pdata, len);
63966373
}
63976374

6398-
if (g_softap_started)
6375+
if (g_softap_started)
63996376
{
64006377
ret = esp_wifi_set_config(WIFI_IF_AP, &wifi_cfg);
64016378
if (ret)
@@ -6674,12 +6651,8 @@ int esp_wifi_softap_auth(struct iwreq *iwr, bool set)
66746651
break;
66756652

66766653
case IW_AUTH_CIPHER_TKIP:
6677-
wifi_cfg.ap.authmode = WIFI_AUTH_WPA_PSK;
6678-
break;
6679-
66806654
case IW_AUTH_CIPHER_CCMP:
66816655
case IW_AUTH_CIPHER_AES_CMAC:
6682-
wifi_cfg.ap.authmode = WIFI_AUTH_WPA2_PSK;
66836656
break;
66846657

66856658
default:

0 commit comments

Comments
 (0)