]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP: Allow raw hex PSK to be used for legacy configuration
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 15 Sep 2017 14:54:31 +0000 (17:54 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 15 Sep 2017 14:54:31 +0000 (17:54 +0300)
The new psk=<hexdump> can be used as an alternative to pass=<passphrase>
when configuring the DPP Configurator with a legacy network parameters.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/ap/dpp_hostapd.c
wpa_supplicant/dpp_supplicant.c

index 8b6a630c41c82cd45d66336344fceb32652edce2..c73c56cc4e5d3ab061495474c342fbcc1214c1ca 100644 (file)
@@ -337,6 +337,8 @@ static void hostapd_dpp_set_configurator(struct hostapd_data *hapd,
        size_t ssid_len = 4;
        char pass[64] = { };
        size_t pass_len = 0;
+       u8 psk[PMK_LEN];
+       int psk_set = 0;
 
        if (!cmd)
                return;
@@ -364,6 +366,14 @@ static void hostapd_dpp_set_configurator(struct hostapd_data *hapd,
                        goto fail;
        }
 
+       pos = os_strstr(cmd, " psk=");
+       if (pos) {
+               pos += 5;
+               if (hexstr2bin(pos, psk, PMK_LEN) < 0)
+                       goto fail;
+               psk_set = 1;
+       }
+
        if (os_strstr(cmd, " conf=sta-")) {
                conf_sta = os_zalloc(sizeof(struct dpp_configuration));
                if (!conf_sta)
@@ -372,9 +382,13 @@ static void hostapd_dpp_set_configurator(struct hostapd_data *hapd,
                conf_sta->ssid_len = ssid_len;
                if (os_strstr(cmd, " conf=sta-psk")) {
                        conf_sta->dpp = 0;
-                       conf_sta->passphrase = os_strdup(pass);
-                       if (!conf_sta->passphrase)
-                               goto fail;
+                       if (psk_set) {
+                               os_memcpy(conf_sta->psk, psk, PMK_LEN);
+                       } else {
+                               conf_sta->passphrase = os_strdup(pass);
+                               if (!conf_sta->passphrase)
+                                       goto fail;
+                       }
                } else if (os_strstr(cmd, " conf=sta-dpp")) {
                        conf_sta->dpp = 1;
                } else {
@@ -390,9 +404,13 @@ static void hostapd_dpp_set_configurator(struct hostapd_data *hapd,
                conf_ap->ssid_len = ssid_len;
                if (os_strstr(cmd, " conf=ap-psk")) {
                        conf_ap->dpp = 0;
-                       conf_ap->passphrase = os_strdup(pass);
-                       if (!conf_ap->passphrase)
-                               goto fail;
+                       if (psk_set) {
+                               os_memcpy(conf_ap->psk, psk, PMK_LEN);
+                       } else {
+                               conf_ap->passphrase = os_strdup(pass);
+                               if (!conf_ap->passphrase)
+                                       goto fail;
+                       }
                } else if (os_strstr(cmd, " conf=ap-dpp")) {
                        conf_ap->dpp = 1;
                } else {
index f5d1409c3ed57d1f3fbd96a660d3744929b1692c..44178f971bdbc2838caa6583a47e7fd0724cd238 100644 (file)
@@ -387,6 +387,8 @@ static void wpas_dpp_set_configurator(struct wpa_supplicant *wpa_s,
        size_t ssid_len = 4;
        char pass[64] = { };
        size_t pass_len = 0;
+       u8 psk[PMK_LEN];
+       int psk_set = 0;
 
        if (!cmd)
                return;
@@ -414,6 +416,14 @@ static void wpas_dpp_set_configurator(struct wpa_supplicant *wpa_s,
                        goto fail;
        }
 
+       pos = os_strstr(cmd, " psk=");
+       if (pos) {
+               pos += 5;
+               if (hexstr2bin(pos, psk, PMK_LEN) < 0)
+                       goto fail;
+               psk_set = 1;
+       }
+
        if (os_strstr(cmd, " conf=sta-")) {
                conf_sta = os_zalloc(sizeof(struct dpp_configuration));
                if (!conf_sta)
@@ -422,9 +432,13 @@ static void wpas_dpp_set_configurator(struct wpa_supplicant *wpa_s,
                conf_sta->ssid_len = ssid_len;
                if (os_strstr(cmd, " conf=sta-psk")) {
                        conf_sta->dpp = 0;
-                       conf_sta->passphrase = os_strdup(pass);
-                       if (!conf_sta->passphrase)
-                               goto fail;
+                       if (psk_set) {
+                               os_memcpy(conf_sta->psk, psk, PMK_LEN);
+                       } else {
+                               conf_sta->passphrase = os_strdup(pass);
+                               if (!conf_sta->passphrase)
+                                       goto fail;
+                       }
                } else if (os_strstr(cmd, " conf=sta-dpp")) {
                        conf_sta->dpp = 1;
                } else {
@@ -440,9 +454,13 @@ static void wpas_dpp_set_configurator(struct wpa_supplicant *wpa_s,
                conf_ap->ssid_len = ssid_len;
                if (os_strstr(cmd, " conf=ap-psk")) {
                        conf_ap->dpp = 0;
-                       conf_ap->passphrase = os_strdup(pass);
-                       if (!conf_ap->passphrase)
-                               goto fail;
+                       if (psk_set) {
+                               os_memcpy(conf_ap->psk, psk, PMK_LEN);
+                       } else {
+                               conf_ap->passphrase = os_strdup(pass);
+                               if (!conf_ap->passphrase)
+                                       goto fail;
+                       }
                } else if (os_strstr(cmd, " conf=ap-dpp")) {
                        conf_ap->dpp = 1;
                } else {