tests: sigma_dut DPP/PKEX initiator as Configurator over TCP and Wi-Fi

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
Jouni Malinen 2022-07-21 20:32:32 +03:00 committed by Jouni Malinen
parent e9137950fa
commit ca4e82cbfe

View file

@ -2454,6 +2454,100 @@ def test_sigma_dut_dpp_pkex_init_configurator_tcp_through_relay(dev, apdev):
stop_sigma_dut(sigma)
dev[1].set("dpp_config_processing", "0", allow_fail=True)
def test_sigma_dut_dpp_pkex_init_configurator_tcp_and_wifi(dev, apdev):
"""sigma_dut DPP/PKEX initiator as Configurator over TCP and Wi-Fi"""
check_dpp_capab(dev[0], min_ver=3)
check_dpp_capab(dev[1], min_ver=3)
hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured", "channel": "6"})
check_dpp_capab(hapd)
sigma = start_sigma_dut(dev[0].ifname)
try:
# PKEX init (AP Enrollee) over air
id1 = hapd.dpp_bootstrap_gen(type="pkex")
cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id1)
res = hapd.request(cmd)
if "FAIL" in res:
raise Exception("Failed to set PKEX data (responder AP)")
res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPProvisioningRole,Configurator,DPPConfIndex,1,DPPSigningKeyECC,P-256,DPPConfEnrolleeRole,AP,DPPBS,PKEX,DPPPKEXCodeIdentifier,test,DPPPKEXCode,secret,DPPTimeout,6")
if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res:
raise Exception("Unexpected result: " + res)
ev = hapd.wait_event(["DPP-CONF-RECEIVED"], timeout=1)
if ev is None:
raise Exception("AP Enrollee did not report success")
# Relay
port = 8908
pkhash = "05be01e0eb79ae5d2a174d9fc83548638d325f25ee9c5840dfe6dfe8b1ae6517"
params = {"ssid": "unconfigured",
"channel": "6",
"dpp_controller": "ipaddr=127.0.0.1 pkhash=" + pkhash,
"dpp_relay_port": str(port)}
relay = hostapd.add_ap(apdev[1], params)
check_dpp_capab(relay)
# PKEX init (STA Enrollee) through Relay
dev[1].dpp_listen(2437)
id1 = dev[1].dpp_bootstrap_gen(type="pkex")
cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id1)
res = dev[1].request(cmd)
if "FAIL" in res:
raise Exception("Failed to set PKEX data (responder)")
res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPProvisioningRole,Configurator,DPPConfIndex,1,DPPSigningKeyECC,P-256,DPPConfEnrolleeRole,STA,DPPBS,PKEX,DPPPKEXCodeIdentifier,test,DPPPKEXCode,secret,DPPTimeout,6,DPPOverTCP,127.0.0.1")
if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res:
raise Exception("Unexpected result: " + res)
ev = dev[1].wait_event(["DPP-CONF-RECEIVED"], timeout=1)
if ev is None:
raise Exception("STA Enrollee did not report success")
dev[1].request("DPP_STOP_LISTEN")
dev[1].dump_monitor()
# PKEX init (STA Enrollee) over air
dev[1].dpp_listen(2437)
id1 = dev[1].dpp_bootstrap_gen(type="pkex")
cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id1)
res = dev[1].request(cmd)
if "FAIL" in res:
raise Exception("Failed to set PKEX data (responder)")
res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPProvisioningRole,Configurator,DPPConfIndex,1,DPPSigningKeyECC,P-256,DPPConfEnrolleeRole,STA,DPPBS,PKEX,DPPPKEXCodeIdentifier,test,DPPPKEXCode,secret,DPPTimeout,6")
if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res:
raise Exception("Unexpected result: " + res)
ev = dev[1].wait_event(["DPP-CONF-RECEIVED"], timeout=1)
if ev is None:
raise Exception("STA(2) Enrollee did not report success")
dev[1].request("DPP_STOP_LISTEN")
dev[1].dump_monitor()
# PKEX init (STA Enrollee) through Relay
dev[1].dpp_listen(2437)
id1 = dev[1].dpp_bootstrap_gen(type="pkex")
cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id1)
res = dev[1].request(cmd)
if "FAIL" in res:
raise Exception("Failed to set PKEX data (responder)")
# Make things more complex by allowing frames from Relay to be seen on
# the Controller over the air.
dev[0].dpp_listen(2437)
res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPProvisioningRole,Configurator,DPPConfIndex,1,DPPSigningKeyECC,P-256,DPPConfEnrolleeRole,STA,DPPBS,PKEX,DPPPKEXCodeIdentifier,test,DPPPKEXCode,secret,DPPTimeout,6,DPPOverTCP,127.0.0.1")
if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res:
raise Exception("Unexpected result: " + res)
ev = dev[1].wait_event(["DPP-CONF-RECEIVED"], timeout=1)
if ev is None:
raise Exception("STA(3) Enrollee did not report success")
dev[1].request("DPP_STOP_LISTEN")
dev[1].dump_monitor()
finally:
stop_sigma_dut(sigma)
def dpp_pkex_resp_start_on_v1(dev):
while True:
ev = dev.wait_event(["DPP-RX"], timeout=5)