tests: DPP Controller in hostapd
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
parent
7ddb71224b
commit
255e29fcae
1 changed files with 47 additions and 35 deletions
|
@ -4774,7 +4774,7 @@ def test_dpp_tcp(dev, apdev, params):
|
||||||
prefix = "dpp_tcp"
|
prefix = "dpp_tcp"
|
||||||
cap_lo = os.path.join(params['logdir'], prefix + ".lo.pcap")
|
cap_lo = os.path.join(params['logdir'], prefix + ".lo.pcap")
|
||||||
try:
|
try:
|
||||||
run_dpp_tcp(dev, apdev, cap_lo)
|
run_dpp_tcp(dev[0], dev[1], cap_lo)
|
||||||
finally:
|
finally:
|
||||||
dev[1].request("DPP_CONTROLLER_STOP")
|
dev[1].request("DPP_CONTROLLER_STOP")
|
||||||
|
|
||||||
|
@ -4783,7 +4783,7 @@ def test_dpp_tcp_port(dev, apdev, params):
|
||||||
prefix = "dpp_tcp_port"
|
prefix = "dpp_tcp_port"
|
||||||
cap_lo = os.path.join(params['logdir'], prefix + ".lo.pcap")
|
cap_lo = os.path.join(params['logdir'], prefix + ".lo.pcap")
|
||||||
try:
|
try:
|
||||||
run_dpp_tcp(dev, apdev, cap_lo, port="23456")
|
run_dpp_tcp(dev[0], dev[1], cap_lo, port="23456")
|
||||||
finally:
|
finally:
|
||||||
dev[1].request("DPP_CONTROLLER_STOP")
|
dev[1].request("DPP_CONTROLLER_STOP")
|
||||||
|
|
||||||
|
@ -4791,24 +4791,30 @@ def test_dpp_tcp_mutual(dev, apdev, params):
|
||||||
"""DPP over TCP (mutual)"""
|
"""DPP over TCP (mutual)"""
|
||||||
cap_lo = os.path.join(params['prefix'], ".lo.pcap")
|
cap_lo = os.path.join(params['prefix'], ".lo.pcap")
|
||||||
try:
|
try:
|
||||||
run_dpp_tcp(dev, apdev, cap_lo, mutual=True)
|
run_dpp_tcp(dev[0], dev[1], cap_lo, mutual=True)
|
||||||
finally:
|
finally:
|
||||||
dev[1].request("DPP_CONTROLLER_STOP")
|
dev[1].request("DPP_CONTROLLER_STOP")
|
||||||
|
|
||||||
def run_dpp_tcp(dev, apdev, cap_lo, port=None, mutual=False):
|
def test_dpp_tcp_mutual_hostapd_conf(dev, apdev, params):
|
||||||
check_dpp_capab(dev[0])
|
"""DPP over TCP (mutual, hostapd as Configurator)"""
|
||||||
check_dpp_capab(dev[1])
|
cap_lo = os.path.join(params['prefix'], ".lo.pcap")
|
||||||
|
hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured"})
|
||||||
|
run_dpp_tcp(dev[0], hapd, cap_lo, mutual=True)
|
||||||
|
|
||||||
|
def run_dpp_tcp(dev0, dev1, cap_lo, port=None, mutual=False):
|
||||||
|
check_dpp_capab(dev0)
|
||||||
|
check_dpp_capab(dev1)
|
||||||
|
|
||||||
wt = WlantestCapture('lo', cap_lo)
|
wt = WlantestCapture('lo', cap_lo)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
# Controller
|
# Controller
|
||||||
conf_id = dev[1].dpp_configurator_add()
|
conf_id = dev1.dpp_configurator_add()
|
||||||
dev[1].set("dpp_configurator_params",
|
dev1.set("dpp_configurator_params",
|
||||||
" conf=sta-dpp configurator=%d" % conf_id)
|
" conf=sta-dpp configurator=%d" % conf_id)
|
||||||
id_c = dev[1].dpp_bootstrap_gen()
|
id_c = dev1.dpp_bootstrap_gen()
|
||||||
uri_c = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id_c)
|
uri_c = dev1.request("DPP_BOOTSTRAP_GET_URI %d" % id_c)
|
||||||
res = dev[1].request("DPP_BOOTSTRAP_INFO %d" % id_c)
|
res = dev1.request("DPP_BOOTSTRAP_INFO %d" % id_c)
|
||||||
pkhash = None
|
pkhash = None
|
||||||
for line in res.splitlines():
|
for line in res.splitlines():
|
||||||
name, value = line.split('=')
|
name, value = line.split('=')
|
||||||
|
@ -4822,35 +4828,35 @@ def run_dpp_tcp(dev, apdev, cap_lo, port=None, mutual=False):
|
||||||
req += " tcp_port=" + port
|
req += " tcp_port=" + port
|
||||||
if mutual:
|
if mutual:
|
||||||
req += " qr=mutual"
|
req += " qr=mutual"
|
||||||
id0 = dev[0].dpp_bootstrap_gen()
|
id0 = dev0.dpp_bootstrap_gen()
|
||||||
uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
|
uri0 = dev0.request("DPP_BOOTSTRAP_GET_URI %d" % id0)
|
||||||
own = id0
|
own = id0
|
||||||
else:
|
else:
|
||||||
own = None
|
own = None
|
||||||
if "OK" not in dev[1].request(req):
|
if "OK" not in dev1.request(req):
|
||||||
raise Exception("Failed to start Controller")
|
raise Exception("Failed to start Controller")
|
||||||
|
|
||||||
# Initiate from Enrollee with broadcast DPP Authentication Request
|
# Initiate from Enrollee with broadcast DPP Authentication Request
|
||||||
dev[0].dpp_auth_init(uri=uri_c, own=own, role="enrollee",
|
dev0.dpp_auth_init(uri=uri_c, own=own, role="enrollee",
|
||||||
tcp_addr="127.0.0.1", tcp_port=port)
|
tcp_addr="127.0.0.1", tcp_port=port)
|
||||||
|
|
||||||
if mutual:
|
if mutual:
|
||||||
ev = dev[0].wait_event(["DPP-RESPONSE-PENDING"], timeout=5)
|
ev = dev0.wait_event(["DPP-RESPONSE-PENDING"], timeout=5)
|
||||||
if ev is None:
|
if ev is None:
|
||||||
raise Exception("Pending response not reported")
|
raise Exception("Pending response not reported")
|
||||||
ev = dev[1].wait_event(["DPP-SCAN-PEER-QR-CODE"], timeout=5)
|
ev = dev1.wait_event(["DPP-SCAN-PEER-QR-CODE"], timeout=5)
|
||||||
if ev is None:
|
if ev is None:
|
||||||
raise Exception("QR Code scan for mutual authentication not requested")
|
raise Exception("QR Code scan for mutual authentication not requested")
|
||||||
|
|
||||||
id1 = dev[1].dpp_qr_code(uri0)
|
id1 = dev1.dpp_qr_code(uri0)
|
||||||
|
|
||||||
ev = dev[0].wait_event(["DPP-AUTH-DIRECTION"], timeout=5)
|
ev = dev0.wait_event(["DPP-AUTH-DIRECTION"], timeout=5)
|
||||||
if ev is None:
|
if ev is None:
|
||||||
raise Exception("DPP authentication direction not indicated (Initiator)")
|
raise Exception("DPP authentication direction not indicated (Initiator)")
|
||||||
if "mutual=1" not in ev:
|
if "mutual=1" not in ev:
|
||||||
raise Exception("Mutual authentication not used")
|
raise Exception("Mutual authentication not used")
|
||||||
|
|
||||||
wait_auth_success(dev[1], dev[0], configurator=dev[1], enrollee=dev[0],
|
wait_auth_success(dev1, dev0, configurator=dev1, enrollee=dev0,
|
||||||
allow_enrollee_failure=True,
|
allow_enrollee_failure=True,
|
||||||
allow_configurator_failure=True)
|
allow_configurator_failure=True)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
@ -4860,31 +4866,37 @@ def test_dpp_tcp_conf_init(dev, apdev, params):
|
||||||
"""DPP over TCP (Configurator initiates)"""
|
"""DPP over TCP (Configurator initiates)"""
|
||||||
cap_lo = os.path.join(params['prefix'], ".lo.pcap")
|
cap_lo = os.path.join(params['prefix'], ".lo.pcap")
|
||||||
try:
|
try:
|
||||||
run_dpp_tcp_conf_init(dev, apdev, cap_lo)
|
run_dpp_tcp_conf_init(dev[0], dev[1], cap_lo)
|
||||||
finally:
|
finally:
|
||||||
dev[1].request("DPP_CONTROLLER_STOP")
|
dev[1].request("DPP_CONTROLLER_STOP")
|
||||||
|
|
||||||
def run_dpp_tcp_conf_init(dev, apdev, cap_lo, port=None):
|
def test_dpp_tcp_conf_init_hostapd_enrollee(dev, apdev, params):
|
||||||
check_dpp_capab(dev[0], min_ver=2)
|
"""DPP over TCP (Configurator initiates, hostapd as Enrollee)"""
|
||||||
check_dpp_capab(dev[1], min_ver=2)
|
cap_lo = os.path.join(params['prefix'], ".lo.pcap")
|
||||||
|
hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured"})
|
||||||
|
run_dpp_tcp_conf_init(dev[0], hapd, cap_lo, conf="ap-dpp")
|
||||||
|
|
||||||
|
def run_dpp_tcp_conf_init(dev0, dev1, cap_lo, port=None, conf="sta-dpp"):
|
||||||
|
check_dpp_capab(dev0, min_ver=2)
|
||||||
|
check_dpp_capab(dev1, min_ver=2)
|
||||||
|
|
||||||
wt = WlantestCapture('lo', cap_lo)
|
wt = WlantestCapture('lo', cap_lo)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
id_c = dev[1].dpp_bootstrap_gen()
|
id_c = dev1.dpp_bootstrap_gen()
|
||||||
uri_c = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id_c)
|
uri_c = dev1.request("DPP_BOOTSTRAP_GET_URI %d" % id_c)
|
||||||
res = dev[1].request("DPP_BOOTSTRAP_INFO %d" % id_c)
|
res = dev1.request("DPP_BOOTSTRAP_INFO %d" % id_c)
|
||||||
req = "DPP_CONTROLLER_START role=enrollee"
|
req = "DPP_CONTROLLER_START role=enrollee"
|
||||||
if port:
|
if port:
|
||||||
req += " tcp_port=" + port
|
req += " tcp_port=" + port
|
||||||
if "OK" not in dev[1].request(req):
|
if "OK" not in dev1.request(req):
|
||||||
raise Exception("Failed to start Controller")
|
raise Exception("Failed to start Controller")
|
||||||
|
|
||||||
conf_id = dev[0].dpp_configurator_add()
|
conf_id = dev0.dpp_configurator_add()
|
||||||
dev[0].dpp_auth_init(uri=uri_c, role="configurator", conf="sta-dpp",
|
dev0.dpp_auth_init(uri=uri_c, role="configurator", conf=conf,
|
||||||
configurator=conf_id,
|
configurator=conf_id,
|
||||||
tcp_addr="127.0.0.1", tcp_port=port)
|
tcp_addr="127.0.0.1", tcp_port=port)
|
||||||
wait_auth_success(dev[0], dev[1], configurator=dev[0], enrollee=dev[1],
|
wait_auth_success(dev1, dev0, configurator=dev0, enrollee=dev1,
|
||||||
allow_enrollee_failure=True,
|
allow_enrollee_failure=True,
|
||||||
allow_configurator_failure=True)
|
allow_configurator_failure=True)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
Loading…
Reference in a new issue