From 3710b58d2417ad1f6858c457f5e3400313eb9b33 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 30 Nov 2018 13:46:15 +0200 Subject: [PATCH] tests: More DPP incompatible roles coverage Cover the Configurator/Configurator case in addition Enrollee/Enrollee. Signed-off-by: Jouni Malinen --- tests/hwsim/test_dpp.py | 50 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/tests/hwsim/test_dpp.py b/tests/hwsim/test_dpp.py index 509d9e1bc..1688d42c5 100644 --- a/tests/hwsim/test_dpp.py +++ b/tests/hwsim/test_dpp.py @@ -897,8 +897,7 @@ def run_dpp_qr_code_auth_initiator_either(dev, apdev, resp_role, dev[0].request("DPP_STOP_LISTEN") -def test_dpp_qr_code_auth_incompatible_roles(dev, apdev): - """DPP QR Code and authentication exchange (incompatible roles)""" +def run_init_incompatible_roles(dev, role="enrollee"): check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) logger.info("dev0 displays QR Code") @@ -916,8 +915,13 @@ def test_dpp_qr_code_auth_incompatible_roles(dev, apdev): id1 = int(res) logger.info("dev1 initiates DPP Authentication") - if "OK" not in dev[0].request("DPP_LISTEN 2412 role=enrollee"): + if "OK" not in dev[0].request("DPP_LISTEN 2412 role=%s" % role): raise Exception("Failed to start listen operation") + return id1 + +def test_dpp_qr_code_auth_incompatible_roles(dev, apdev): + """DPP QR Code and authentication exchange (incompatible roles)""" + id1 = run_init_incompatible_roles(dev) if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d role=enrollee" % id1): raise Exception("Failed to initiate DPP Authentication") ev = dev[1].wait_event(["DPP-NOT-COMPATIBLE"], timeout=5) @@ -937,6 +941,46 @@ def test_dpp_qr_code_auth_incompatible_roles(dev, apdev): raise Exception("DPP authentication did not succeed (Initiator)") dev[0].request("DPP_STOP_LISTEN") +def test_dpp_qr_code_auth_incompatible_roles2(dev, apdev): + """DPP QR Code and authentication exchange (incompatible roles 2)""" + id1 = run_init_incompatible_roles(dev, role="configurator") + if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d role=configurator" % id1): + raise Exception("Failed to initiate DPP Authentication") + ev = dev[1].wait_event(["DPP-NOT-COMPATIBLE"], timeout=5) + if ev is None: + raise Exception("DPP-NOT-COMPATIBLE event on initiator timed out") + ev = dev[0].wait_event(["DPP-NOT-COMPATIBLE"], timeout=1) + if ev is None: + raise Exception("DPP-NOT-COMPATIBLE event on responder timed out") + +def test_dpp_qr_code_auth_incompatible_roles_failure(dev, apdev): + """DPP QR Code and authentication exchange (incompatible roles failure)""" + id1 = run_init_incompatible_roles(dev, role="configurator") + with alloc_fail(dev[0], 1, "dpp_auth_build_resp_status"): + 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-NOT-COMPATIBLE"], timeout=1) + if ev is None: + raise Exception("DPP-NOT-COMPATIBLE event on responder timed out") + +def test_dpp_qr_code_auth_incompatible_roles_failure2(dev, apdev): + """DPP QR Code and authentication exchange (incompatible roles failure 2)""" + id1 = run_init_incompatible_roles(dev, role="configurator") + with alloc_fail(dev[1], 1, "dpp_auth_resp_rx_status"): + if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d role=configurator" % id1): + raise Exception("Failed to initiate DPP Authentication") + wait_fail_trigger(dev[1], "GET_ALLOC_FAIL") + +def test_dpp_qr_code_auth_incompatible_roles_failure3(dev, apdev): + """DPP QR Code and authentication exchange (incompatible roles failure 3)""" + id1 = run_init_incompatible_roles(dev, role="configurator") + with fail_test(dev[1], 1, "dpp_auth_resp_rx_status"): + if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d role=configurator" % id1): + raise Exception("Failed to initiate DPP Authentication") + ev = dev[1].wait_event(["DPP-FAIL"], timeout=5) + if ev is None or "AES-SIV decryption failed" not in ev: + raise Exception("AES-SIV decryption failure not reported") + def test_dpp_qr_code_auth_neg_chan(dev, apdev): """DPP QR Code and authentication exchange with requested different channel""" check_dpp_capab(dev[0])