diff options
Diffstat (limited to 'tests/hwsim/test_dpp.py')
| -rw-r--r-- | tests/hwsim/test_dpp.py | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/tests/hwsim/test_dpp.py b/tests/hwsim/test_dpp.py index 71df7fc64148..4ed2652ef5df 100644 --- a/tests/hwsim/test_dpp.py +++ b/tests/hwsim/test_dpp.py @@ -214,7 +214,8 @@ def test_dpp_qr_code_keygen_fail(dev, apdev): """DPP QR Code and keygen failure""" check_dpp_capab(dev[0]) - with alloc_fail(dev[0], 1, "dpp_bootstrap_key_der;dpp_keygen"): + with alloc_fail(dev[0], 1, + "crypto_ec_key_get_subject_public_key;dpp_keygen"): if "FAIL" not in dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode"): raise Exception("Failure not reported") @@ -369,8 +370,10 @@ def run_dpp_qr_code_auth_unicast(dev, apdev, curve, netrole=None, key=None, require_conf_failure=False, configurator=False, conf_curve=None, conf=None, qr=None, stop_responder=True): - check_dpp_capab(dev[0], curve and "brainpool" in curve) - check_dpp_capab(dev[1], curve and "brainpool" in curve) + brainpool = (curve and "brainpool" in curve) or \ + (conf_curve and "brainpool" in conf_curve) + check_dpp_capab(dev[0], brainpool) + check_dpp_capab(dev[1], brainpool) if configurator: conf_id = dev[1].dpp_configurator_add(curve=conf_curve) else: @@ -1751,8 +1754,10 @@ def update_hapd_config(hapd): def run_dpp_ap_config(dev, apdev, curve=None, conf_curve=None, reconf_configurator=False): - check_dpp_capab(dev[0]) - check_dpp_capab(dev[1]) + brainpool = (curve and "BP-" in curve) or \ + (conf_curve and "BP-" in conf_curve) + check_dpp_capab(dev[0], brainpool) + check_dpp_capab(dev[1], brainpool) hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured"}) check_dpp_capab(hapd) @@ -2214,7 +2219,7 @@ def test_dpp_test_vector_p_256_b(dev, apdev): def der_priv_key_p_521(priv): if len(priv) != 2 * 66: raise Exception("Unexpected der_priv_key_p_521 parameter: " + priv) - der_prefix = "3081500201010442" + der_prefix = "30500201010442" der_postfix = "a00706052b81040023" return der_prefix + priv + der_postfix @@ -2482,7 +2487,7 @@ def test_dpp_pkex_commit_reveal_req_processing_failure(dev, apdev): dev[0].dpp_pkex_resp(2437, identifier="test", code="secret") with alloc_fail(dev[0], 1, - "dpp_get_pubkey_point;dpp_pkex_rx_commit_reveal_req"): + "crypto_ec_key_get_pubkey_point;dpp_pkex_rx_commit_reveal_req"): dev[1].dpp_pkex_init(identifier="test", code="secret") wait_fail_trigger(dev[0], "GET_ALLOC_FAIL") @@ -4138,7 +4143,7 @@ def test_dpp_pkex_alloc_fail(dev, apdev): id1 = None # Local error cases on the Initiator - tests = [(1, "dpp_get_pubkey_point"), + tests = [(1, "crypto_ec_key_get_pubkey_point"), (1, "dpp_alloc_msg;dpp_pkex_build_exchange_req"), (1, "dpp_alloc_msg;dpp_pkex_build_commit_reveal_req"), (1, "dpp_alloc_msg;dpp_auth_build_req"), @@ -4168,9 +4173,9 @@ def test_dpp_pkex_alloc_fail(dev, apdev): (3, "dpp_pkex_init"), (1, "dpp_pkex_derive_z"), (1, "=dpp_pkex_rx_commit_reveal_resp"), - (1, "dpp_get_pubkey_point;dpp_build_jwk"), - (2, "dpp_get_pubkey_point;dpp_build_jwk"), - (1, "dpp_get_pubkey_point;dpp_auth_init")] + (1, "crypto_ec_key_get_pubkey_point;dpp_build_jwk"), + (2, "crypto_ec_key_get_pubkey_point;dpp_build_jwk"), + (1, "crypto_ec_key_get_pubkey_point;dpp_auth_init")] for count, func in tests: dev[0].request("DPP_STOP_LISTEN") dev[1].request("DPP_STOP_LISTEN") @@ -4191,11 +4196,11 @@ def test_dpp_pkex_alloc_fail(dev, apdev): dev[0].wait_event(["GAS-QUERY-DONE"], timeout=3) # Local error cases on the Responder - tests = [(1, "dpp_get_pubkey_point"), + tests = [(1, "crypto_ec_key_get_pubkey_point"), (1, "dpp_alloc_msg;dpp_pkex_build_exchange_resp"), (1, "dpp_alloc_msg;dpp_pkex_build_commit_reveal_resp"), (1, "dpp_alloc_msg;dpp_auth_build_resp"), - (1, "dpp_get_pubkey_point;dpp_auth_build_resp_ok"), + (1, "crypto_ec_key_get_pubkey_point;dpp_auth_build_resp_ok"), (1, "dpp_alloc_auth"), (1, "=dpp_auth_req_rx"), (1, "=dpp_auth_conf_rx"), @@ -4206,7 +4211,7 @@ def test_dpp_pkex_alloc_fail(dev, apdev): (1, "json_parse;dpp_parse_connector"), (1, "dpp_parse_jwk;dpp_parse_connector"), (1, "dpp_parse_jwk;dpp_parse_cred_dpp"), - (1, "dpp_get_pubkey_point;dpp_check_pubkey_match"), + (1, "crypto_ec_key_get_pubkey_point;dpp_check_pubkey_match"), (1, "base64_gen_decode;dpp_process_signed_connector"), (1, "dpp_parse_jws_prot_hdr;dpp_process_signed_connector"), (2, "base64_gen_decode;dpp_process_signed_connector"), @@ -4219,7 +4224,7 @@ def test_dpp_pkex_alloc_fail(dev, apdev): (2, "=dpp_pkex_rx_exchange_req"), (3, "=dpp_pkex_rx_exchange_req"), (1, "=dpp_pkex_rx_commit_reveal_req"), - (1, "dpp_get_pubkey_point;dpp_pkex_rx_commit_reveal_req"), + (1, "crypto_ec_key_get_pubkey_point;dpp_pkex_rx_commit_reveal_req"), (1, "dpp_bootstrap_key_hash")] for count, func in tests: dev[0].request("DPP_STOP_LISTEN") @@ -4650,7 +4655,8 @@ def test_dpp_invalid_configurator_key(dev, apdev): if "FAIL" not in dev[0].request("DPP_CONFIGURATOR_ADD key=" + dpp_key_p256): raise Exception("Error not reported") - with alloc_fail(dev[0], 1, "dpp_get_pubkey_point;dpp_keygen_configurator"): + with alloc_fail(dev[0], 1, + "crypto_ec_key_get_pubkey_point;dpp_keygen_configurator"): if "FAIL" not in dev[0].request("DPP_CONFIGURATOR_ADD key=" + dpp_key_p256): raise Exception("Error not reported") @@ -5490,6 +5496,37 @@ def test_dpp_tcp_controller_management_hostapd(dev, apdev, params): if "FAIL" not in hapd.request("DPP_CONFIGURATOR_REMOVE %d" % conf_id): raise Exception("Removal of unknown Configurator accepted") +def test_dpp_tcp_controller_management_hostapd2(dev, apdev, params): + """DPP Controller management in hostapd over interface addition/removal""" + check_dpp_capab(dev[0], min_ver=2) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured"}) + check_dpp_capab(hapd, min_ver=2) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "unconfigured"}) + check_dpp_capab(hapd2, min_ver=2) + id_c = hapd.dpp_bootstrap_gen() + uri_c = hapd.request("DPP_BOOTSTRAP_GET_URI %d" % id_c) + if "OK" not in hapd.request("DPP_CONTROLLER_START role=enrollee"): + raise Exception("Failed to start Controller") + + conf_id = dev[0].dpp_configurator_add() + dev[0].dpp_auth_init(uri=uri_c, role="configurator", conf="sta-dpp", + configurator=conf_id, tcp_addr="127.0.0.1") + ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5) + if ev is None: + raise Exception("DPP Authentication did not succeed") + ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5) + if ev is None: + raise Exception("DPP Configuration did not succeed") + + hapd_global = hostapd.HostapdGlobal(apdev) + hapd_global.remove(apdev[0]['ifname']) + + dev[0].dpp_auth_init(uri=uri_c, role="configurator", conf="sta-dpp", + configurator=conf_id, tcp_addr="127.0.0.1") + ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5) + if ev is not None: + raise Exception("Unexpected DPP Authentication success") + def test_dpp_tcp_controller_start_failure(dev, apdev, params): """DPP Controller startup failure""" check_dpp_capab(dev[0]) |
