Browse Source

tests: Verify SAE anti-clogging mechanism

Signed-hostap: Jouni Malinen <j@w1.fi>
Jouni Malinen 11 years ago
parent
commit
a6cf5cd655
2 changed files with 24 additions and 1 deletions
  1. 21 0
      tests/hwsim/test_sae.py
  2. 3 1
      tests/hwsim/wpasupplicant.py

+ 21 - 0
tests/hwsim/test_sae.py

@@ -63,3 +63,24 @@ def test_sae_group_nego(dev, apdev):
                    scan_freq="2412")
     if dev[0].get_status_field('sae_group') != '19':
         raise Exception("Expected SAE group not used")
+
+def test_sae_anti_clogging(dev, apdev):
+    """SAE anti clogging"""
+    params = hostapd.wpa2_params(ssid="test-sae", passphrase="12345678")
+    params['wpa_key_mgmt'] = 'SAE'
+    params['sae_anti_clogging_threshold'] = '1'
+    hostapd.add_ap(apdev[0]['ifname'], params)
+
+    dev[0].request("SET sae_groups ")
+    dev[1].request("SET sae_groups ")
+    id = {}
+    for i in range(0, 2):
+        dev[i].scan(freq="2412")
+        id[i] = dev[i].connect("test-sae", psk="12345678", key_mgmt="SAE",
+                               scan_freq="2412", only_add_network=True)
+    for i in range(0, 2):
+        dev[i].select_network(id[i])
+    for i in range(0, 2):
+        ev = dev[i].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
+        if ev is None:
+            raise Exception("Association with the AP timed out")

+ 3 - 1
tests/hwsim/wpasupplicant.py

@@ -533,7 +533,7 @@ class WpaSupplicant:
                 password=None, phase1=None, phase2=None, ca_cert=None,
                 domain_suffix_match=None, password_hex=None,
                 client_cert=None, private_key=None, peerkey=False,
-                wait_connect=True):
+                wait_connect=True, only_add_network=False):
         logger.info("Connect STA " + self.ifname + " to AP")
         id = self.add_network()
         self.set_network_quoted(id, "ssid", ssid)
@@ -579,6 +579,8 @@ class WpaSupplicant:
                                     domain_suffix_match)
         if peerkey:
             self.set_network(id, "peerkey", "1")
+        if only_add_network:
+            return id
         if wait_connect:
             self.connect_network(id)
         else: