From 98405323774c986de78fba44c3ba899f2cd5d9e6 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 29 Aug 2019 11:52:32 +0300 Subject: [PATCH] tests: PMF and Data frame injection Verify driver/mac80211 behavior for unexpected A2 in Data frames. Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_pmf.py | 42 +++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/test_ap_pmf.py b/tests/hwsim/test_ap_pmf.py index 8b0bafe58..59bbb1384 100644 --- a/tests/hwsim/test_ap_pmf.py +++ b/tests/hwsim/test_ap_pmf.py @@ -5,13 +5,15 @@ # See README for more details. from remotehost import remote_compatible +import binascii import time import logging logger = logging.getLogger() import hwsim_utils import hostapd -from utils import alloc_fail, fail_test, wait_fail_trigger, HwsimSkip +from utils import alloc_fail, fail_test, wait_fail_trigger, HwsimSkip, \ + radiotap_build, start_monitor, stop_monitor from wlantest import Wlantest from wpasupplicant import WpaSupplicant @@ -608,6 +610,44 @@ def test_ap_pmf_inject_auth(dev, apdev): # Verify that original association is still functional. hwsim_utils.test_connectivity(dev[0], hapd) +def test_ap_pmf_inject_data(dev, apdev): + """WPA2-PSK AP with PMF and Data frame injection""" + try: + run_ap_pmf_inject_data(dev, apdev) + finally: + stop_monitor(apdev[1]["ifname"]) + +def run_ap_pmf_inject_data(dev, apdev): + ssid = "test-pmf" + params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678") + params["wpa_key_mgmt"] = "WPA-PSK-SHA256" + params["ieee80211w"] = "2" + hapd = hostapd.add_ap(apdev[0], params) + 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) + + sock = start_monitor(apdev[1]["ifname"]) + radiotap = radiotap_build() + + bssid = hapd.own_addr().replace(':', '') + addr = dev[0].own_addr().replace(':', '') + + # Inject Data frame with A2=broadcast, A2=multicast, A2=BSSID, A2=STA, and + # A2=unknown unicast + addresses = [ 6*"ff", 6*"01", bssid, addr, "020102030405" ] + for a in addresses: + frame = binascii.unhexlify("48010000" + bssid + a + bssid + "0000") + sock.send(radiotap + frame) + + 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") + hwsim_utils.test_connectivity(dev[0], hapd) + def test_ap_pmf_tkip_reject(dev, apdev): """Mixed mode BSS and MFP-enabled AP rejecting TKIP""" params = hostapd.wpa2_params(ssid="test-pmf", passphrase="12345678")