mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-30 16:54:04 -05:00
tests: WPA2-PSK AP with passphrase only in memory
Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
a52410c29f
commit
53f4ed68ee
@ -68,6 +68,40 @@ def test_ap_wpa2_psk_file(dev, apdev):
|
||||
raise Exception("Timed out while waiting for failure report")
|
||||
dev[1].request("REMOVE_NETWORK all")
|
||||
|
||||
def test_ap_wpa2_psk_mem(dev, apdev):
|
||||
"""WPA2-PSK AP with passphrase only in memory"""
|
||||
try:
|
||||
_test_ap_wpa2_psk_mem(dev, apdev)
|
||||
finally:
|
||||
dev[0].request("SCAN_INTERVAL 5")
|
||||
dev[1].request("SCAN_INTERVAL 5")
|
||||
|
||||
def _test_ap_wpa2_psk_mem(dev, apdev):
|
||||
ssid = "test-wpa2-psk"
|
||||
passphrase = 'qwertyuiop'
|
||||
psk = '602e323e077bc63bd80307ef4745b754b0ae0a925c2638ecd13a794b9527b9e6'
|
||||
params = hostapd.wpa2_params(ssid=ssid)
|
||||
params['wpa_psk'] = psk
|
||||
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
||||
|
||||
dev[0].connect(ssid, mem_only_psk="1", scan_freq="2412", wait_connect=False)
|
||||
dev[0].request("SCAN_INTERVAL 1")
|
||||
ev = dev[0].wait_event(["CTRL-REQ-PSK_PASSPHRASE"], timeout=10)
|
||||
if ev is None:
|
||||
raise Exception("Request for PSK/passphrase timed out")
|
||||
id = ev.split(':')[0].split('-')[-1]
|
||||
dev[0].request("CTRL-RSP-PSK_PASSPHRASE-" + id + ':"' + passphrase + '"')
|
||||
dev[0].wait_connected(timeout=10)
|
||||
|
||||
dev[1].connect(ssid, mem_only_psk="1", scan_freq="2412", wait_connect=False)
|
||||
dev[1].request("SCAN_INTERVAL 1")
|
||||
ev = dev[1].wait_event(["CTRL-REQ-PSK_PASSPHRASE"], timeout=10)
|
||||
if ev is None:
|
||||
raise Exception("Request for PSK/passphrase timed out(2)")
|
||||
id = ev.split(':')[0].split('-')[-1]
|
||||
dev[1].request("CTRL-RSP-PSK_PASSPHRASE-" + id + ':' + psk)
|
||||
dev[1].wait_connected(timeout=10)
|
||||
|
||||
def test_ap_wpa2_ptk_rekey(dev, apdev):
|
||||
"""WPA2-PSK AP and PTK rekey enforced by station"""
|
||||
ssid = "test-wpa2-psk"
|
||||
|
@ -1075,6 +1075,60 @@ def test_dbus_connect(dev, apdev):
|
||||
if not t.success():
|
||||
raise Exception("Expected signals not seen")
|
||||
|
||||
def test_dbus_connect_psk_mem(dev, apdev):
|
||||
"""D-Bus AddNetwork and connect with memory-only PSK"""
|
||||
(bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0])
|
||||
iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE)
|
||||
|
||||
ssid = "test-wpa2-psk"
|
||||
passphrase = 'qwertyuiop'
|
||||
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
|
||||
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
||||
|
||||
class TestDbusConnect(TestDbus):
|
||||
def __init__(self, bus):
|
||||
TestDbus.__init__(self, bus)
|
||||
self.connected = False
|
||||
|
||||
def __enter__(self):
|
||||
gobject.timeout_add(1, self.run_connect)
|
||||
gobject.timeout_add(15000, self.timeout)
|
||||
self.add_signal(self.propertiesChanged, WPAS_DBUS_IFACE,
|
||||
"PropertiesChanged")
|
||||
self.add_signal(self.networkRequest, WPAS_DBUS_IFACE,
|
||||
"NetworkRequest")
|
||||
self.loop.run()
|
||||
return self
|
||||
|
||||
def propertiesChanged(self, properties):
|
||||
logger.debug("propertiesChanged: %s" % str(properties))
|
||||
if 'State' in properties and properties['State'] == "completed":
|
||||
self.connected = True
|
||||
self.loop.quit()
|
||||
|
||||
def networkRequest(self, path, field, txt):
|
||||
logger.debug("networkRequest: %s %s %s" % (path, field, txt))
|
||||
if field == "PSK_PASSPHRASE":
|
||||
iface.NetworkReply(path, field, '"' + passphrase + '"')
|
||||
|
||||
def run_connect(self, *args):
|
||||
logger.debug("run_connect")
|
||||
args = dbus.Dictionary({ 'ssid': ssid,
|
||||
'key_mgmt': 'WPA-PSK',
|
||||
'mem_only_psk': 1,
|
||||
'scan_freq': 2412 },
|
||||
signature='sv')
|
||||
self.netw = iface.AddNetwork(args)
|
||||
iface.SelectNetwork(self.netw)
|
||||
return False
|
||||
|
||||
def success(self):
|
||||
return self.connected
|
||||
|
||||
with TestDbusConnect(bus) as t:
|
||||
if not t.success():
|
||||
raise Exception("Expected signals not seen")
|
||||
|
||||
def test_dbus_connect_oom(dev, apdev):
|
||||
"""D-Bus AddNetwork and connect when out-of-memory"""
|
||||
(bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0])
|
||||
|
@ -838,7 +838,7 @@ class WpaSupplicant:
|
||||
"disable_ht40", "disable_sgi", "disable_ldpc",
|
||||
"ht40_intolerant", "update_identifier", "mac_addr",
|
||||
"erp", "bg_scan_period", "bssid_blacklist",
|
||||
"bssid_whitelist" ]
|
||||
"bssid_whitelist", "mem_only_psk" ]
|
||||
for field in not_quoted:
|
||||
if field in kwargs and kwargs[field]:
|
||||
self.set_network(id, field, kwargs[field])
|
||||
|
Loading…
Reference in New Issue
Block a user