This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 9ede7d4650318d6d8c7af8bb6cac56994b53b17b
Author: Tiago Medicci Serrano <tiago.medi...@espressif.com>
AuthorDate: Thu Apr 27 11:07:07 2023 -0300

    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.
---
 arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c | 50 +++++++-------------------
 1 file changed, 12 insertions(+), 38 deletions(-)

diff --git a/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c 
b/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c
index dd0c3b6248..206504e7ae 100644
--- a/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c
+++ b/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c
@@ -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)
-        {
-          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;
-            }
+      if (ext->alg != IW_ENCODE_ALG_NONE)
+        {
+          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:

Reply via email to