]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: DPP bootstrapping via NFC URI record (hostapd reading tag)
authorJouni Malinen <j@w1.fi>
Sun, 21 Mar 2021 14:39:46 +0000 (16:39 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 21 Mar 2021 14:39:46 +0000 (16:39 +0200)
Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/hostapd.py
tests/hwsim/test_dpp.py

index b20d52e9bfdff4b2943f4a535a4fe7c95313127c..5ea68444c1b96a77c9f13f565147fa05b7a3c014 100644 (file)
@@ -419,6 +419,12 @@ class Hostapd:
             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
@@ -467,10 +473,13 @@ class Hostapd:
     def dpp_auth_init(self, peer=None, uri=None, conf=None, configurator=None,
                       extra=None, own=None, role=None, neg_freq=None,
                       ssid=None, passphrase=None, expect_fail=False,
-                      conn_status=False):
+                      conn_status=False, 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
index b19e3a32807c8af6398fb2fe340c5fbe2554f685..826307020d41286bc7d2134c3548250058319d4a 100644 (file)
@@ -5793,6 +5793,24 @@ def test_dpp_nfc_uri_hostapd(dev, apdev):
     dev[0].dpp_auth_init(nfc_uri=uri, configurator=conf_id, conf="ap-dpp")
     wait_auth_success(hapd, dev[0], configurator=dev[0], enrollee=hapd)
 
+def test_dpp_nfc_uri_hostapd_tag_read(dev, apdev):
+    """DPP bootstrapping via NFC URI record (hostapd reading tag)"""
+    check_dpp_capab(dev[0])
+
+    hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured"})
+    check_dpp_capab(hapd)
+
+    id = dev[0].dpp_bootstrap_gen(type="nfc-uri", chan="81/1", mac=True)
+    uri = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id)
+    info = dev[0].request("DPP_BOOTSTRAP_INFO %d" % id)
+    conf_id = dev[0].dpp_configurator_add()
+    dev[0].set("dpp_configurator_params",
+               "conf=ap-dpp configurator=%d" % conf_id)
+    dev[0].dpp_listen(2412)
+
+    hapd.dpp_auth_init(nfc_uri=uri, role="enrollee")
+    wait_auth_success(dev[0], hapd, configurator=dev[0], enrollee=hapd)
+
 def test_dpp_nfc_negotiated_handover(dev, apdev):
     """DPP bootstrapping via NFC negotiated handover"""
     run_dpp_nfc_negotiated_handover(dev)