浏览代码

wpa_supplicant: Get WPS credential in passphrase format

Closes https://github.com/espressif/esp-idf/issues/10339
Kapil Gupta 3 年之前
父节点
当前提交
5186b018c0
共有 2 个文件被更改,包括 30 次插入10 次删除
  1. 23 8
      components/esp_wifi/Kconfig
  2. 7 2
      components/wpa_supplicant/esp_supplicant/src/esp_wps.c

+ 23 - 8
components/esp_wifi/Kconfig

@@ -455,14 +455,6 @@ menu "Wi-Fi"
             Select this option to enable 192 bit NSA suite-B.
             This is necessary to support WPA3 192 bit security.
 
-    config ESP_WIFI_WPS_STRICT
-        bool "Strictly validate all WPS attributes"
-        default n
-        help
-            Select this option to enable validate each WPS attribute
-            rigorously. Disabling this add the workaorunds with various APs.
-            Enabling this may cause inter operability issues with some APs.
-
     config ESP_WIFI_11KV_SUPPORT
         bool "Enable 802.11k, 802.11v APIs Support"
         default n
@@ -530,6 +522,29 @@ menu "Wi-Fi"
         help
             Enable Wi-Fi DL MU-MIMO and DL OFDMA reception statistics. Will use 10932 bytes memory.
 
+    menu "WPS Configuration Options"
+        config ESP_WIFI_WPS_STRICT
+            bool "Strictly validate all WPS attributes"
+            default n
+            help
+                Select this option to enable validate each WPS attribute
+                rigorously. Disabling this add the workaorunds with various APs.
+                Enabling this may cause inter operability issues with some APs.
+
+        config ESP_WIFI_WPS_PASSPHRASE
+            bool "Get WPA2 passphrase in WPS config"
+            default n
+            help
+                Select this option to get passphrase during WPS configuration.
+                This option fakes the virtual display capabilites to get the
+                configuration in passphrase mode.
+                Not recommanded to be used since WPS credentials should not
+                be shared to other devices, making it in readable format increases
+                that risk, also passphrase requires pbkdf2 to convert in psk.
+
+    endmenu # "WPS Configuration Options"
+
+
     config ESP_WIFI_DEBUG_PRINT
         bool "Print debug messages from WPA Supplicant"
         default n

+ 7 - 2
components/wpa_supplicant/esp_supplicant/src/esp_wps.c

@@ -792,11 +792,12 @@ int wps_finish(void)
                 return ESP_FAIL;
             }
 
+            esp_wifi_get_config(WIFI_IF_STA, config);
             os_memcpy(config->sta.ssid, sm->ssid[0], sm->ssid_len[0]);
             os_memcpy(config->sta.password, sm->key[0], sm->key_len[0]);
             os_memcpy(config->sta.bssid, sm->bssid, ETH_ALEN);
             config->sta.bssid_set = 0;
-            esp_wifi_set_config(0, config);
+            esp_wifi_set_config(WIFI_IF_STA, config);
 
             os_free(config);
         }
@@ -1126,7 +1127,10 @@ int wps_dev_init(void)
         ret = ESP_FAIL;
         goto _out;
     }
-    dev->config_methods = WPS_CONFIG_VIRT_PUSHBUTTON | WPS_CONFIG_PHY_DISPLAY;
+    dev->config_methods = WPS_CONFIG_VIRT_PUSHBUTTON;
+#ifdef CONFIG_ESP_WIFI_WPS_PASSPHRASE
+    dev->config_methods |= WPS_CONFIG_DISPLAY | WPS_CONFIG_VIRT_DISPLAY;
+#endif
     dev->rf_bands = WPS_RF_24GHZ;
 
     WPA_PUT_BE16(dev->pri_dev_type, WPS_DEV_PHONE);
@@ -1408,6 +1412,7 @@ static int wifi_station_wps_init(const esp_wps_config_t *config)
     }
 
     os_memcpy(cfg.wps->uuid, sm->uuid, WPS_UUID_LEN);
+    cfg.wps->config_methods = sm->wps_ctx->dev.config_methods;
     if ((sm->wps = wps_init(&cfg)) == NULL) {         /* alloc wps_data */
         goto _err;
     }