aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2017-07-03 09:56:29 (GMT)
committerJouni Malinen <j@w1.fi>2017-07-03 10:15:12 (GMT)
commit0651dfb76cffb80e216c4b8d62c657b26e67b634 (patch)
treeeebfc0394224583f7eeee9d01ea88bcf3ecb54dc /tests
parent6b140f0fa24494b77ca8987c2bf27c9509f82fa6 (diff)
downloadhostap-0651dfb76cffb80e216c4b8d62c657b26e67b634.zip
hostap-0651dfb76cffb80e216c4b8d62c657b26e67b634.tar.gz
hostap-0651dfb76cffb80e216c4b8d62c657b26e67b634.tar.bz2
tests: DPP configurator in hostapd
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/hwsim/test_dpp.py96
1 files changed, 96 insertions, 0 deletions
diff --git a/tests/hwsim/test_dpp.py b/tests/hwsim/test_dpp.py
index e2b51f2..3aa40cb 100644
--- a/tests/hwsim/test_dpp.py
+++ b/tests/hwsim/test_dpp.py
@@ -1464,3 +1464,99 @@ def test_dpp_pkex_hostapd_initiator(dev, apdev):
raise Exception("DPP configuration not completed (Enrollee)")
dev[0].request("DPP_STOP_LISTEN")
dev[0].dump_monitor()
+
+def test_dpp_hostapd_configurator(dev, apdev):
+ """DPP with hostapd as configurator/initiator"""
+ check_dpp_capab(dev[0])
+ hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured",
+ "channel": "1" })
+ check_dpp_capab(hapd)
+
+ cmd = "DPP_CONFIGURATOR_ADD"
+ res = hapd.request(cmd);
+ if "FAIL" in res:
+ raise Exception("Failed to add configurator")
+ conf_id = int(res)
+
+ addr = dev[0].own_addr().replace(':', '')
+ cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
+ res = dev[0].request(cmd)
+ if "FAIL" in res:
+ raise Exception("Failed to generate bootstrapping info")
+ id0 = int(res)
+ uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
+
+ res = hapd.request("DPP_QR_CODE " + uri0)
+ if "FAIL" in res:
+ raise Exception("Failed to parse QR Code URI")
+ id1 = int(res)
+
+ cmd = "DPP_LISTEN 2412"
+ if "OK" not in dev[0].request(cmd):
+ raise Exception("Failed to start listen operation")
+ cmd = "DPP_AUTH_INIT peer=%d configurator=%d conf=sta-dpp" % (id1, conf_id)
+ if "OK" not in hapd.request(cmd):
+ raise Exception("Failed to initiate DPP Authentication")
+
+ ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
+ if ev is None:
+ raise Exception("DPP authentication did not succeed (Responder)")
+ ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
+ if ev is None:
+ raise Exception("DPP authentication did not succeed (Initiator)")
+ ev = hapd.wait_event(["DPP-CONF-SENT"], timeout=5)
+ if ev is None:
+ raise Exception("DPP configuration not completed (Configurator)")
+ ev = dev[0].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
+ if ev is None:
+ raise Exception("DPP configuration not completed (Enrollee)")
+ dev[0].request("DPP_STOP_LISTEN")
+ dev[0].dump_monitor()
+
+def test_dpp_hostapd_configurator_responder(dev, apdev):
+ """DPP with hostapd as configurator/responder"""
+ check_dpp_capab(dev[0])
+ hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured",
+ "channel": "1" })
+ check_dpp_capab(hapd)
+
+ cmd = "DPP_CONFIGURATOR_ADD"
+ res = hapd.request(cmd);
+ if "FAIL" in res:
+ raise Exception("Failed to add configurator")
+ conf_id = int(res)
+
+ hapd.set("dpp_configurator_params",
+ " conf=sta-dpp configurator=%d" % conf_id);
+
+ addr = hapd.own_addr().replace(':', '')
+ cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
+ res = hapd.request(cmd)
+ if "FAIL" in res:
+ raise Exception("Failed to generate bootstrapping info")
+ id0 = int(res)
+ uri0 = hapd.request("DPP_BOOTSTRAP_GET_URI %d" % id0)
+
+ res = dev[0].request("DPP_QR_CODE " + uri0)
+ if "FAIL" in res:
+ raise Exception("Failed to parse QR Code URI")
+ id1 = int(res)
+
+ cmd = "DPP_AUTH_INIT peer=%d role=enrollee" % (id1)
+ if "OK" not in dev[0].request(cmd):
+ raise Exception("Failed to initiate DPP Authentication")
+
+ ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
+ if ev is None:
+ raise Exception("DPP authentication did not succeed (Responder)")
+ ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
+ if ev is None:
+ raise Exception("DPP authentication did not succeed (Initiator)")
+ ev = hapd.wait_event(["DPP-CONF-SENT"], timeout=5)
+ if ev is None:
+ raise Exception("DPP configuration not completed (Configurator)")
+ ev = dev[0].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
+ if ev is None:
+ raise Exception("DPP configuration not completed (Enrollee)")
+ dev[0].request("DPP_STOP_LISTEN")
+ dev[0].dump_monitor()