tests: DPP URI supported curves

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
Jouni Malinen 2022-04-14 16:59:15 +03:00 committed by Jouni Malinen
parent b0769ce61c
commit 339aef0980
3 changed files with 35 additions and 2 deletions

View file

@ -426,7 +426,7 @@ class Hostapd:
return int(res) return int(res)
def dpp_bootstrap_gen(self, type="qrcode", chan=None, mac=None, info=None, def dpp_bootstrap_gen(self, type="qrcode", chan=None, mac=None, info=None,
curve=None, key=None): curve=None, key=None, supported_curves=None):
cmd = "DPP_BOOTSTRAP_GEN type=" + type cmd = "DPP_BOOTSTRAP_GEN type=" + type
if chan: if chan:
cmd += " chan=" + chan cmd += " chan=" + chan
@ -440,6 +440,8 @@ class Hostapd:
cmd += " curve=" + curve cmd += " curve=" + curve
if key: if key:
cmd += " key=" + key cmd += " key=" + key
if supported_curves:
cmd += " supported_curves=" + supported_curves
res = self.request(cmd) res = self.request(cmd)
if "FAIL" in res: if "FAIL" in res:
raise Exception("Failed to generate bootstrapping info") raise Exception("Failed to generate bootstrapping info")

View file

@ -146,6 +146,35 @@ def test_dpp_uri_version(dev, apdev):
if "version=0" not in info.splitlines(): if "version=0" not in info.splitlines():
raise Exception("Unexpected version information (without indication)") raise Exception("Unexpected version information (without indication)")
def test_dpp_uri_supported_curves(dev, apdev):
"""DPP URI supported curves"""
check_dpp_capab(dev[0], min_ver=3)
tests = [("P-256", "1"),
("P-384", "2"),
("P-521", "4"),
("BP-256", "8"),
("BP-384", "01"),
("BP-512", "02"),
("P-256:P-384:P-521", "7"),
("P-256:BP-512", "12"),
("P-256:P-384:BP-384", "31"),
("P-256:P-384:P-521:BP-256:BP-384:BP-512", "f3")]
for t in tests:
logger.info("Supported list: " + t[0])
id0 = dev[0].dpp_bootstrap_gen(supported_curves=t[0])
uri = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
logger.info("Generated URI: " + uri)
if ";B:%s;" % t[1] not in uri:
raise Exception("Supported curves(1) not indicated correctly: " + uri)
id1 = dev[0].dpp_qr_code(uri)
uri = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id1)
info = dev[0].request("DPP_BOOTSTRAP_INFO %d" % id1)
logger.info("Parsed URI info:\n" + info)
if "supp_curves=" + t[0] not in info.splitlines():
raise Exception("supp_curves not indicated correctly in info")
def test_dpp_qr_code_parsing_fail(dev, apdev): def test_dpp_qr_code_parsing_fail(dev, apdev):
"""DPP QR Code parsing local failure""" """DPP QR Code parsing local failure"""
check_dpp_capab(dev[0]) check_dpp_capab(dev[0])

View file

@ -1482,7 +1482,7 @@ class WpaSupplicant:
return int(res) return int(res)
def dpp_bootstrap_gen(self, type="qrcode", chan=None, mac=None, info=None, def dpp_bootstrap_gen(self, type="qrcode", chan=None, mac=None, info=None,
curve=None, key=None): curve=None, key=None, supported_curves=None):
cmd = "DPP_BOOTSTRAP_GEN type=" + type cmd = "DPP_BOOTSTRAP_GEN type=" + type
if chan: if chan:
cmd += " chan=" + chan cmd += " chan=" + chan
@ -1496,6 +1496,8 @@ class WpaSupplicant:
cmd += " curve=" + curve cmd += " curve=" + curve
if key: if key:
cmd += " key=" + key cmd += " key=" + key
if supported_curves:
cmd += " supported_curves=" + supported_curves
res = self.request(cmd) res = self.request(cmd)
if "FAIL" in res: if "FAIL" in res:
raise Exception("Failed to generate bootstrapping info") raise Exception("Failed to generate bootstrapping info")