From b1cc775cf3a90145f5f1ea988da064b7cce558b9 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 2 Apr 2022 17:16:51 +0300 Subject: [PATCH] tests: Opportunistic Wireless Encryption - duplicated association attempt Signed-off-by: Jouni Malinen --- tests/hwsim/test_owe.py | 66 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tests/hwsim/test_owe.py b/tests/hwsim/test_owe.py index f72c60682..733c7b422 100644 --- a/tests/hwsim/test_owe.py +++ b/tests/hwsim/test_owe.py @@ -829,6 +829,72 @@ def test_owe_invalid_assoc_resp(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].dump_monitor() +def test_owe_double_assoc(dev, apdev): + """Opportunistic Wireless Encryption - duplicated association attempt""" + if "OWE" not in dev[0].get_capability("key_mgmt"): + raise HwsimSkip("OWE not supported") + params = {"ssid": "owe", + "wpa": "2", + "ieee80211w": "2", + "wpa_key_mgmt": "OWE", + "rsn_pairwise": "CCMP"} + hapd = hostapd.add_ap(apdev[0], params) + bssid = hapd.own_addr() + + dev[0].scan_for_bss(bssid, freq="2412") + + hapd.set("ext_mgmt_frame_handling", "1") + dev[0].connect("owe", key_mgmt="OWE", owe_group="19", ieee80211w="2", + scan_freq="2412", wait_connect=False) + + for i in range(0, 10): + req = hapd.mgmt_rx() + if req is None: + raise Exception("MGMT RX wait timed out") + if req['subtype'] == 11: + break + req = None + if not req: + raise Exception("Authentication frame not received") + hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + binascii.hexlify(req['frame']).decode()) + + for i in range(0, 10): + req = hapd.mgmt_rx() + if req is None: + raise Exception("MGMT RX wait timed out") + if req['subtype'] == 0: + break + req = None + if not req: + raise Exception("Association Request frame not received") + hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + binascii.hexlify(req['frame']).decode()) + + ev = hapd.wait_event(["MGMT-TX-STATUS"], timeout=5) + if ev is None: + raise Exception("Management frame TX status not reported (1)") + if "stype=1 ok=1" not in ev: + raise Exception("Unexpected management frame TX status (1): " + ev) + cmd = "MGMT_TX_STATUS_PROCESS stype=1 ok=0 %s" % (ev.split(' ')[3]) + if "OK" not in hapd.request(cmd): + raise Exception("MGMT_TX_STATUS_PROCESS failed") + + hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + binascii.hexlify(req['frame']).decode()) + + ev = hapd.wait_event(["MGMT-TX-STATUS"], timeout=5) + if ev is None: + raise Exception("Management frame TX status not reported (1)") + if "stype=1 ok=1" not in ev: + raise Exception("Unexpected management frame TX status (1): " + ev) + cmd = "MGMT_TX_STATUS_PROCESS stype=1 ok=1 %s" % (ev.split(' ')[3]) + if "OK" not in hapd.request(cmd): + raise Exception("MGMT_TX_STATUS_PROCESS failed") + + ev = dev[0].wait_event(["PMKSA-CACHE-ADDED"], timeout=5) + if ev is None: + raise Exception("No PMKSA cache entry from OWE added") + + dev[0].wait_connected() + def start_owe(dev, apdev, workaround=0): if "OWE" not in dev[0].get_capability("key_mgmt"): raise HwsimSkip("OWE not supported")