res = dev[1].dpp_qr_code(uri)
if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d" % res):
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 = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- ev = dev[0].wait_event(["DPP-CONF-FAILED"], timeout=2)
- if ev is None:
- raise Exception("DPP configuration result not seen (Enrollee)")
- ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=2)
- if ev is None:
- raise Exception("DPP configuration result not seen (Responder)")
- dev[0].request("DPP_STOP_LISTEN")
- dev[1].request("DPP_STOP_LISTEN")
- dev[0].dump_monitor()
- dev[1].dump_monitor()
+ wait_auth_success(dev[0], dev[1], configurator=dev[1], enrollee=dev[0],
+ allow_enrollee_failure=True, stop_responder=True,
+ stop_initiator=True)
def test_dpp_qr_code_auth_broadcast(dev, apdev):
"""DPP QR Code and authentication exchange (broadcast)"""
dev[0].dpp_listen(2412)
if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d" % id1):
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 = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- dev[0].request("DPP_STOP_LISTEN")
+ wait_auth_success(dev[0], dev[1], stop_responder=True)
def test_dpp_qr_code_auth_unicast(dev, apdev):
"""DPP QR Code and authentication exchange (unicast)"""
cmd += " configurator=%d" % conf_id
if "OK" not in dev[1].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 = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- ev = dev[1].wait_event(["DPP-CONF-SENT", "DPP-CONF-FAILED"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Configurator)")
- if "DPP-CONF-FAILED" in ev and not require_conf_failure:
- raise Exception("Unexpected failure on Configurator")
- ev = dev[0].wait_event(["DPP-CONF-RECEIVED", "DPP-CONF-FAILED"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Enrollee)")
- if require_conf_success:
- if "DPP-CONF-FAILED" in ev:
- raise Exception("DPP configuration failed")
- if require_conf_failure:
- if "DPP-CONF-SUCCESS" in ev:
- raise Exception("DPP configuration succeeded unexpectedly")
- dev[0].request("DPP_STOP_LISTEN")
- dev[0].dump_monitor()
+ wait_auth_success(dev[0], dev[1], configurator=dev[1], enrollee=dev[0],
+ allow_enrollee_failure=True,
+ allow_configurator_failure=not require_conf_success,
+ require_configurator_failure=require_conf_failure,
+ stop_responder=True)
dev[1].dump_monitor()
def test_dpp_qr_code_auth_mutual(dev, apdev):
if "mutual=1" not in ev:
raise Exception("Mutual authentication not used")
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- dev[0].request("DPP_STOP_LISTEN")
+ wait_auth_success(dev[0], dev[1], stop_responder=True)
def test_dpp_qr_code_auth_mutual2(dev, apdev):
"""DPP QR Code and authentication exchange (mutual2)"""
if "mutual=1" not in ev:
raise Exception("Mutual authentication not used")
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- dev[0].request("DPP_STOP_LISTEN")
+ wait_auth_success(dev[0], dev[1], stop_responder=True)
def test_dpp_qr_code_auth_mutual_p_256(dev, apdev):
"""DPP QR Code and authentication exchange (mutual, autogen P-256)"""
if "mutual=1" not in ev:
raise Exception("Mutual authentication not used")
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- dev[0].request("DPP_STOP_LISTEN")
+ wait_auth_success(dev[0], dev[1], stop_responder=True)
def test_dpp_auth_resp_retries(dev, apdev):
"""DPP Authentication Response retries"""
if "mutual=0" not in ev:
raise Exception("Mutual authentication not used")
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- dev[0].request("DPP_STOP_LISTEN")
+ wait_auth_success(dev[0], dev[1], stop_responder=True)
def test_dpp_qr_code_auth_mutual_curve_mismatch(dev, apdev):
"""DPP QR Code and authentication exchange (mutual/mismatch)"""
logger.info("AP scans QR Code")
hapd.dpp_qr_code(uri0)
- 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)")
- hapd.request("DPP_STOP_LISTEN")
+ wait_auth_success(hapd, dev[0], stop_responder=True)
def test_dpp_qr_code_listen_continue(dev, apdev):
"""DPP QR Code and listen operation needing continuation"""
logger.info("dev1 initiates DPP Authentication")
if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d" % id1):
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 = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- dev[0].request("DPP_STOP_LISTEN")
+ wait_auth_success(dev[0], dev[1], stop_responder=True)
def test_dpp_qr_code_auth_initiator_enrollee(dev, apdev):
"""DPP QR Code and authentication exchange (Initiator in Enrollee role)"""
dev[0].dpp_listen(2412)
if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d role=enrollee" % id1):
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 = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
-
- ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration did not succeed (Configurator)")
- ev = dev[1].wait_event(["DPP-CONF-FAILED"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration did not succeed (Enrollee)")
-
- dev[0].request("DPP_STOP_LISTEN")
+ wait_auth_success(dev[0], dev[1], configurator=dev[0], enrollee=dev[1],
+ allow_enrollee_failure=True, stop_responder=True)
def test_dpp_qr_code_auth_initiator_either_1(dev, apdev):
"""DPP QR Code and authentication exchange (Initiator in either role)"""
dev[0].dpp_listen(2412, role=resp_role)
if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d role=either" % id1):
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 = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
-
- ev = conf_dev.wait_event(["DPP-CONF-SENT"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration did not succeed (Configurator)")
- ev = enrollee_dev.wait_event(["DPP-CONF-FAILED"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration did not succeed (Enrollee)")
-
- dev[0].request("DPP_STOP_LISTEN")
+ wait_auth_success(dev[0], dev[1], configurator=conf_dev,
+ enrollee=enrollee_dev, allow_enrollee_failure=True,
+ stop_responder=True)
def run_init_incompatible_roles(dev, role="enrollee"):
check_dpp_capab(dev[0])
if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d role=configurator" % id1):
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 = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- dev[0].request("DPP_STOP_LISTEN")
+ wait_auth_success(dev[0], dev[1], stop_responder=True)
def test_dpp_qr_code_auth_incompatible_roles2(dev, apdev):
"""DPP QR Code and authentication exchange (incompatible roles 2)"""
if "freq=2462 result=SUCCESS" not in ev:
raise Exception("Unexpected TX status for Authentication Confirm: " + ev)
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- ev = dev[1].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", "DPP-CONF-FAILED"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Enrollee)")
- if "DPP-CONF-FAILED" in ev:
- raise Exception("DPP configuration failed")
- dev[0].request("DPP_STOP_LISTEN")
- dev[0].dump_monitor()
+ wait_auth_success(dev[0], dev[1], configurator=dev[1], enrollee=dev[0],
+ stop_responder=True)
dev[1].dump_monitor()
def test_dpp_config_legacy(dev, apdev):
msg['freq'], msg['datarate'], msg['ssi_signal'], binascii.hexlify(msg['frame']).decode())):
raise Exception("MGMT_RX_PROCESS failed")
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
+ wait_auth_success(dev[0], dev[1])
# DPP Configuration Response (GAS Initial Response frame)
msg = dev[0].mgmt_rx()
cmd = "DPP_AUTH_INIT peer=%d conf=ap-dpp configurator=%d" % (id, conf_id)
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 = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Configurator)")
- ev = hapd.wait_event(["DPP-CONF-RECEIVED", "DPP-CONF-FAILED"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Enrollee)")
- if "DPP-CONF-FAILED" in ev:
- raise Exception("DPP configuration failed")
-
+ wait_auth_success(hapd, dev[0], configurator=dev[0], enrollee=hapd)
update_hapd_config(hapd)
id1 = dev[1].dpp_bootstrap_gen(chan="81/1", mac=True, curve=curve)
cmd = "DPP_AUTH_INIT peer=%d conf=sta-dpp configurator=%d" % (id0b, conf_id)
if "OK" not in dev[0].request(cmd):
raise Exception("Failed to initiate DPP Authentication")
- ev = dev[1].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 = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Configurator)")
- ev = dev[1].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Enrollee)")
- dev[1].request("DPP_STOP_LISTEN")
+ wait_auth_success(dev[1], dev[0], configurator=dev[0], enrollee=dev[1],
+ stop_responder=True)
ev = dev[1].wait_event(["DPP-CONFOBJ-SSID"], timeout=1)
if ev is None:
cmd = "DPP_AUTH_INIT peer=%d role=enrollee" % id1
if "OK" not in dev[1].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 = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Configurator)")
- ev = dev[1].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()
+ wait_auth_success(dev[0], dev[1], configurator=dev[0], enrollee=dev[1],
+ stop_responder=True)
dev[1].dump_monitor()
def test_dpp_qr_code_hostapd_init(dev, apdev):
cmd = "DPP_AUTH_INIT peer=%d role=enrollee" % id1
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 = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Configurator)")
- ev = hapd.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()
+ wait_auth_success(dev[0], hapd, configurator=dev[0], enrollee=hapd,
+ stop_responder=True)
def test_dpp_qr_code_hostapd_init_offchannel(dev, apdev):
"""DPP QR Code and hostapd as initiator (offchannel)"""
cmd += " " + extra
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 = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Configurator)")
- ev = hapd.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()
+ wait_auth_success(dev[0], hapd, configurator=dev[0], enrollee=hapd,
+ stop_responder=True)
def test_dpp_test_vector_p_256(dev, apdev):
"""DPP P-256 test vector (mutual auth)"""
cmd = "DPP_AUTH_INIT peer=%d own=%d neg_freq=2412" % (id1peer, id1)
if "OK" not in dev[1].request(cmd):
raise Exception("Failed to initiate operation")
-
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
+ wait_auth_success(dev[0], dev[1])
def test_dpp_test_vector_p_256_b(dev, apdev):
"""DPP P-256 test vector (Responder-only auth)"""
cmd = "DPP_AUTH_INIT peer=%d own=%d neg_freq=2412" % (id1peer, id1)
if "OK" not in dev[1].request(cmd):
raise Exception("Failed to initiate operation")
-
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
+ wait_auth_success(dev[0], dev[1])
def der_priv_key_p_521(priv):
if len(priv) != 2 * 66:
cmd = "DPP_AUTH_INIT peer=%d own=%d neg_freq=2412" % (id1peer, id1)
if "OK" not in dev[1].request(cmd):
raise Exception("Failed to initiate operation")
-
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
+ wait_auth_success(dev[0], dev[1])
def test_dpp_pkex(dev, apdev):
"""DPP and PKEX"""
raise Exception("DPP authentication succeeded")
return
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
-
- if check_config:
- ev = dev[1].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)")
+ wait_auth_success(dev[0], dev[1],
+ configurator=dev[1] if check_config else None,
+ enrollee=dev[0] if check_config else None)
def test_dpp_pkex_5ghz(dev, apdev):
"""DPP and PKEX on 5 GHz"""
if "FAIL" in res:
raise Exception("Failed to set PKEX data (initiator)")
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS", "DPP-FAIL"], timeout=20)
- if ev is None or "DPP-AUTH-SUCCESS" not in ev:
- raise Exception("DPP authentication did not succeed (Initiator)")
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
+ wait_auth_success(dev[0], dev[1], timeout=20)
def test_dpp_pkex_test_vector(dev, apdev):
"""DPP and PKEX (P-256) test vector"""
res = dev[1].request(cmd)
if "FAIL" in res:
raise Exception("Failed to set PKEX data (initiator)")
-
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
+ wait_auth_success(dev[0], dev[1])
def test_dpp_pkex_code_mismatch(dev, apdev):
"""DPP and PKEX with mismatching code"""
res = dev[1].request(cmd)
if "FAIL" in res:
raise Exception("Failed to set PKEX data (initiator, retry)")
-
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator, retry)")
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder, retry)")
+ wait_auth_success(dev[0], dev[1])
def test_dpp_pkex_code_mismatch_limit(dev, apdev):
"""DPP and PKEX with mismatching code limit"""
res = dev[1].request(cmd)
if "FAIL" in res:
raise Exception("Failed to set PKEX data (initiator)")
-
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- ev = dev[0].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-CONF-SENT"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Configurator)")
- ev = dev[1].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Enrollee)")
+ wait_auth_success(dev[0], dev[1], configurator=dev[0], enrollee=dev[1])
def test_dpp_pkex_no_responder(dev, apdev):
"""DPP and PKEX with no responder (retry behavior)"""
if "FAIL" in res:
raise Exception("Failed to set PKEX data (responder)")
dev[1].dpp_listen(2437)
-
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=10)
- 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 = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Configurator)")
- # Ignore Enrollee result since configurator was not set here
+ wait_auth_success(dev[1], dev[0], configurator=dev[0], enrollee=dev[1],
+ allow_enrollee_failure=True)
def test_dpp_pkex_hostapd_responder(dev, apdev):
"""DPP PKEX with hostapd as responder"""
res = dev[0].request(cmd)
if "FAIL" in res:
raise Exception("Failed to set PKEX data (initiator/wpa_supplicant)")
-
- 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-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
- ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Configurator)")
- ev = hapd.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()
+ wait_auth_success(hapd, dev[0], configurator=dev[0], enrollee=hapd,
+ stop_initiator=True)
def test_dpp_pkex_hostapd_initiator(dev, apdev):
"""DPP PKEX with hostapd as initiator"""
res = hapd.request(cmd)
if "FAIL" in res:
raise Exception("Failed to set PKEX data (initiator/hostapd)")
-
- 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-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
- ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Configurator)")
- ev = hapd.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()
+ wait_auth_success(hapd, dev[0], configurator=dev[0], enrollee=hapd,
+ stop_initiator=True)
def test_dpp_hostapd_configurator(dev, apdev):
"""DPP with hostapd as configurator/initiator"""
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()
+ wait_auth_success(dev[0], hapd, configurator=hapd, enrollee=dev[0],
+ stop_responder=True)
def test_dpp_hostapd_configurator_responder(dev, apdev):
"""DPP with hostapd as configurator/responder"""
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()
+ wait_auth_success(hapd, dev[0], configurator=hapd, enrollee=dev[0],
+ stop_initiator=True)
def test_dpp_own_config(dev, apdev):
"""DPP configurator signing own connector"""
cmd = "DPP_AUTH_INIT peer=%d conf=ap-dpp configurator=%d%s" % (id, conf_id, extra)
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 = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Configurator)")
- ev = hapd.wait_event(["DPP-CONF-RECEIVED"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Enrollee)")
-
+ wait_auth_success(hapd, dev[0], configurator=dev[0], enrollee=hapd)
update_hapd_config(hapd)
dev[0].set("dpp_config_processing", "1")
cmd = "DPP_AUTH_INIT peer=%d conf=sta-dpp configurator=%d%s" % (id, conf_id, extra)
if "OK" not in hapd.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 (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", "DPP-CONF-FAILED"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Enrollee)")
- if "DPP-CONF-RECEIVED" not in ev:
- raise Exception("DPP configuration failed (Enrollee)")
-
+ wait_auth_success(dev[0], hapd, configurator=hapd, enrollee=dev[0])
dev[0].wait_connected()
def test_dpp_intro_mismatch(dev, apdev):
def test_dpp_proto_stop_at_auth_conf_tx(dev, apdev):
"""DPP protocol testing - stop when transmitting Auth Conf (Registrar)"""
run_dpp_proto_init(dev, 1, 89, init_enrollee=True)
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=10)
- if ev is None:
- raise Exception("Authentication did not succeed (Initiator)")
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("Authentication did not succeed (Responder)")
+ wait_auth_success(dev[0], dev[1], timeout=10)
ev = dev[1].wait_event(["GAS-QUERY-START"], timeout=0.1)
if ev is not None:
raise Exception("Unexpected GAS query")
def test_dpp_proto_stop_at_auth_conf_tx2(dev, apdev):
"""DPP protocol testing - stop when transmitting Auth Conf (Enrollee)"""
run_dpp_proto_init(dev, 1, 89)
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=10)
- if ev is None:
- raise Exception("Authentication did not succeed (Initiator)")
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("Authentication did not succeed (Responder)")
+ wait_auth_success(dev[0], dev[1], timeout=10)
ev = dev[0].wait_event(["GAS-QUERY-DONE"], timeout=5)
if ev is None or "result=TIMEOUT" not in ev:
raise Exception("Failed to initiate DPP Authentication")
if no_wait:
return
- ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=timeout)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Responder)")
- ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
- raise Exception("DPP authentication did not succeed (Initiator)")
- ev = dev[0].wait_event(["DPP-CONF-RECEIVED", "DPP-CONF-FAILED"], timeout=5)
- if ev is None:
- raise Exception("DPP configuration not completed (Enrollee)")
- dev[0].request("DPP_STOP_LISTEN")
- dev[0].dump_monitor()
- dev[1].dump_monitor()
+ wait_auth_success(dev[0], dev[1], timeout=timeout, configurator=dev[1],
+ enrollee=dev[0], allow_enrollee_failure=True,
+ stop_responder=True)
def test_dpp_qr_code_chan_list_no_match(dev, apdev):
"""DPP QR Code and no matching supported channel"""
raise Exception("MGMT_RX_PROCESS failed")
return msg
-def wait_auth_success(responder, initiator):
- ev = responder.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
+def wait_auth_success(responder, initiator, configurator=None, enrollee=None,
+ allow_enrollee_failure=False,
+ allow_configurator_failure=False,
+ require_configurator_failure=False,
+ timeout=5, stop_responder=False, stop_initiator=False):
+ ev = responder.wait_event(["DPP-AUTH-SUCCESS", "DPP-FAIL"], timeout=timeout)
+ if ev is None or "DPP-AUTH-SUCCESS" not in ev:
raise Exception("DPP authentication did not succeed (Responder)")
- ev = initiator.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
- if ev is None:
+ ev = initiator.wait_event(["DPP-AUTH-SUCCESS", "DPP-FAIL"], timeout=5)
+ if ev is None or "DPP-AUTH-SUCCESS" not in ev:
raise Exception("DPP authentication did not succeed (Initiator)")
+ if configurator:
+ ev = configurator.wait_event(["DPP-CONF-SENT",
+ "DPP-CONF-FAILED"], timeout=5)
+ if ev is None:
+ raise Exception("DPP configuration not completed (Configurator)")
+ if "DPP-CONF-FAILED" in ev and not allow_configurator_failure:
+ raise Exception("DPP configuration did not succeed (Configurator")
+ if "DPP-CONF-SUCCESS" in ev and not require_configurator_failure:
+ raise Exception("DPP configuration succeeded (Configurator")
+ if enrollee:
+ ev = enrollee.wait_event(["DPP-CONF-RECEIVED",
+ "DPP-CONF-FAILED"], timeout=5)
+ if ev is None:
+ raise Exception("DPP configuration not completed (Enrollee)")
+ if "DPP-CONF-FAILED" in ev and not allow_enrollee_failure:
+ raise Exception("DPP configuration did not succeed (Enrollee)")
+ if stop_responder:
+ responder.request("DPP_STOP_LISTEN")
+ if stop_initiator:
+ initiator.request("DPP_STOP_LISTEN")
def wait_conf_completion(configurator, enrollee):
ev = configurator.wait_event(["DPP-CONF-SENT"], timeout=5)