diff --git a/tests/hwsim/test_dpp.py b/tests/hwsim/test_dpp.py index 616ef65d4..fee8180a4 100644 --- a/tests/hwsim/test_dpp.py +++ b/tests/hwsim/test_dpp.py @@ -1527,6 +1527,42 @@ def run_dpp_pkex(dev, apdev, curve=None, init_extra="", check_config=False): if ev is None: raise Exception("DPP configuration not completed (Enrollee)") +def test_dpp_pkex_code_mismatch(dev, apdev): + """DPP and PKEX with mismatching code""" + check_dpp_capab(dev[0]) + check_dpp_capab(dev[1]) + + cmd = "DPP_BOOTSTRAP_GEN type=pkex" + res = dev[0].request(cmd) + if "FAIL" in res: + raise Exception("Failed to generate bootstrapping info") + id0 = int(res) + + cmd = "DPP_BOOTSTRAP_GEN type=pkex" + res = dev[1].request(cmd) + if "FAIL" in res: + raise Exception("Failed to generate bootstrapping info") + id1 = int(res) + + cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id0) + res = dev[0].request(cmd) + if "FAIL" in res: + raise Exception("Failed to set PKEX data (responder)") + cmd = "DPP_LISTEN 2437" + if "OK" not in dev[0].request(cmd): + raise Exception("Failed to start listen operation") + + cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 code=unknown" % id1 + res = dev[1].request(cmd) + if "FAIL" in res: + raise Exception("Failed to set PKEX data (initiator)") + + ev = dev[0].wait_event(["DPP-FAIL"], timeout=5) + if ev is None: + raise Exception("Failure not reported") + if "possible PKEX code mismatch" not in ev: + raise Exception("Unexpected result: " + ev) + def test_dpp_pkex_config2(dev, apdev): """DPP and PKEX with responder as the configurator""" check_dpp_capab(dev[0])