]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P2: Make sure password is set when using non opportunistic methods
authorAndrei Otcheretianski <andrei.otcheretianski@intel.com>
Tue, 26 Nov 2024 09:10:12 +0000 (11:10 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 23 Dec 2024 11:09:15 +0000 (13:09 +0200)
Otherwise the flow would continue, eventually falling back to PASN
method instead of SAE even if not allowed in PBMA.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
wpa_supplicant/ctrl_iface.c

index 5b7e2f1b573cb019624412446888cc8d7f078686..a6036a729881f49055df40d33ced33428d108954 100644 (file)
@@ -6356,6 +6356,29 @@ static int p2p_ctrl_asp_provision(struct wpa_supplicant *wpa_s, char *cmd)
 }
 
 
+static bool bootstrap_pwd_required(u16 bootstrap)
+{
+       switch (bootstrap) {
+       case P2P_PBMA_OPPORTUNISTIC:
+               return false;
+       case P2P_PBMA_PIN_CODE_DISPLAY:
+       case P2P_PBMA_PASSPHRASE_DISPLAY:
+       case P2P_PBMA_QR_DISPLAY:
+       case P2P_PBMA_NFC_TAG:
+       case P2P_PBMA_PIN_CODE_KEYPAD:
+       case P2P_PBMA_PASSPHRASE_KEYPAD:
+       case P2P_PBMA_QR_SCAN:
+       case P2P_PBMA_NFC_READER:
+               return true;
+       case P2P_PBMA_SERVICE_MANAGED:
+       case P2P_PBMA_HANDSHAKE_SKIP:
+               return false;
+       }
+
+       return false;
+}
+
+
 static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd,
                            char *buf, size_t buflen)
 {
@@ -6518,6 +6541,12 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd,
                }
        }
 
+       if (bootstrap_pwd_required(bootstrap) && !password) {
+               wpa_printf(MSG_DEBUG,
+                          "CTRL_IFACE: This P2P2 bootstrap method requires password");
+               return -1;
+       }
+
        new_pin = wpas_p2p_connect(wpa_s, addr, pin, wps_method,
                                   persistent_group, automatic, join,
                                   auth, go_intent, freq, freq2, persistent_id,