tests: DPP bootstrapping via NFC URI record (hostapd reading tag)

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2021-03-21 16:39:46 +02:00
parent c4b2d6f566
commit 9c809b2aaa
2 changed files with 29 additions and 2 deletions

View file

@ -419,6 +419,12 @@ class Hostapd:
raise Exception("Failed to parse QR Code URI") raise Exception("Failed to parse QR Code URI")
return int(res) 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, def dpp_bootstrap_gen(self, type="qrcode", chan=None, mac=None, info=None,
curve=None, key=None): curve=None, key=None):
cmd = "DPP_BOOTSTRAP_GEN type=" + type cmd = "DPP_BOOTSTRAP_GEN type=" + type
@ -467,9 +473,12 @@ class Hostapd:
def dpp_auth_init(self, peer=None, uri=None, conf=None, configurator=None, def dpp_auth_init(self, peer=None, uri=None, conf=None, configurator=None,
extra=None, own=None, role=None, neg_freq=None, extra=None, own=None, role=None, neg_freq=None,
ssid=None, passphrase=None, expect_fail=False, ssid=None, passphrase=None, expect_fail=False,
conn_status=False): conn_status=False, nfc_uri=None):
cmd = "DPP_AUTH_INIT" cmd = "DPP_AUTH_INIT"
if peer is None: if peer is None:
if nfc_uri:
peer = self.dpp_nfc_uri(nfc_uri)
else:
peer = self.dpp_qr_code(uri) peer = self.dpp_qr_code(uri)
cmd += " peer=%d" % peer cmd += " peer=%d" % peer
if own is not None: if own is not None:

View 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") 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) 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): def test_dpp_nfc_negotiated_handover(dev, apdev):
"""DPP bootstrapping via NFC negotiated handover""" """DPP bootstrapping via NFC negotiated handover"""
run_dpp_nfc_negotiated_handover(dev) run_dpp_nfc_negotiated_handover(dev)