From 368aa0230be71dbdb8d4c3584273dd30c89583e0 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 7 Jul 2024 11:59:16 +0300 Subject: [PATCH] tests: SAE protocol testing - Invalid Rejected Groups element Signed-off-by: Jouni Malinen --- tests/hwsim/test_sae.py | 90 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/tests/hwsim/test_sae.py b/tests/hwsim/test_sae.py index e26bb0a34..c3d02c494 100644 --- a/tests/hwsim/test_sae.py +++ b/tests/hwsim/test_sae.py @@ -2345,6 +2345,96 @@ def test_sae_h2e_rejected_groups_unexpected(dev, apdev): dev[0].set("sae_groups", "") dev[0].set("sae_pwe", "0") +def test_sae_h2e_rejected_groups_invalid(dev, apdev): + """SAE protocol testing - Invalid Rejected Groups element""" + check_sae_capab(dev[0]) + params = hostapd.wpa2_params(ssid="test-sae", + passphrase="12345678") + params['wpa_key_mgmt'] = 'SAE' + params['sae_groups'] = "19 20" + params['sae_pwe'] = "1" + hapd = hostapd.add_ap(apdev[0], params) + + try: + dev[0].set("sae_groups", "20 19") + dev[0].set("sae_pwe", "1") + run_sae_h2e_rejected_groups_invalid(dev[0], hapd) + finally: + dev[0].set("sae_groups", "") + dev[0].set("sae_pwe", "0") + +def run_sae_h2e_rejected_groups_invalid(dev, hapd): + addr = dev.own_addr() + bssid = hapd.own_addr() + + dev.scan_for_bss(bssid, freq=2412) + hapd.set("ext_mgmt_frame_handling", "1") + dev.connect("test-sae", psk="12345678", key_mgmt="SAE", + scan_freq="2412", wait_connect=False) + + logger.info("Commit (group 20)") + for i in range(10): + req = hapd.mgmt_rx() + if req is None: + raise Exception("MGMT RX wait timed out (commit)") + if req['subtype'] == 11: + break + req = None + if not req: + raise Exception("Authentication frame (commit) not received") + group, = struct.unpack('