From 4a667b01e6f537cc8976996ac774040d28d7b908 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 3 Dec 2019 18:27:52 +0200 Subject: [PATCH] tests: DPP bootstrapping via NFC URI record Signed-off-by: Jouni Malinen --- tests/hwsim/test_dpp.py | 18 ++++++++++++++++++ tests/hwsim/wpasupplicant.py | 13 +++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/hwsim/test_dpp.py b/tests/hwsim/test_dpp.py index c96aeee04..3ff9ef404 100644 --- a/tests/hwsim/test_dpp.py +++ b/tests/hwsim/test_dpp.py @@ -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]) diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 26315fc16..c9ebb250d 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -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