From 339aef0980af33b208d5daa6815e22b0639f3249 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 14 Apr 2022 16:59:15 +0300 Subject: [PATCH] tests: DPP URI supported curves Signed-off-by: Jouni Malinen --- tests/hwsim/hostapd.py | 4 +++- tests/hwsim/test_dpp.py | 29 +++++++++++++++++++++++++++++ tests/hwsim/wpasupplicant.py | 4 +++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index f1ae8150e..be322c00b 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -426,7 +426,7 @@ class Hostapd: return int(res) 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 if chan: cmd += " chan=" + chan @@ -440,6 +440,8 @@ class Hostapd: cmd += " curve=" + curve if key: cmd += " key=" + key + if supported_curves: + cmd += " supported_curves=" + supported_curves res = self.request(cmd) if "FAIL" in res: raise Exception("Failed to generate bootstrapping info") diff --git a/tests/hwsim/test_dpp.py b/tests/hwsim/test_dpp.py index 94b9f8207..523ff3c71 100644 --- a/tests/hwsim/test_dpp.py +++ b/tests/hwsim/test_dpp.py @@ -146,6 +146,35 @@ def test_dpp_uri_version(dev, apdev): if "version=0" not in info.splitlines(): 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): """DPP QR Code parsing local failure""" check_dpp_capab(dev[0]) diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 01193f4d4..1c173349f 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -1482,7 +1482,7 @@ class WpaSupplicant: return int(res) 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 if chan: cmd += " chan=" + chan @@ -1496,6 +1496,8 @@ class WpaSupplicant: cmd += " curve=" + curve if key: cmd += " key=" + key + if supported_curves: + cmd += " supported_curves=" + supported_curves res = self.request(cmd) if "FAIL" in res: raise Exception("Failed to generate bootstrapping info")