From db46138de430c431dd6c799ef923d7976b0da064 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 7 Oct 2022 19:44:48 +0300 Subject: [PATCH] tests: sigma_dut DPP reconfiguration using SAE (Enrollee) Signed-off-by: Jouni Malinen --- tests/hwsim/test_sigma_dut.py | 86 +++++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/tests/hwsim/test_sigma_dut.py b/tests/hwsim/test_sigma_dut.py index b2c139d77..6b1094b21 100644 --- a/tests/hwsim/test_sigma_dut.py +++ b/tests/hwsim/test_sigma_dut.py @@ -4089,6 +4089,87 @@ def test_sigma_dut_dpp_reconfig_enrollee(dev, apdev): dev[0].set("dpp_config_processing", "0") stop_sigma_dut(sigma) +def test_sigma_dut_dpp_reconfig_enrollee_sae(dev, apdev): + """sigma_dut DPP reconfiguration using SAE (Enrollee)""" + check_dpp_capab(dev[0]) + check_dpp_capab(dev[1]) + check_sae_capab(dev[0]) + hapd = start_dpp_ap(apdev[0]) + sigma = start_sigma_dut(dev[0].ifname) + try: + cmd = "DPP_CONFIGURATOR_ADD key=" + csign + res = dev[1].request(cmd) + if "FAIL" in res: + raise Exception("Failed to add configurator") + conf_id = int(res) + + id0 = dev[1].dpp_bootstrap_gen(chan="81/6", mac=True) + uri0 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0) + + dev[1].set("dpp_configurator_params", + "conf=sta-dpp ssid=%s configurator=%d" % (to_hex("DPPNET01"), conf_id)) + cmd = "DPP_LISTEN 2437 role=configurator" + if "OK" not in dev[1].request(cmd): + raise Exception("Failed to start listen operation") + + ifname = dev[0].ifname + sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,DPP" % ifname) + + res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % to_hex(uri0)) + if "status,COMPLETE" not in res: + raise Exception("dev_exec_action did not succeed: " + res) + + res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPAuthDirection,Single,DPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,6,DPPWaitForConnect,Yes", timeout=10) + if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,OK,NetworkConnectResult,OK" not in res: + raise Exception("Unexpected result: " + res) + + hapd.disable() + dev[0].dump_monitor() + + hapd = start_sae_pwe_ap(apdev[0], 2, ssid="DPPNET01") + + dev[1].set("dpp_configurator_params", + "conf=sta-sae ssid=%s pass=%s configurator=%d conn_status=1" % (to_hex("DPPNET01"), to_hex("12345678"), conf_id)) + cmd = "DPP_LISTEN 2437 role=configurator" + if "OK" not in dev[1].request(cmd): + raise Exception("Failed to start listen operation") + dev[1].dump_monitor() + + res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,DPPReconfigure,DPPTimeout,6,DPPWaitForConnect,Yes", timeout=10) + if "status,COMPLETE,ReconfigAuthResult,OK,ConfResult,OK,NetworkConnectResult,OK" not in res: + raise Exception("Unexpected reconfiguration result: " + res) + + ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=15) + if ev is None: + raise Exception("DPP Config Response (reconfig) not transmitted") + + dev[0].wait_connected(timeout=20) + ev = dev[1].wait_event(["DPP-CONN-STATUS-RESULT"], timeout=20) + if ev is None: + raise Exception("No connection status reported") + if "result=0" not in ev: + raise Exception("Connection status did not report success: " + ev) + + time.sleep(1) + cmd = "DPP_LISTEN 2437 role=configurator" + if "OK" not in dev[1].request(cmd): + raise Exception("Failed to start listen operation") + dev[0].dump_monitor() + dev[1].dump_monitor() + + res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,DPPReconfigure,DPPTimeout,6,DPPWaitForConnect,Yes", timeout=30) + if "status,COMPLETE,ReconfigAuthResult,OK,ConfResult,OK,NetworkConnectResult,OK" not in res: + raise Exception("Unexpected reconfiguration [2] result: " + res) + + ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=5) + if ev is None: + raise Exception("DPP Config Response (reconfig) not transmitted [2]") + + dev[0].wait_connected(timeout=20) + finally: + dev[0].set("dpp_config_processing", "0") + stop_sigma_dut(sigma) + def test_sigma_dut_dpp_reconfig_configurator(dev, apdev): """sigma_dut DPP reconfiguration (Configurator)""" check_dpp_capab(dev[0]) @@ -5200,9 +5281,8 @@ def test_sigma_dut_eap_aka(dev, apdev, params): finally: stop_sigma_dut(sigma) -def start_sae_pwe_ap(apdev, sae_pwe): - ssid = "test-sae" - params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678") +def start_sae_pwe_ap(apdev, sae_pwe, ssid="test-sae", password="12345678"): + params = hostapd.wpa2_params(ssid=ssid, passphrase=password) params['wpa_key_mgmt'] = 'SAE' params["ieee80211w"] = "2" params['sae_groups'] = '19'