]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: DPP URI supported curves
authorJouni Malinen <quic_jouni@quicinc.com>
Thu, 14 Apr 2022 13:59:15 +0000 (16:59 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 14 Apr 2022 13:59:15 +0000 (16:59 +0300)
Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
tests/hwsim/hostapd.py
tests/hwsim/test_dpp.py
tests/hwsim/wpasupplicant.py

index f1ae8150e2c504639af44c97ed915ae99641e4df..be322c00bdaaffeedb3c92ea369ef160bf4e29d0 100644 (file)
@@ -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")
index 94b9f8207b5848959a48ed5a8f76dafc05915116..523ff3c71c3e5160897a93b0ee23953dc719b5d4 100644 (file)
@@ -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])
index 01193f4d4b1767d23b0d3b12cf31b2242b7b9afb..1c173349f4b71b36dc154dc082818637519710ae 100644 (file)
@@ -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")