From 1ccde13b865f1a0ae33b78c21ebf234ef0d991ea Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 29 Aug 2019 11:52:26 +0300 Subject: [PATCH] tests: Extend ap_pmf_inject_auth coverage for addresses/frames Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_pmf.py | 46 ++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/tests/hwsim/test_ap_pmf.py b/tests/hwsim/test_ap_pmf.py index a825330ab..8b0bafe58 100644 --- a/tests/hwsim/test_ap_pmf.py +++ b/tests/hwsim/test_ap_pmf.py @@ -549,34 +549,62 @@ def test_ap_pmf_inject_auth(dev, apdev): dev[0].connect(ssid, psk="12345678", ieee80211w="2", key_mgmt="WPA-PSK-SHA256", proto="WPA2", scan_freq="2412") + hapd.wait_sta() hwsim_utils.test_connectivity(dev[0], hapd) bssid = hapd.own_addr().replace(':', '') addr = dev[0].own_addr().replace(':', '') # Inject an unprotected Authentication frame claiming to be from the - # associated STA. - auth = "b0003a01" + bssid + addr + bssid + '1000000001000000' + # associated STA, from another STA, from the AP's own address, from all + # zeros and all ones addresses, and from a multicast address. hapd.request("SET ext_mgmt_frame_handling 1") - res = hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % auth) + failed = False + addresses = [ addr, "021122334455", bssid, 6*"00", 6*"ff", 6*"01" ] + for a in addresses: + auth = "b0003a01" + bssid + a + bssid + '1000000001000000' + res = hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % auth) + if "OK" not in res: + failed = True hapd.request("SET ext_mgmt_frame_handling 0") - if "OK" not in res: + if failed: raise Exception("MGMT_RX_PROCESS failed") time.sleep(0.1) + ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.1) + if ev: + raise Exception("Unexpected disconnection reported on the STA") + # Verify that original association is still functional. hwsim_utils.test_connectivity(dev[0], hapd) - # Inject an unprotected Association Request frame claiming to be from the - # associated STA. - auth = "00003a01" + bssid + addr + bssid + '2000' + '31040500' + '0008746573742d706d66' + '010802040b160c121824' + '301a0100000fac040100000fac040100000fac06c0000000000fac06' + # Inject an unprotected Association Request frame (with and without RSNE) + # claiming to be from the set of test addresses. hapd.request("SET ext_mgmt_frame_handling 1") - res = hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % auth) + for a in addresses: + assoc = "00003a01" + bssid + a + bssid + '2000' + '31040500' + '0008746573742d706d66' + '010802040b160c121824' + '301a0100000fac040100000fac040100000fac06c0000000000fac06' + res = hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % assoc) + if "OK" not in res: + failed = True + + assoc = "00003a01" + bssid + a + bssid + '2000' + '31040500' + '0008746573742d706d66' + '010802040b160c121824' + '3000' + res = hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % assoc) + if "OK" not in res: + failed = True + + assoc = "00003a01" + bssid + a + bssid + '2000' + '31040500' + '0008746573742d706d66' + '010802040b160c121824' + res = hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % assoc) + if "OK" not in res: + failed = True hapd.request("SET ext_mgmt_frame_handling 0") - if "OK" not in res: + if failed: raise Exception("MGMT_RX_PROCESS failed") time.sleep(5) + ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.1) + if ev: + raise Exception("Unexpected disconnection reported on the STA") + # Verify that original association is still functional. hwsim_utils.test_connectivity(dev[0], hapd) -- 2.39.2