]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: DPP bootstrapping via NFC URI record
authorJouni Malinen <jouni@codeaurora.org>
Tue, 3 Dec 2019 16:27:52 +0000 (18:27 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 5 Dec 2019 10:37:51 +0000 (12:37 +0200)
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
tests/hwsim/test_dpp.py
tests/hwsim/wpasupplicant.py

index c96aeee048e5da9b99e68353934c1bf9d421d63f..3ff9ef404f187f7ba91db04a62517152fb01eee1 100644 (file)
@@ -4853,3 +4853,21 @@ def run_dpp_config_save(dev, apdev, config, conf_ssid, exp_ssid):
             raise Exception("SSID not saved")
         if 'psk="secret passphrase"' not in data:
             raise Exception("Passphtase not saved")
+
+def test_dpp_nfc_uri(dev, apdev):
+    """DPP bootstrapping via NFC URI record"""
+    check_dpp_capab(dev[0])
+    check_dpp_capab(dev[1])
+
+    id = dev[0].dpp_bootstrap_gen(type="nfc-uri", chan="81/1", mac=True)
+    uri = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id)
+    logger.info("Generated URI: " + uri)
+    info = dev[0].request("DPP_BOOTSTRAP_INFO %d" % id)
+    logger.info("Bootstrapping info:\n" + info)
+    if "type=NFC-URI" not in info:
+        raise Exception("Unexpected bootstrapping info contents")
+
+    dev[0].dpp_listen(2412)
+    conf_id = dev[1].dpp_configurator_add()
+    dev[1].dpp_auth_init(nfc_uri=uri, configurator=conf_id, conf="sta-dpp")
+    wait_auth_success(dev[0], dev[1], configurator=dev[1], enrollee=dev[0])
index 26315fc164e105d56b063c7bae25b55fdd18ee79..c9ebb250d2a24af117e53f8d2495424e4471bacc 100644 (file)
@@ -1424,6 +1424,12 @@ class WpaSupplicant:
             raise Exception("Failed to parse QR Code URI")
         return int(res)
 
+    def dpp_nfc_uri(self, uri):
+        res = self.request("DPP_NFC_URI " + uri)
+        if "FAIL" in res:
+            raise Exception("Failed to parse NFC URI")
+        return int(res)
+
     def dpp_bootstrap_gen(self, type="qrcode", chan=None, mac=None, info=None,
                           curve=None, key=None):
         cmd = "DPP_BOOTSTRAP_GEN type=" + type
@@ -1459,10 +1465,13 @@ class WpaSupplicant:
                       extra=None, own=None, role=None, neg_freq=None,
                       ssid=None, passphrase=None, expect_fail=False,
                       tcp_addr=None, tcp_port=None, conn_status=False,
-                      ssid_charset=None):
+                      ssid_charset=None, nfc_uri=None):
         cmd = "DPP_AUTH_INIT"
         if peer is None:
-            peer = self.dpp_qr_code(uri)
+            if nfc_uri:
+                peer = self.dpp_nfc_uri(nfc_uri)
+            else:
+                peer = self.dpp_qr_code(uri)
         cmd += " peer=%d" % peer
         if own is not None:
             cmd += " own=%d" % own