2015-09-01 19:37:52 +02:00
|
|
|
# Test cases for FILS
|
2017-01-31 13:41:24 +01:00
|
|
|
# Copyright (c) 2015-2017, Qualcomm Atheros, Inc.
|
2015-09-01 19:37:52 +02:00
|
|
|
#
|
|
|
|
# This software may be distributed under the terms of the BSD license.
|
|
|
|
# See README for more details.
|
|
|
|
|
2016-12-17 16:26:21 +01:00
|
|
|
import binascii
|
|
|
|
import hashlib
|
2015-09-01 19:37:52 +02:00
|
|
|
import logging
|
|
|
|
logger = logging.getLogger()
|
2017-01-31 13:41:24 +01:00
|
|
|
import os
|
|
|
|
import socket
|
|
|
|
import struct
|
2015-09-01 19:37:52 +02:00
|
|
|
import time
|
|
|
|
|
|
|
|
import hostapd
|
2017-08-25 15:23:56 +02:00
|
|
|
from tshark import run_tshark
|
2015-09-01 19:37:52 +02:00
|
|
|
from wpasupplicant import WpaSupplicant
|
|
|
|
import hwsim_utils
|
2017-02-13 10:09:02 +01:00
|
|
|
from utils import HwsimSkip, alloc_fail
|
2015-09-01 19:37:52 +02:00
|
|
|
from test_erp import check_erp_capa, start_erp_as
|
2017-01-31 13:41:24 +01:00
|
|
|
from test_ap_hs20 import ip_checksum
|
2015-09-01 19:37:52 +02:00
|
|
|
|
|
|
|
def check_fils_capa(dev):
|
|
|
|
capa = dev.get_capability("fils")
|
|
|
|
if capa is None or "FILS" not in capa:
|
|
|
|
raise HwsimSkip("FILS not supported")
|
|
|
|
|
2017-03-13 10:46:59 +01:00
|
|
|
def check_fils_sk_pfs_capa(dev):
|
|
|
|
capa = dev.get_capability("fils")
|
|
|
|
if capa is None or "FILS-SK-PFS" not in capa:
|
|
|
|
raise HwsimSkip("FILS-SK-PFS not supported")
|
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_full_auth(dev, apdev, params):
|
2015-09-01 19:37:52 +02:00
|
|
|
"""FILS SK full authentication"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2015-09-01 19:37:52 +02:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_send_reauth_start'] = '1'
|
|
|
|
params['erp_domain'] = 'example.com'
|
2016-12-17 16:20:32 +01:00
|
|
|
params['fils_realm'] = 'example.com'
|
2015-09-01 19:37:52 +02:00
|
|
|
params['wpa_group_rekey'] = '1'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
bss = dev[0].get_bss(bssid)
|
|
|
|
logger.debug("BSS: " + str(bss))
|
|
|
|
if "[FILS]" not in bss['flags']:
|
|
|
|
raise Exception("[FILS] flag not indicated")
|
|
|
|
if "[WPA2-FILS-SHA256-CCMP]" not in bss['flags']:
|
|
|
|
raise Exception("[WPA2-FILS-SHA256-CCMP] flag not indicated")
|
|
|
|
|
|
|
|
res = dev[0].request("SCAN_RESULTS")
|
|
|
|
logger.debug("SCAN_RESULTS: " + res)
|
|
|
|
if "[FILS]" not in res:
|
|
|
|
raise Exception("[FILS] flag not indicated")
|
|
|
|
if "[WPA2-FILS-SHA256-CCMP]" not in res:
|
|
|
|
raise Exception("[WPA2-FILS-SHA256-CCMP] flag not indicated")
|
|
|
|
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("GTK rekey timed out")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
2016-12-27 18:24:34 +01:00
|
|
|
conf = hapd.get_config()
|
|
|
|
if conf['key_mgmt'] != 'FILS-SHA256':
|
|
|
|
raise Exception("Unexpected config key_mgmt: " + conf['key_mgmt'])
|
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_sha384_full_auth(dev, apdev, params):
|
2015-09-01 19:37:52 +02:00
|
|
|
"""FILS SK full authentication (SHA384)"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2015-09-01 19:37:52 +02:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA384"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_send_reauth_start'] = '1'
|
|
|
|
params['erp_domain'] = 'example.com'
|
2016-12-17 16:20:32 +01:00
|
|
|
params['fils_realm'] = 'example.com'
|
2015-09-01 19:37:52 +02:00
|
|
|
params['wpa_group_rekey'] = '1'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
bss = dev[0].get_bss(bssid)
|
|
|
|
logger.debug("BSS: " + str(bss))
|
|
|
|
if "[FILS]" not in bss['flags']:
|
|
|
|
raise Exception("[FILS] flag not indicated")
|
|
|
|
if "[WPA2-FILS-SHA384-CCMP]" not in bss['flags']:
|
|
|
|
raise Exception("[WPA2-FILS-SHA384-CCMP] flag not indicated")
|
|
|
|
|
|
|
|
res = dev[0].request("SCAN_RESULTS")
|
|
|
|
logger.debug("SCAN_RESULTS: " + res)
|
|
|
|
if "[FILS]" not in res:
|
|
|
|
raise Exception("[FILS] flag not indicated")
|
|
|
|
if "[WPA2-FILS-SHA384-CCMP]" not in res:
|
|
|
|
raise Exception("[WPA2-FILS-SHA384-CCMP] flag not indicated")
|
|
|
|
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
dev[0].connect("fils", key_mgmt="FILS-SHA384",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("GTK rekey timed out")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
2016-12-27 18:24:34 +01:00
|
|
|
conf = hapd.get_config()
|
|
|
|
if conf['key_mgmt'] != 'FILS-SHA384':
|
|
|
|
raise Exception("Unexpected config key_mgmt: " + conf['key_mgmt'])
|
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_pmksa_caching(dev, apdev, params):
|
2015-09-01 19:37:52 +02:00
|
|
|
"""FILS SK and PMKSA caching"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2015-09-01 19:37:52 +02:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
2016-12-17 16:20:32 +01:00
|
|
|
params['fils_realm'] = 'example.com'
|
2015-09-01 19:37:52 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
pmksa = dev[0].get_pmksa(bssid)
|
|
|
|
if pmksa is None:
|
|
|
|
raise Exception("No PMKSA cache entry created")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
2018-08-06 21:46:40 +02:00
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using PMKSA caching timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
pmksa2 = dev[0].get_pmksa(bssid)
|
|
|
|
if pmksa2 is None:
|
|
|
|
raise Exception("No PMKSA cache entry found")
|
|
|
|
if pmksa['pmkid'] != pmksa2['pmkid']:
|
|
|
|
raise Exception("Unexpected PMKID change")
|
|
|
|
|
|
|
|
# Verify EAPOL reauthentication after FILS authentication
|
|
|
|
hapd.request("EAPOL_REAUTH " + dev[0].own_addr())
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("EAP authentication did not start")
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("EAP authentication did not succeed")
|
|
|
|
time.sleep(0.1)
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
def test_fils_sk_pmksa_caching_ocv(dev, apdev, params):
|
|
|
|
"""FILS SK and PMKSA caching with OCV"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2018-08-06 21:46:40 +02:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['ieee80211w'] = '1'
|
|
|
|
params['ocv'] = '1'
|
|
|
|
try:
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
2019-01-24 08:45:41 +01:00
|
|
|
except Exception as e:
|
2018-08-06 21:46:40 +02:00
|
|
|
if "Failed to set hostapd parameter ocv" in str(e):
|
|
|
|
raise HwsimSkip("OCV not supported")
|
|
|
|
raise
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412", ieee80211w="1", ocv="1")
|
|
|
|
pmksa = dev[0].get_pmksa(bssid)
|
|
|
|
if pmksa is None:
|
|
|
|
raise Exception("No PMKSA cache entry created")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
2015-09-01 19:37:52 +02:00
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using PMKSA caching timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
pmksa2 = dev[0].get_pmksa(bssid)
|
|
|
|
if pmksa2 is None:
|
|
|
|
raise Exception("No PMKSA cache entry found")
|
|
|
|
if pmksa['pmkid'] != pmksa2['pmkid']:
|
|
|
|
raise Exception("Unexpected PMKID change")
|
|
|
|
|
|
|
|
# Verify EAPOL reauthentication after FILS authentication
|
|
|
|
hapd.request("EAPOL_REAUTH " + dev[0].own_addr())
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("EAP authentication did not start")
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("EAP authentication did not succeed")
|
|
|
|
time.sleep(0.1)
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
2017-02-21 11:21:45 +01:00
|
|
|
def test_fils_sk_pmksa_caching_and_cache_id(dev, apdev):
|
|
|
|
"""FILS SK and PMKSA caching with Cache Identifier"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['fils_cache_id'] = "abcd"
|
|
|
|
params["radius_server_clients"] = "auth_serv/radius_clients.conf"
|
|
|
|
params["radius_server_auth_port"] = '18128'
|
|
|
|
params["eap_server"] = "1"
|
|
|
|
params["eap_user_file"] = "auth_serv/eap_user.conf"
|
|
|
|
params["ca_cert"] = "auth_serv/ca.pem"
|
|
|
|
params["server_cert"] = "auth_serv/server.pem"
|
|
|
|
params["private_key"] = "auth_serv/server.key"
|
|
|
|
params["eap_sim_db"] = "unix:/tmp/hlr_auc_gw.sock"
|
|
|
|
params["dh_file"] = "auth_serv/dh.conf"
|
|
|
|
params["pac_opaque_encr_key"] = "000102030405060708090a0b0c0d0e0f"
|
|
|
|
params["eap_fast_a_id"] = "101112131415161718191a1b1c1d1e1f"
|
|
|
|
params["eap_fast_a_id_info"] = "test server"
|
|
|
|
params["eap_server_erp"] = "1"
|
|
|
|
params["erp_domain"] = "example.com"
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
res = dev[0].request("PMKSA")
|
|
|
|
if "FILS Cache Identifier" not in res:
|
|
|
|
raise Exception("PMKSA list does not include FILS Cache Identifier")
|
|
|
|
pmksa = dev[0].get_pmksa(bssid)
|
|
|
|
if pmksa is None:
|
|
|
|
raise Exception("No PMKSA cache entry created")
|
|
|
|
if "cache_id" not in pmksa:
|
|
|
|
raise Exception("No FILS Cache Identifier listed")
|
|
|
|
if pmksa["cache_id"] != "abcd":
|
|
|
|
raise Exception("The configured FILS Cache Identifier not seen in PMKSA")
|
|
|
|
|
|
|
|
bssid2 = apdev[1]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['fils_cache_id'] = "abcd"
|
|
|
|
hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid2, freq=2412)
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
if "OK" not in dev[0].request("ROAM " + bssid2):
|
|
|
|
raise Exception("ROAM failed")
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using PMKSA caching timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if bssid2 not in ev:
|
|
|
|
raise Exception("Failed to connect to the second AP")
|
|
|
|
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd2)
|
|
|
|
pmksa2 = dev[0].get_pmksa(bssid2)
|
|
|
|
if pmksa2:
|
|
|
|
raise Exception("Unexpected extra PMKSA cache added")
|
|
|
|
pmksa2 = dev[0].get_pmksa(bssid)
|
|
|
|
if not pmksa2:
|
|
|
|
raise Exception("Original PMKSA cache entry removed")
|
|
|
|
if pmksa['pmkid'] != pmksa2['pmkid']:
|
|
|
|
raise Exception("Unexpected PMKID change")
|
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_pmksa_caching_ctrl_ext(dev, apdev, params):
|
2017-02-21 15:28:37 +01:00
|
|
|
"""FILS SK and PMKSA caching with Cache Identifier and external management"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
hapd_as = start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-02-21 15:28:37 +01:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA384"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_send_reauth_start'] = '1'
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['fils_cache_id'] = "ffee"
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA384",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
res1 = dev[0].request("PMKSA_GET %d" % id)
|
|
|
|
logger.info("PMKSA_GET: " + res1)
|
|
|
|
if "UNKNOWN COMMAND" in res1:
|
|
|
|
raise HwsimSkip("PMKSA_GET not supported in the build")
|
|
|
|
if bssid not in res1:
|
|
|
|
raise Exception("PMKSA cache entry missing")
|
|
|
|
if "ffee" not in res1:
|
|
|
|
raise Exception("FILS Cache Identifier not seen in PMKSA cache entry")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
hapd_as.disable()
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("PMKSA_FLUSH")
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
for entry in res1.splitlines():
|
|
|
|
if "OK" not in dev[0].request("PMKSA_ADD %d %s" % (id, entry)):
|
|
|
|
raise Exception("Failed to add PMKSA entry")
|
|
|
|
|
|
|
|
bssid2 = apdev[1]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA384"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_send_reauth_start'] = '1'
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['fils_cache_id'] = "ffee"
|
|
|
|
hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid2, freq=2412)
|
|
|
|
dev[0].set_network(id, "bssid", bssid2)
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_connected()
|
|
|
|
if bssid2 not in ev:
|
|
|
|
raise Exception("Unexpected BSS selected")
|
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_erp(dev, apdev, params):
|
2015-09-01 19:37:52 +02:00
|
|
|
"""FILS SK using ERP"""
|
2017-09-05 18:12:29 +02:00
|
|
|
run_fils_sk_erp(dev, apdev, "FILS-SHA256", params)
|
2016-12-26 13:50:28 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_erp_sha384(dev, apdev, params):
|
2016-12-26 13:50:28 +01:00
|
|
|
"""FILS SK using ERP and SHA384"""
|
2017-09-05 18:12:29 +02:00
|
|
|
run_fils_sk_erp(dev, apdev, "FILS-SHA384", params)
|
2016-12-26 13:50:28 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def run_fils_sk_erp(dev, apdev, key_mgmt, params):
|
2015-09-01 19:37:52 +02:00
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2015-09-01 19:37:52 +02:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
2016-12-26 13:50:28 +01:00
|
|
|
params['wpa_key_mgmt'] = key_mgmt
|
2015-09-01 19:37:52 +02:00
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
2016-12-17 16:20:32 +01:00
|
|
|
params['fils_realm'] = 'example.com'
|
2015-09-01 19:37:52 +02:00
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
2016-12-26 13:50:28 +01:00
|
|
|
id = dev[0].connect("fils", key_mgmt=key_mgmt,
|
2015-09-01 19:37:52 +02:00
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using FILS/ERP timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if "EVENT-ASSOC-REJECT" in ev:
|
|
|
|
raise Exception("Association failed")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2016-12-17 16:26:21 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_erp_followed_by_pmksa_caching(dev, apdev, params):
|
2018-08-23 11:11:44 +02:00
|
|
|
"""FILS SK ERP following by PMKSA caching"""
|
2017-07-05 16:55:10 +02:00
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-07-05 16:55:10 +02:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
# Force the second connection to use ERP by deleting the PMKSA entry.
|
|
|
|
dev[0].request("PMKSA_FLUSH")
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using FILS/ERP timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if "EVENT-ASSOC-REJECT" in ev:
|
|
|
|
raise Exception("Association failed")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
pmksa = dev[0].get_pmksa(bssid)
|
|
|
|
if pmksa is None:
|
|
|
|
raise Exception("No PMKSA cache entry created")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
# The third connection is expected to use PMKSA caching for FILS
|
|
|
|
# authentication.
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using PMKSA caching timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if "EVENT-ASSOC-REJECT" in ev:
|
|
|
|
raise Exception("Association failed")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
pmksa2 = dev[0].get_pmksa(bssid)
|
|
|
|
if pmksa2 is None:
|
|
|
|
raise Exception("No PMKSA cache entry found")
|
|
|
|
if pmksa['pmkid'] != pmksa2['pmkid']:
|
|
|
|
raise Exception("Unexpected PMKID change")
|
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_erp_another_ssid(dev, apdev, params):
|
2017-01-29 13:24:47 +01:00
|
|
|
"""FILS SK using ERP and roam to another SSID"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-01-29 13:24:47 +01:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
hapd.disable()
|
|
|
|
dev[0].flush_scan_cache()
|
|
|
|
if "FAIL" in dev[0].request("PMKSA_FLUSH"):
|
|
|
|
raise Exception("PMKSA_FLUSH failed")
|
|
|
|
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils2")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
id = dev[0].connect("fils2", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412", wait_connect=False)
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using FILS/ERP timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if "EVENT-ASSOC-REJECT" in ev:
|
|
|
|
raise Exception("Association failed")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_multiple_realms(dev, apdev, params):
|
2016-12-17 16:26:21 +01:00
|
|
|
"""FILS SK and multiple realms"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2016-12-17 16:26:21 +01:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
2019-03-15 11:10:37 +01:00
|
|
|
fils_realms = ['r1.example.org', 'r2.EXAMPLE.org', 'r3.example.org',
|
|
|
|
'r4.example.org', 'r5.example.org', 'r6.example.org',
|
|
|
|
'r7.example.org', 'r8.example.org',
|
|
|
|
'example.com',
|
|
|
|
'r9.example.org', 'r10.example.org', 'r11.example.org',
|
|
|
|
'r12.example.org', 'r13.example.org', 'r14.example.org',
|
|
|
|
'r15.example.org', 'r16.example.org']
|
2016-12-17 16:26:21 +01:00
|
|
|
params['fils_realm'] = fils_realms
|
|
|
|
params['fils_cache_id'] = "1234"
|
|
|
|
params['hessid'] = bssid
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
|
|
|
|
if "OK" not in dev[0].request("ANQP_GET " + bssid + " 275"):
|
|
|
|
raise Exception("ANQP_GET command failed")
|
|
|
|
ev = dev[0].wait_event(["GAS-QUERY-DONE"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("GAS query timed out")
|
|
|
|
bss = dev[0].get_bss(bssid)
|
|
|
|
|
|
|
|
if 'fils_info' not in bss:
|
|
|
|
raise Exception("FILS Indication element information missing")
|
|
|
|
if bss['fils_info'] != '02b8':
|
|
|
|
raise Exception("Unexpected FILS Information: " + bss['fils_info'])
|
|
|
|
|
|
|
|
if 'fils_cache_id' not in bss:
|
|
|
|
raise Exception("FILS Cache Identifier missing")
|
|
|
|
if bss['fils_cache_id'] != '1234':
|
|
|
|
raise Exception("Unexpected FILS Cache Identifier: " + bss['fils_cache_id'])
|
|
|
|
|
|
|
|
if 'fils_realms' not in bss:
|
|
|
|
raise Exception("FILS Realm Identifiers missing")
|
|
|
|
expected = ''
|
|
|
|
count = 0
|
|
|
|
for realm in fils_realms:
|
2019-02-02 15:25:57 +01:00
|
|
|
hash = hashlib.sha256(realm.lower().encode()).digest()
|
2019-02-02 12:01:36 +01:00
|
|
|
expected += binascii.hexlify(hash[0:2]).decode()
|
2016-12-17 16:26:21 +01:00
|
|
|
count += 1
|
|
|
|
if count == 7:
|
|
|
|
break
|
|
|
|
if bss['fils_realms'] != expected:
|
|
|
|
raise Exception("Unexpected FILS Realm Identifiers: " + bss['fils_realms'])
|
|
|
|
|
|
|
|
if 'anqp_fils_realm_info' not in bss:
|
|
|
|
raise Exception("FILS Realm Information ANQP-element not seen")
|
2019-02-02 11:10:53 +01:00
|
|
|
info = bss['anqp_fils_realm_info']
|
2016-12-17 16:26:21 +01:00
|
|
|
expected = ''
|
|
|
|
for realm in fils_realms:
|
2019-02-02 15:25:57 +01:00
|
|
|
hash = hashlib.sha256(realm.lower().encode()).digest()
|
2019-02-02 12:01:36 +01:00
|
|
|
expected += binascii.hexlify(hash[0:2]).decode()
|
2016-12-17 16:26:21 +01:00
|
|
|
if info != expected:
|
|
|
|
raise Exception("Unexpected FILS Realm Info ANQP-element: " + info)
|
|
|
|
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using FILS/ERP timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if "EVENT-ASSOC-REJECT" in ev:
|
|
|
|
raise Exception("Association failed")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2017-01-29 13:11:43 +01:00
|
|
|
|
2017-01-31 13:41:24 +01:00
|
|
|
# DHCP message op codes
|
2019-03-15 11:10:37 +01:00
|
|
|
BOOTREQUEST = 1
|
|
|
|
BOOTREPLY = 2
|
|
|
|
|
|
|
|
OPT_PAD = 0
|
|
|
|
OPT_DHCP_MESSAGE_TYPE = 53
|
|
|
|
OPT_RAPID_COMMIT = 80
|
|
|
|
OPT_END = 255
|
|
|
|
|
|
|
|
DHCPDISCOVER = 1
|
|
|
|
DHCPOFFER = 2
|
|
|
|
DHCPREQUEST = 3
|
|
|
|
DHCPDECLINE = 4
|
|
|
|
DHCPACK = 5
|
|
|
|
DHCPNAK = 6
|
|
|
|
DHCPRELEASE = 7
|
|
|
|
DHCPINFORM = 8
|
2017-01-31 13:41:24 +01:00
|
|
|
|
|
|
|
def build_dhcp(req, dhcp_msg, chaddr, giaddr="0.0.0.0",
|
|
|
|
ip_src="0.0.0.0", ip_dst="255.255.255.255",
|
2017-02-13 10:51:25 +01:00
|
|
|
rapid_commit=True, override_op=None, magic_override=None,
|
|
|
|
opt_end=True, extra_op=None):
|
2019-02-02 16:52:25 +01:00
|
|
|
proto = b'\x08\x00' # IPv4
|
2017-01-31 13:41:24 +01:00
|
|
|
_ip_src = socket.inet_pton(socket.AF_INET, ip_src)
|
|
|
|
_ip_dst = socket.inet_pton(socket.AF_INET, ip_dst)
|
|
|
|
|
2019-02-02 16:52:25 +01:00
|
|
|
_ciaddr = b'\x00\x00\x00\x00'
|
|
|
|
_yiaddr = b'\x00\x00\x00\x00'
|
|
|
|
_siaddr = b'\x00\x00\x00\x00'
|
2017-01-31 13:41:24 +01:00
|
|
|
_giaddr = socket.inet_pton(socket.AF_INET, giaddr)
|
2019-03-15 11:10:37 +01:00
|
|
|
_chaddr = binascii.unhexlify(chaddr.replace(':', '')) + 10 * b'\x00'
|
2017-01-31 13:41:24 +01:00
|
|
|
htype = 1 # Hardware address type; 1 = Ethernet
|
|
|
|
hlen = 6 # Hardware address length
|
|
|
|
hops = 0
|
|
|
|
xid = 123456
|
|
|
|
secs = 0
|
|
|
|
flags = 0
|
|
|
|
if req:
|
|
|
|
op = BOOTREQUEST
|
|
|
|
src_port = 68
|
|
|
|
dst_port = 67
|
|
|
|
else:
|
|
|
|
op = BOOTREPLY
|
|
|
|
src_port = 67
|
|
|
|
dst_port = 68
|
2017-02-13 10:51:25 +01:00
|
|
|
if override_op is not None:
|
|
|
|
op = override_op
|
2017-01-31 13:41:24 +01:00
|
|
|
payload = struct.pack('>BBBBLHH', op, htype, hlen, hops, xid, secs, flags)
|
2019-02-02 16:52:25 +01:00
|
|
|
sname = 64*b'\x00'
|
|
|
|
file = 128*b'\x00'
|
2017-01-31 13:41:24 +01:00
|
|
|
payload += _ciaddr + _yiaddr + _siaddr + _giaddr + _chaddr + sname + file
|
|
|
|
# magic - DHCP
|
2017-02-13 10:51:25 +01:00
|
|
|
if magic_override is not None:
|
|
|
|
payload += magic_override
|
|
|
|
else:
|
2019-02-02 16:52:25 +01:00
|
|
|
payload += b'\x63\x82\x53\x63'
|
2017-01-31 13:41:24 +01:00
|
|
|
# Option: DHCP Message Type
|
2017-02-13 10:51:25 +01:00
|
|
|
if dhcp_msg is not None:
|
|
|
|
payload += struct.pack('BBB', OPT_DHCP_MESSAGE_TYPE, 1, dhcp_msg)
|
2017-01-31 13:41:24 +01:00
|
|
|
if rapid_commit:
|
|
|
|
# Option: Rapid Commit
|
|
|
|
payload += struct.pack('BB', OPT_RAPID_COMMIT, 0)
|
2017-02-13 10:51:25 +01:00
|
|
|
if extra_op:
|
|
|
|
payload += extra_op
|
2017-01-31 13:41:24 +01:00
|
|
|
# End Option
|
2017-02-13 10:51:25 +01:00
|
|
|
if opt_end:
|
|
|
|
payload += struct.pack('B', OPT_END)
|
2017-01-31 13:41:24 +01:00
|
|
|
|
|
|
|
udp = struct.pack('>HHHH', src_port, dst_port,
|
|
|
|
8 + len(payload), 0) + payload
|
|
|
|
|
|
|
|
tot_len = 20 + len(udp)
|
|
|
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
2019-02-02 16:52:25 +01:00
|
|
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
2017-01-31 13:41:24 +01:00
|
|
|
csum = ip_checksum(ipv4)
|
|
|
|
ipv4 = start + csum + _ip_src + _ip_dst
|
|
|
|
|
|
|
|
return proto + ipv4 + udp
|
|
|
|
|
2017-02-13 09:56:01 +01:00
|
|
|
def fils_hlp_config(fils_hlp_wait_time=10000):
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
params['own_ip_addr'] = '127.0.0.3'
|
|
|
|
params['dhcp_server'] = '127.0.0.2'
|
|
|
|
params['fils_hlp_wait_time'] = str(fils_hlp_wait_time)
|
|
|
|
return params
|
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_hlp(dev, apdev, params):
|
2017-01-31 13:41:24 +01:00
|
|
|
"""FILS SK HLP (rapid commit server)"""
|
2017-09-05 18:12:29 +02:00
|
|
|
run_fils_sk_hlp(dev, apdev, True, params)
|
2017-01-31 13:41:24 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_hlp_no_rapid_commit(dev, apdev, params):
|
2017-01-31 13:41:24 +01:00
|
|
|
"""FILS SK HLP (no rapid commit server)"""
|
2017-09-05 18:12:29 +02:00
|
|
|
run_fils_sk_hlp(dev, apdev, False, params)
|
2017-01-31 13:41:24 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def run_fils_sk_hlp(dev, apdev, rapid_commit_server, params):
|
2017-01-29 13:11:43 +01:00
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-01-29 13:11:43 +01:00
|
|
|
|
2017-01-31 13:41:24 +01:00
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
|
2017-02-16 19:58:07 +01:00
|
|
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
2017-01-31 13:41:24 +01:00
|
|
|
sock.settimeout(5)
|
|
|
|
sock.bind(("127.0.0.2", 67))
|
|
|
|
|
2017-01-29 13:11:43 +01:00
|
|
|
bssid = apdev[0]['bssid']
|
2017-02-13 09:56:01 +01:00
|
|
|
params = fils_hlp_config()
|
2017-01-31 13:41:24 +01:00
|
|
|
params['fils_hlp_wait_time'] = '10000'
|
|
|
|
if not rapid_commit_server:
|
|
|
|
params['dhcp_rapid_commit_proxy'] = '1'
|
2017-01-29 13:11:43 +01:00
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
if "OK" not in dev[0].request("FILS_HLP_REQ_FLUSH"):
|
|
|
|
raise Exception("Failed to flush pending FILS HLP requests")
|
2019-03-15 11:10:37 +01:00
|
|
|
tests = ["",
|
|
|
|
"q",
|
|
|
|
"ff:ff:ff:ff:ff:ff",
|
|
|
|
"ff:ff:ff:ff:ff:ff q"]
|
2017-01-29 13:11:43 +01:00
|
|
|
for t in tests:
|
|
|
|
if "FAIL" not in dev[0].request("FILS_HLP_REQ_ADD " + t):
|
|
|
|
raise Exception("Invalid FILS_HLP_REQ_ADD accepted: " + t)
|
2017-01-31 13:41:24 +01:00
|
|
|
dhcpdisc = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
|
|
|
chaddr=dev[0].own_addr())
|
2019-03-15 11:10:37 +01:00
|
|
|
tests = ["ff:ff:ff:ff:ff:ff aabb",
|
|
|
|
"ff:ff:ff:ff:ff:ff " + 255*'cc',
|
|
|
|
hapd.own_addr() + " ddee010203040506070809",
|
|
|
|
"ff:ff:ff:ff:ff:ff " + binascii.hexlify(dhcpdisc).decode()]
|
2017-01-29 13:11:43 +01:00
|
|
|
for t in tests:
|
|
|
|
if "OK" not in dev[0].request("FILS_HLP_REQ_ADD " + t):
|
|
|
|
raise Exception("FILS_HLP_REQ_ADD failed: " + t)
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
2017-01-31 13:41:24 +01:00
|
|
|
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-01-31 13:41:24 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
if rapid_commit_server:
|
|
|
|
# TODO: Proper rapid commit response
|
|
|
|
dhcpdisc = build_dhcp(req=False, dhcp_msg=DHCPACK,
|
|
|
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3")
|
|
|
|
sock.sendto(dhcpdisc[2+20+8:], addr)
|
|
|
|
else:
|
|
|
|
dhcpdisc = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
|
|
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3")
|
|
|
|
sock.sendto(dhcpdisc[2+20+8:], addr)
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-01-31 13:41:24 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
dhcpdisc = build_dhcp(req=False, dhcp_msg=DHCPACK, rapid_commit=False,
|
|
|
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3")
|
|
|
|
sock.sendto(dhcpdisc[2+20+8:], addr)
|
|
|
|
ev = dev[0].wait_event(["FILS-HLP-RX"], timeout=10)
|
2017-01-29 13:11:43 +01:00
|
|
|
if ev is None:
|
2017-01-31 13:41:24 +01:00
|
|
|
raise Exception("FILS HLP response not reported")
|
|
|
|
vals = ev.split(' ')
|
|
|
|
frame = binascii.unhexlify(vals[3].split('=')[1])
|
|
|
|
proto, = struct.unpack('>H', frame[0:2])
|
|
|
|
if proto != 0x0800:
|
|
|
|
raise Exception("Unexpected ethertype in HLP response: %d" % proto)
|
|
|
|
frame = frame[2:]
|
|
|
|
ip = frame[0:20]
|
2019-02-02 16:52:25 +01:00
|
|
|
if ip_checksum(ip) != b'\x00\x00':
|
2017-01-31 13:41:24 +01:00
|
|
|
raise Exception("IP header checksum mismatch in HLP response")
|
|
|
|
frame = frame[20:]
|
|
|
|
udp = frame[0:8]
|
|
|
|
frame = frame[8:]
|
|
|
|
sport, dport, ulen, ucheck = struct.unpack('>HHHH', udp)
|
|
|
|
if sport != 67 or dport != 68:
|
|
|
|
raise Exception("Unexpected UDP port in HLP response")
|
|
|
|
dhcp = frame[0:28]
|
|
|
|
frame = frame[28:]
|
2019-03-15 11:10:37 +01:00
|
|
|
op, htype, hlen, hops, xid, secs, flags, ciaddr, yiaddr, siaddr, giaddr = struct.unpack('>4BL2H4L', dhcp)
|
2017-01-31 13:41:24 +01:00
|
|
|
chaddr = frame[0:16]
|
|
|
|
frame = frame[16:]
|
|
|
|
sname = frame[0:64]
|
|
|
|
frame = frame[64:]
|
|
|
|
file = frame[0:128]
|
|
|
|
frame = frame[128:]
|
|
|
|
options = frame
|
2019-02-02 16:52:25 +01:00
|
|
|
if options[0:4] != b'\x63\x82\x53\x63':
|
2017-01-31 13:41:24 +01:00
|
|
|
raise Exception("No DHCP magic seen in HLP response")
|
|
|
|
options = options[4:]
|
|
|
|
# TODO: fully parse and validate DHCPACK options
|
|
|
|
if struct.pack('BBB', OPT_DHCP_MESSAGE_TYPE, 1, DHCPACK) not in options:
|
|
|
|
raise Exception("DHCPACK not in HLP response")
|
|
|
|
|
|
|
|
dev[0].wait_connected()
|
2017-01-29 13:11:43 +01:00
|
|
|
|
|
|
|
dev[0].request("FILS_HLP_REQ_FLUSH")
|
2017-01-31 13:41:24 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_hlp_timeout(dev, apdev, params):
|
2017-02-13 09:56:01 +01:00
|
|
|
"""FILS SK HLP (rapid commit server timeout)"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-02-13 09:56:01 +01:00
|
|
|
|
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
|
2017-02-16 19:58:07 +01:00
|
|
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
2017-02-13 09:56:01 +01:00
|
|
|
sock.settimeout(5)
|
|
|
|
sock.bind(("127.0.0.2", 67))
|
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = fils_hlp_config(fils_hlp_wait_time=30)
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
if "OK" not in dev[0].request("FILS_HLP_REQ_FLUSH"):
|
|
|
|
raise Exception("Failed to flush pending FILS HLP requests")
|
|
|
|
dhcpdisc = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
|
|
|
chaddr=dev[0].own_addr())
|
2019-02-02 12:01:36 +01:00
|
|
|
if "OK" not in dev[0].request("FILS_HLP_REQ_ADD " + "ff:ff:ff:ff:ff:ff " + binascii.hexlify(dhcpdisc).decode()):
|
2017-02-13 09:56:01 +01:00
|
|
|
raise Exception("FILS_HLP_REQ_ADD failed")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-02-13 09:56:01 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
# Wait for HLP wait timeout to hit
|
|
|
|
# FILS: HLP response timeout - continue with association response
|
|
|
|
dev[0].wait_connected()
|
|
|
|
|
|
|
|
dev[0].request("FILS_HLP_REQ_FLUSH")
|
2017-02-13 10:09:02 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_hlp_oom(dev, apdev, params):
|
2017-02-13 10:09:02 +01:00
|
|
|
"""FILS SK HLP and hostapd OOM"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-02-13 10:09:02 +01:00
|
|
|
|
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
|
2017-02-16 19:58:07 +01:00
|
|
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
2017-02-13 10:09:02 +01:00
|
|
|
sock.settimeout(5)
|
|
|
|
sock.bind(("127.0.0.2", 67))
|
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = fils_hlp_config(fils_hlp_wait_time=500)
|
|
|
|
params['dhcp_rapid_commit_proxy'] = '1'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
if "OK" not in dev[0].request("FILS_HLP_REQ_FLUSH"):
|
|
|
|
raise Exception("Failed to flush pending FILS HLP requests")
|
|
|
|
dhcpdisc = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
|
|
|
chaddr=dev[0].own_addr())
|
2019-02-02 12:01:36 +01:00
|
|
|
if "OK" not in dev[0].request("FILS_HLP_REQ_ADD " + "ff:ff:ff:ff:ff:ff " + binascii.hexlify(dhcpdisc).decode()):
|
2017-02-13 10:09:02 +01:00
|
|
|
raise Exception("FILS_HLP_REQ_ADD failed")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
with alloc_fail(hapd, 1, "fils_process_hlp"):
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
with alloc_fail(hapd, 1, "fils_process_hlp_dhcp"):
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
with alloc_fail(hapd, 1, "wpabuf_alloc;fils_process_hlp_dhcp"):
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
with alloc_fail(hapd, 1, "wpabuf_alloc;fils_dhcp_handler"):
|
|
|
|
dev[0].select_network(id, freq=2412)
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-02-13 10:09:02 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
dhcpdisc = build_dhcp(req=False, dhcp_msg=DHCPACK,
|
|
|
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3")
|
|
|
|
sock.sendto(dhcpdisc[2+20+8:], addr)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
with alloc_fail(hapd, 1, "wpabuf_resize;fils_dhcp_handler"):
|
|
|
|
dev[0].select_network(id, freq=2412)
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-02-13 10:09:02 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
dhcpdisc = build_dhcp(req=False, dhcp_msg=DHCPACK,
|
|
|
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3")
|
|
|
|
sock.sendto(dhcpdisc[2+20+8:], addr)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-02-13 10:09:02 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
|
|
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3")
|
|
|
|
with alloc_fail(hapd, 1, "wpabuf_resize;fils_dhcp_request"):
|
|
|
|
sock.sendto(dhcpoffer[2+20+8:], addr)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].request("FILS_HLP_REQ_FLUSH")
|
2017-02-13 10:51:25 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_hlp_req_parsing(dev, apdev, params):
|
2017-02-13 10:51:25 +01:00
|
|
|
"""FILS SK HLP request parsing"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-02-13 10:51:25 +01:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = fils_hlp_config(fils_hlp_wait_time=30)
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
if "OK" not in dev[0].request("FILS_HLP_REQ_FLUSH"):
|
|
|
|
raise Exception("Failed to flush pending FILS HLP requests")
|
|
|
|
|
|
|
|
tot_len = 20 + 1
|
|
|
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
2019-02-02 16:52:25 +01:00
|
|
|
_ip_src = b'\x00\x00\x00\x00'
|
|
|
|
_ip_dst = b'\x00\x00\x00\x00'
|
|
|
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
2017-02-13 10:51:25 +01:00
|
|
|
csum = ip_checksum(ipv4)
|
|
|
|
ipv4_overflow = start + csum + _ip_src + _ip_dst
|
|
|
|
|
|
|
|
tot_len = 20
|
|
|
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 123)
|
2019-02-02 16:52:25 +01:00
|
|
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
2017-02-13 10:51:25 +01:00
|
|
|
csum = ip_checksum(ipv4)
|
|
|
|
ipv4_unknown_proto = start + csum + _ip_src + _ip_dst
|
|
|
|
|
|
|
|
tot_len = 20
|
|
|
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
2019-02-02 16:52:25 +01:00
|
|
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
2017-02-13 10:51:25 +01:00
|
|
|
csum = ip_checksum(ipv4)
|
|
|
|
ipv4_missing_udp_hdr = start + csum + _ip_src + _ip_dst
|
|
|
|
|
|
|
|
src_port = 68
|
|
|
|
dst_port = 67
|
|
|
|
udp = struct.pack('>HHHH', src_port, dst_port, 8 + 1, 0)
|
|
|
|
tot_len = 20 + len(udp)
|
|
|
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
2019-02-02 16:52:25 +01:00
|
|
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
2017-02-13 10:51:25 +01:00
|
|
|
csum = ip_checksum(ipv4)
|
|
|
|
udp_overflow = start + csum + _ip_src + _ip_dst + udp
|
|
|
|
|
|
|
|
udp = struct.pack('>HHHH', src_port, dst_port, 7, 0)
|
|
|
|
tot_len = 20 + len(udp)
|
|
|
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
2019-02-02 16:52:25 +01:00
|
|
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
2017-02-13 10:51:25 +01:00
|
|
|
csum = ip_checksum(ipv4)
|
|
|
|
udp_underflow = start + csum + _ip_src + _ip_dst + udp
|
|
|
|
|
|
|
|
src_port = 123
|
|
|
|
dst_port = 456
|
|
|
|
udp = struct.pack('>HHHH', src_port, dst_port, 8, 0)
|
|
|
|
tot_len = 20 + len(udp)
|
|
|
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
2019-02-02 16:52:25 +01:00
|
|
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
2017-02-13 10:51:25 +01:00
|
|
|
csum = ip_checksum(ipv4)
|
|
|
|
udp_unknown_port = start + csum + _ip_src + _ip_dst + udp
|
|
|
|
|
|
|
|
src_port = 68
|
|
|
|
dst_port = 67
|
|
|
|
udp = struct.pack('>HHHH', src_port, dst_port, 8, 0)
|
|
|
|
tot_len = 20 + len(udp)
|
|
|
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
2019-02-02 16:52:25 +01:00
|
|
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
2017-02-13 10:51:25 +01:00
|
|
|
csum = ip_checksum(ipv4)
|
|
|
|
dhcp_missing_data = start + csum + _ip_src + _ip_dst + udp
|
|
|
|
|
|
|
|
dhcp_not_req = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
|
|
|
chaddr=dev[0].own_addr(), override_op=BOOTREPLY)
|
|
|
|
dhcp_no_magic = build_dhcp(req=True, dhcp_msg=None,
|
2019-02-02 16:52:25 +01:00
|
|
|
chaddr=dev[0].own_addr(), magic_override=b'',
|
2017-02-13 10:51:25 +01:00
|
|
|
rapid_commit=False, opt_end=False)
|
|
|
|
dhcp_unknown_magic = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
|
|
|
chaddr=dev[0].own_addr(),
|
2019-02-02 16:52:25 +01:00
|
|
|
magic_override=b'\x00\x00\x00\x00')
|
2017-02-13 10:51:25 +01:00
|
|
|
dhcp_opts = build_dhcp(req=True, dhcp_msg=DHCPNAK,
|
|
|
|
chaddr=dev[0].own_addr(),
|
2019-02-02 16:52:25 +01:00
|
|
|
extra_op=b'\x00\x11', opt_end=False)
|
2017-02-13 10:51:25 +01:00
|
|
|
dhcp_opts2 = build_dhcp(req=True, dhcp_msg=DHCPNAK,
|
|
|
|
chaddr=dev[0].own_addr(),
|
2019-02-02 16:52:25 +01:00
|
|
|
extra_op=b'\x11\x01', opt_end=False)
|
2017-02-13 10:51:25 +01:00
|
|
|
dhcp_valid = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
|
|
|
chaddr=dev[0].own_addr())
|
|
|
|
|
2019-03-15 11:10:37 +01:00
|
|
|
tests = ["ff",
|
|
|
|
"0800",
|
|
|
|
"0800" + 20*"00",
|
|
|
|
"0800" + binascii.hexlify(ipv4_overflow).decode(),
|
|
|
|
"0800" + binascii.hexlify(ipv4_unknown_proto).decode(),
|
|
|
|
"0800" + binascii.hexlify(ipv4_missing_udp_hdr).decode(),
|
|
|
|
"0800" + binascii.hexlify(udp_overflow).decode(),
|
|
|
|
"0800" + binascii.hexlify(udp_underflow).decode(),
|
|
|
|
"0800" + binascii.hexlify(udp_unknown_port).decode(),
|
|
|
|
"0800" + binascii.hexlify(dhcp_missing_data).decode(),
|
|
|
|
binascii.hexlify(dhcp_not_req).decode(),
|
|
|
|
binascii.hexlify(dhcp_no_magic).decode(),
|
|
|
|
binascii.hexlify(dhcp_unknown_magic).decode()]
|
2017-02-13 10:51:25 +01:00
|
|
|
for t in tests:
|
|
|
|
if "OK" not in dev[0].request("FILS_HLP_REQ_ADD ff:ff:ff:ff:ff:ff " + t):
|
|
|
|
raise Exception("FILS_HLP_REQ_ADD failed: " + t)
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].request("FILS_HLP_REQ_FLUSH")
|
2019-03-15 11:10:37 +01:00
|
|
|
tests = [binascii.hexlify(dhcp_opts).decode(),
|
|
|
|
binascii.hexlify(dhcp_opts2).decode()]
|
2017-02-13 10:51:25 +01:00
|
|
|
for t in tests:
|
|
|
|
if "OK" not in dev[0].request("FILS_HLP_REQ_ADD ff:ff:ff:ff:ff:ff " + t):
|
|
|
|
raise Exception("FILS_HLP_REQ_ADD failed: " + t)
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].request("FILS_HLP_REQ_FLUSH")
|
2019-02-02 12:01:36 +01:00
|
|
|
if "OK" not in dev[0].request("FILS_HLP_REQ_ADD ff:ff:ff:ff:ff:ff " + binascii.hexlify(dhcp_valid).decode()):
|
2017-02-13 10:51:25 +01:00
|
|
|
raise Exception("FILS_HLP_REQ_ADD failed")
|
|
|
|
hapd.set("own_ip_addr", "0.0.0.0")
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
hapd.set("dhcp_server", "0.0.0.0")
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
# FILS: Failed to bind DHCP socket: Address already in use
|
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
|
2017-02-16 19:58:07 +01:00
|
|
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
2017-02-13 10:51:25 +01:00
|
|
|
sock.settimeout(5)
|
|
|
|
sock.bind(("127.0.0.2", 67))
|
|
|
|
hapd.set("own_ip_addr", "127.0.0.2")
|
|
|
|
hapd.set("dhcp_server", "127.0.0.2")
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
# FILS: DHCP sendto failed: Invalid argument
|
|
|
|
hapd.set("own_ip_addr", "127.0.0.3")
|
|
|
|
hapd.set("dhcp_server", "127.0.0.2")
|
|
|
|
hapd.set("dhcp_relay_port", "0")
|
|
|
|
hapd.set("dhcp_server_port", "0")
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].request("FILS_HLP_REQ_FLUSH")
|
2017-02-13 12:42:31 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params):
|
2017-02-13 12:42:31 +01:00
|
|
|
"""FILS SK HLP and DHCP response parsing"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-02-13 12:42:31 +01:00
|
|
|
|
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
|
2017-02-16 19:58:07 +01:00
|
|
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
2017-02-13 12:42:31 +01:00
|
|
|
sock.settimeout(5)
|
|
|
|
sock.bind(("127.0.0.2", 67))
|
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = fils_hlp_config(fils_hlp_wait_time=30)
|
|
|
|
params['dhcp_rapid_commit_proxy'] = '1'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
if "OK" not in dev[0].request("FILS_HLP_REQ_FLUSH"):
|
|
|
|
raise Exception("Failed to flush pending FILS HLP requests")
|
|
|
|
dhcpdisc = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
|
|
|
chaddr=dev[0].own_addr())
|
2019-02-02 12:01:36 +01:00
|
|
|
if "OK" not in dev[0].request("FILS_HLP_REQ_ADD " + "ff:ff:ff:ff:ff:ff " + binascii.hexlify(dhcpdisc).decode()):
|
2017-02-13 12:42:31 +01:00
|
|
|
raise Exception("FILS_HLP_REQ_ADD failed")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
with alloc_fail(hapd, 1, "fils_process_hlp"):
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-02-13 12:42:31 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
dhcpdisc = build_dhcp(req=False, dhcp_msg=DHCPACK,
|
|
|
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3")
|
|
|
|
#sock.sendto(dhcpdisc[2+20+8:], addr)
|
2019-03-15 11:10:37 +01:00
|
|
|
chaddr = binascii.unhexlify(dev[0].own_addr().replace(':', '')) + 10*b'\x00'
|
|
|
|
tests = [b"\x00",
|
|
|
|
b"\x02" + 500 * b"\x00",
|
|
|
|
b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 500*b"\x00",
|
|
|
|
b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 16*b"\x00" + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63",
|
|
|
|
b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 16*b"\x00" + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x00\x11",
|
|
|
|
b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 16*b"\x00" + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x11\x01",
|
|
|
|
b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + chaddr + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x35\x00\xff",
|
|
|
|
b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + chaddr + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x35\x01\x00\xff",
|
|
|
|
1501 * b"\x00"]
|
2017-02-13 12:42:31 +01:00
|
|
|
for t in tests:
|
|
|
|
sock.sendto(t, addr)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
# FILS: DHCP sendto failed: Invalid argument for second DHCP TX in proxy
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-02-13 12:42:31 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
hapd.set("dhcp_server_port", "0")
|
|
|
|
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
|
|
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3")
|
|
|
|
sock.sendto(dhcpoffer[2+20+8:], addr)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
hapd.set("dhcp_server_port", "67")
|
|
|
|
|
|
|
|
# Options in DHCPOFFER
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-02-13 12:42:31 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
|
|
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
2019-02-02 16:52:25 +01:00
|
|
|
extra_op=b"\x00\x11", opt_end=False)
|
2017-02-13 12:42:31 +01:00
|
|
|
sock.sendto(dhcpoffer[2+20+8:], addr)
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-02-13 12:42:31 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
# Options in DHCPOFFER (2)
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-02-13 12:42:31 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
|
|
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
2019-02-02 16:52:25 +01:00
|
|
|
extra_op=b"\x11\x01", opt_end=False)
|
2017-02-13 12:42:31 +01:00
|
|
|
sock.sendto(dhcpoffer[2+20+8:], addr)
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-02-13 12:42:31 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
# Server ID in DHCPOFFER
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-02-13 12:42:31 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
|
|
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
2019-02-02 16:52:25 +01:00
|
|
|
extra_op=b"\x36\x01\x30")
|
2017-02-13 12:42:31 +01:00
|
|
|
sock.sendto(dhcpoffer[2+20+8:], addr)
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-02-13 12:42:31 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
# FILS: Could not update DHCPDISCOVER
|
|
|
|
dev[0].request("FILS_HLP_REQ_FLUSH")
|
|
|
|
dhcpdisc = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
|
|
|
chaddr=dev[0].own_addr(),
|
2019-02-02 16:52:25 +01:00
|
|
|
extra_op=b"\x00\x11", opt_end=False)
|
2019-02-02 12:01:36 +01:00
|
|
|
if "OK" not in dev[0].request("FILS_HLP_REQ_ADD " + "ff:ff:ff:ff:ff:ff " + binascii.hexlify(dhcpdisc).decode()):
|
2017-02-13 12:42:31 +01:00
|
|
|
raise Exception("FILS_HLP_REQ_ADD failed")
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-02-13 12:42:31 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
|
|
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
2019-02-02 16:52:25 +01:00
|
|
|
extra_op=b"\x36\x01\x30")
|
2017-02-13 12:42:31 +01:00
|
|
|
sock.sendto(dhcpoffer[2+20+8:], addr)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
# FILS: Could not update DHCPDISCOVER (2)
|
|
|
|
dev[0].request("FILS_HLP_REQ_FLUSH")
|
|
|
|
dhcpdisc = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
|
|
|
chaddr=dev[0].own_addr(),
|
2019-02-02 16:52:25 +01:00
|
|
|
extra_op=b"\x11\x01", opt_end=False)
|
2019-02-02 12:01:36 +01:00
|
|
|
if "OK" not in dev[0].request("FILS_HLP_REQ_ADD " + "ff:ff:ff:ff:ff:ff " + binascii.hexlify(dhcpdisc).decode()):
|
2017-02-13 12:42:31 +01:00
|
|
|
raise Exception("FILS_HLP_REQ_ADD failed")
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
2019-03-15 11:10:37 +01:00
|
|
|
(msg, addr) = sock.recvfrom(1000)
|
2017-02-13 12:42:31 +01:00
|
|
|
logger.debug("Received DHCP message from %s" % str(addr))
|
|
|
|
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
|
|
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
2019-02-02 16:52:25 +01:00
|
|
|
extra_op=b"\x36\x01\x30")
|
2017-02-13 12:42:31 +01:00
|
|
|
sock.sendto(dhcpoffer[2+20+8:], addr)
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].request("FILS_HLP_REQ_FLUSH")
|
2017-02-22 23:13:48 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_erp_and_reauth(dev, apdev, params):
|
2017-02-22 23:13:48 +01:00
|
|
|
"""FILS SK using ERP and AP going away"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-02-22 23:13:48 +01:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
params['broadcast_deauth'] = '0'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
hapd.disable()
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
hapd.enable()
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Reconnection using FILS/ERP timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if "EVENT-ASSOC-REJECT" in ev:
|
|
|
|
raise Exception("Association failed")
|
2017-02-23 16:59:13 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_erp_sim(dev, apdev, params):
|
2017-02-23 16:59:13 +01:00
|
|
|
"""FILS SK using ERP with SIM"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-03-15 11:10:37 +01:00
|
|
|
realm = 'wlan.mnc001.mcc232.3gppnetwork.org'
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(erp_domain=realm,
|
2017-09-05 18:12:29 +02:00
|
|
|
msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-02-23 16:59:13 +01:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['fils_realm'] = realm
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="SIM", identity="1232010000000000@" + realm,
|
|
|
|
password="90dca4eda45b53cf0f12d7c9c3bc6a89:cb9cccc4b9258e6dca4760379fb82581",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
hapd.disable()
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
hapd.enable()
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Reconnection using FILS/ERP timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if "EVENT-ASSOC-REJECT" in ev:
|
|
|
|
raise Exception("Association failed")
|
2017-03-12 21:46:50 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_pfs_19(dev, apdev, params):
|
2017-03-12 21:46:50 +01:00
|
|
|
"""FILS SK with PFS (DH group 19)"""
|
2017-09-05 18:12:29 +02:00
|
|
|
run_fils_sk_pfs(dev, apdev, "19", params)
|
2017-03-12 21:46:50 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_pfs_20(dev, apdev, params):
|
2017-03-12 21:46:50 +01:00
|
|
|
"""FILS SK with PFS (DH group 20)"""
|
2017-09-05 18:12:29 +02:00
|
|
|
run_fils_sk_pfs(dev, apdev, "20", params)
|
2017-03-12 21:46:50 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_pfs_21(dev, apdev, params):
|
2017-03-12 21:46:50 +01:00
|
|
|
"""FILS SK with PFS (DH group 21)"""
|
2017-09-05 18:12:29 +02:00
|
|
|
run_fils_sk_pfs(dev, apdev, "21", params)
|
2017-03-12 21:46:50 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_pfs_25(dev, apdev, params):
|
2017-03-12 21:46:50 +01:00
|
|
|
"""FILS SK with PFS (DH group 25)"""
|
2017-09-05 18:12:29 +02:00
|
|
|
run_fils_sk_pfs(dev, apdev, "25", params)
|
2017-03-12 21:46:50 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_pfs_26(dev, apdev, params):
|
2017-03-12 21:46:50 +01:00
|
|
|
"""FILS SK with PFS (DH group 26)"""
|
2017-09-05 18:12:29 +02:00
|
|
|
run_fils_sk_pfs(dev, apdev, "26", params)
|
2017-03-12 21:46:50 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_pfs_27(dev, apdev, params):
|
2017-03-12 21:46:50 +01:00
|
|
|
"""FILS SK with PFS (DH group 27)"""
|
2017-09-05 18:12:29 +02:00
|
|
|
run_fils_sk_pfs(dev, apdev, "27", params)
|
2017-03-12 21:46:50 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_pfs_28(dev, apdev, params):
|
2017-03-12 21:46:50 +01:00
|
|
|
"""FILS SK with PFS (DH group 28)"""
|
2017-09-05 18:12:29 +02:00
|
|
|
run_fils_sk_pfs(dev, apdev, "28", params)
|
2017-03-12 21:46:50 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_pfs_29(dev, apdev, params):
|
2017-03-12 21:46:50 +01:00
|
|
|
"""FILS SK with PFS (DH group 29)"""
|
2017-09-05 18:12:29 +02:00
|
|
|
run_fils_sk_pfs(dev, apdev, "29", params)
|
2017-03-12 21:46:50 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_pfs_30(dev, apdev, params):
|
2017-03-12 21:46:50 +01:00
|
|
|
"""FILS SK with PFS (DH group 30)"""
|
2017-09-05 18:12:29 +02:00
|
|
|
run_fils_sk_pfs(dev, apdev, "30", params)
|
2017-03-12 21:46:50 +01:00
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def run_fils_sk_pfs(dev, apdev, group, params):
|
2017-03-13 10:46:59 +01:00
|
|
|
check_fils_sk_pfs_capa(dev[0])
|
2017-03-12 21:46:50 +01:00
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
|
|
|
tls = dev[0].request("GET tls_library")
|
2019-03-15 11:10:37 +01:00
|
|
|
if int(group) in [25]:
|
2017-11-18 12:55:41 +01:00
|
|
|
if not (tls.startswith("OpenSSL") and ("build=OpenSSL 1.0.2" in tls or "build=OpenSSL 1.1" in tls) and ("run=OpenSSL 1.0.2" in tls or "run=OpenSSL 1.1" in tls)):
|
|
|
|
raise HwsimSkip("EC group not supported")
|
2019-03-15 11:10:37 +01:00
|
|
|
if int(group) in [27, 28, 29, 30]:
|
2017-03-12 21:46:50 +01:00
|
|
|
if not (tls.startswith("OpenSSL") and ("build=OpenSSL 1.0.2" in tls or "build=OpenSSL 1.1" in tls) and ("run=OpenSSL 1.0.2" in tls or "run=OpenSSL 1.1" in tls)):
|
|
|
|
raise HwsimSkip("Brainpool EC group not supported")
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-03-12 21:46:50 +01:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
params['fils_dh_group'] = group
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", fils_dh_group=group, scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using FILS/ERP timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if "EVENT-ASSOC-REJECT" in ev:
|
|
|
|
raise Exception("Association failed")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_pfs_group_mismatch(dev, apdev, params):
|
2017-03-12 21:46:50 +01:00
|
|
|
"""FILS SK PFS DH group mismatch"""
|
2017-03-13 10:46:59 +01:00
|
|
|
check_fils_sk_pfs_capa(dev[0])
|
2017-03-12 21:46:50 +01:00
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-03-12 21:46:50 +01:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
params['fils_dh_group'] = "20"
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", fils_dh_group="19", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-AUTH-REJECT"], timeout=10)
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Authentication rejection not seen")
|
|
|
|
if "auth_type=5 auth_transaction=2 status_code=77" not in ev:
|
|
|
|
raise Exception("Unexpected auth reject value: " + ev)
|
2017-03-12 22:04:24 +01:00
|
|
|
|
2017-09-13 21:07:08 +02:00
|
|
|
def test_fils_sk_pfs_pmksa_caching(dev, apdev, params):
|
|
|
|
"""FILS SK with PFS and PMKSA caching"""
|
|
|
|
check_fils_sk_pfs_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-09-13 21:07:08 +02:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['fils_dh_group'] = "19"
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", fils_dh_group="19", scan_freq="2412")
|
|
|
|
pmksa = dev[0].get_pmksa(bssid)
|
|
|
|
if pmksa is None:
|
|
|
|
raise Exception("No PMKSA cache entry created")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
# FILS authentication with PMKSA caching and PFS
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using PMKSA caching timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
pmksa2 = dev[0].get_pmksa(bssid)
|
|
|
|
if pmksa2 is None:
|
|
|
|
raise Exception("No PMKSA cache entry found")
|
|
|
|
if pmksa['pmkid'] != pmksa2['pmkid']:
|
|
|
|
raise Exception("Unexpected PMKID change")
|
|
|
|
|
|
|
|
# Verify EAPOL reauthentication after FILS authentication
|
|
|
|
hapd.request("EAPOL_REAUTH " + dev[0].own_addr())
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("EAP authentication did not start")
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("EAP authentication did not succeed")
|
|
|
|
time.sleep(0.1)
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
# FILS authentication with ERP and PFS
|
|
|
|
dev[0].request("PMKSA_FLUSH")
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"CTRL-EVENT-EAP-SUCCESS",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using ERP and PFS timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if "CTRL-EVENT-EAP-SUCCESS" not in ev:
|
|
|
|
raise Exception("ERP success not reported")
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"SME: Trying to authenticate",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using ERP and PFS timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if "SME: Trying to authenticate" in ev:
|
|
|
|
raise Exception("Unexpected extra authentication round with ERP and PFS")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
pmksa3 = dev[0].get_pmksa(bssid)
|
|
|
|
if pmksa3 is None:
|
|
|
|
raise Exception("No PMKSA cache entry found")
|
|
|
|
if pmksa2['pmkid'] == pmksa3['pmkid']:
|
|
|
|
raise Exception("PMKID did not change")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
# FILS authentication with PMKSA caching and PFS
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using PMKSA caching timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
pmksa4 = dev[0].get_pmksa(bssid)
|
|
|
|
if pmksa4 is None:
|
|
|
|
raise Exception("No PMKSA cache entry found")
|
|
|
|
if pmksa3['pmkid'] != pmksa4['pmkid']:
|
|
|
|
raise Exception("Unexpected PMKID change (2)")
|
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_sk_auth_mismatch(dev, apdev, params):
|
2017-03-12 22:04:24 +01:00
|
|
|
"""FILS SK authentication type mismatch (PFS not supported)"""
|
2017-03-13 10:46:59 +01:00
|
|
|
check_fils_sk_pfs_capa(dev[0])
|
2017-03-12 22:04:24 +01:00
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-03-12 22:04:24 +01:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", fils_dh_group="19", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
2019-12-22 16:20:33 +01:00
|
|
|
hapd.dump_monitor()
|
2017-03-12 22:04:24 +01:00
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using FILS/ERP timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" not in ev:
|
|
|
|
raise Exception("No EAP exchange seen")
|
|
|
|
dev[0].wait_connected()
|
2019-12-22 16:20:33 +01:00
|
|
|
hapd.wait_sta()
|
2017-03-12 22:04:24 +01:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2017-04-10 15:19:26 +02:00
|
|
|
|
2019-04-17 21:54:23 +02:00
|
|
|
def setup_fils_rekey(dev, apdev, params, wpa_ptk_rekey=0, wpa_group_rekey=0,
|
|
|
|
pmksa_caching=True):
|
2017-04-10 15:19:26 +02:00
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-04-10 15:19:26 +02:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
2019-04-17 21:54:23 +02:00
|
|
|
if wpa_ptk_rekey:
|
|
|
|
params['wpa_ptk_rekey'] = str(wpa_ptk_rekey)
|
|
|
|
if wpa_group_rekey:
|
|
|
|
params['wpa_group_rekey'] = str(wpa_group_rekey)
|
|
|
|
if not pmksa_caching:
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
2017-04-10 15:19:26 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
2019-04-17 21:54:23 +02:00
|
|
|
raise Exception("Connection using ERP or PMKSA caching timed out")
|
2017-04-10 15:19:26 +02:00
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2019-04-17 21:54:23 +02:00
|
|
|
return hapd
|
|
|
|
|
|
|
|
def test_fils_auth_gtk_rekey(dev, apdev, params):
|
|
|
|
"""GTK rekeying after FILS authentication"""
|
|
|
|
hapd = setup_fils_rekey(dev, apdev, params, wpa_group_rekey=1)
|
2017-04-10 15:19:26 +02:00
|
|
|
ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("GTK rekey timed out")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
|
|
|
|
if ev is not None:
|
|
|
|
raise Exception("Rekeying failed - disconnected")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2017-05-07 13:32:53 +02:00
|
|
|
|
2019-04-17 21:54:23 +02:00
|
|
|
def test_fils_auth_ptk_rekey_ap(dev, apdev, params):
|
|
|
|
"""PTK rekeying after FILS authentication triggered by AP"""
|
|
|
|
hapd = setup_fils_rekey(dev, apdev, params, wpa_ptk_rekey=2)
|
|
|
|
ev = dev[0].wait_event(["WPA: Key negotiation completed"], timeout=3)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("PTK rekey timed out")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=1)
|
|
|
|
if ev is not None:
|
|
|
|
raise Exception("Rekeying failed - disconnected")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
def test_fils_auth_ptk_rekey_ap_erp(dev, apdev, params):
|
|
|
|
"""PTK rekeying after FILS authentication triggered by AP (ERP)"""
|
|
|
|
hapd = setup_fils_rekey(dev, apdev, params, wpa_ptk_rekey=2,
|
|
|
|
pmksa_caching=False)
|
|
|
|
ev = dev[0].wait_event(["WPA: Key negotiation completed"], timeout=3)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("PTK rekey timed out")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=1)
|
|
|
|
if ev is not None:
|
|
|
|
raise Exception("Rekeying failed - disconnected")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
2017-09-05 18:12:29 +02:00
|
|
|
def test_fils_and_ft(dev, apdev, params):
|
2017-05-07 13:32:53 +02:00
|
|
|
"""FILS SK using ERP and FT initial mobility domain association"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
er = start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2017-05-07 13:32:53 +02:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
hapd.disable()
|
|
|
|
dev[0].flush_scan_cache()
|
|
|
|
if "FAIL" in dev[0].request("PMKSA_FLUSH"):
|
|
|
|
raise Exception("PMKSA_FLUSH failed")
|
|
|
|
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils-ft")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256 FT-FILS-SHA256 FT-EAP"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
params["mobility_domain"] = "a1b2"
|
|
|
|
params["r0_key_lifetime"] = "10000"
|
|
|
|
params["pmk_r1_push"] = "1"
|
|
|
|
params["reassociation_deadline"] = "1000"
|
|
|
|
params['nas_identifier'] = "nas1.w1.fi"
|
|
|
|
params['r1_key_holder'] = "000102030405"
|
2019-03-15 11:10:37 +01:00
|
|
|
params['r0kh'] = ["02:00:00:00:04:00 nas2.w1.fi 300102030405060708090a0b0c0d0e0f"]
|
2017-05-07 13:32:53 +02:00
|
|
|
params['r1kh'] = "02:00:00:00:04:00 00:01:02:03:04:06 200102030405060708090a0b0c0d0e0f"
|
|
|
|
params['ieee80211w'] = "1"
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
id = dev[0].connect("fils-ft", key_mgmt="FILS-SHA256 FT-FILS-SHA256 FT-EAP",
|
|
|
|
ieee80211w="1",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412", wait_connect=False)
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"CTRL-EVENT-AUTH-REJECT",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using FILS/ERP timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if "CTRL-EVENT-AUTH-REJECT" in ev:
|
|
|
|
raise Exception("Authentication failed")
|
|
|
|
if "EVENT-ASSOC-REJECT" in ev:
|
|
|
|
raise Exception("Association failed")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
er.disable()
|
|
|
|
|
|
|
|
# FIX: FT-FILS-SHA256 does not currently work for FT protocol due to not
|
|
|
|
# fully defined FT Reassociation Request/Response frame MIC use in FTE.
|
|
|
|
# FT-EAP can be used to work around that in this test case to confirm the
|
|
|
|
# FT key hierarchy was properly formed in the previous step.
|
|
|
|
#params['wpa_key_mgmt'] = "FILS-SHA256 FT-FILS-SHA256"
|
|
|
|
params['wpa_key_mgmt'] = "FT-EAP"
|
|
|
|
params['nas_identifier'] = "nas2.w1.fi"
|
|
|
|
params['r1_key_holder'] = "000102030406"
|
2019-03-15 11:10:37 +01:00
|
|
|
params['r0kh'] = ["02:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0e0f"]
|
2017-05-07 13:32:53 +02:00
|
|
|
params['r1kh'] = "02:00:00:00:03:00 00:01:02:03:04:05 300102030405060708090a0b0c0d0e0f"
|
|
|
|
hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(apdev[1]['bssid'], freq="2412", force_scan=True)
|
|
|
|
# FIX: Cannot use FT-over-DS without the FTE MIC issue addressed
|
|
|
|
#dev[0].roam_over_ds(apdev[1]['bssid'])
|
|
|
|
dev[0].roam(apdev[1]['bssid'])
|
2017-08-25 15:23:56 +02:00
|
|
|
|
2018-03-24 10:28:10 +01:00
|
|
|
def test_fils_and_ft_over_air(dev, apdev, params):
|
|
|
|
"""FILS SK using ERP and FT-over-air (SHA256)"""
|
|
|
|
run_fils_and_ft_over_air(dev, apdev, params, "FT-FILS-SHA256")
|
|
|
|
|
2018-06-05 19:15:53 +02:00
|
|
|
def test_fils_and_ft_over_air_sha384(dev, apdev, params):
|
|
|
|
"""FILS SK using ERP and FT-over-air (SHA384)"""
|
|
|
|
run_fils_and_ft_over_air(dev, apdev, params, "FT-FILS-SHA384")
|
|
|
|
|
2018-03-24 10:28:10 +01:00
|
|
|
def run_fils_and_ft_over_air(dev, apdev, params, key_mgmt):
|
2018-10-03 12:17:15 +02:00
|
|
|
hapd, hapd2 = run_fils_and_ft_setup(dev, apdev, params, key_mgmt)
|
2018-03-24 10:28:10 +01:00
|
|
|
|
|
|
|
logger.info("FT protocol using FT key hierarchy established during FILS authentication")
|
|
|
|
dev[0].scan_for_bss(apdev[1]['bssid'], freq="2412", force_scan=True)
|
|
|
|
hapd.request("NOTE FT protocol to AP2 using FT keys established during FILS FILS authentication")
|
|
|
|
dev[0].roam(apdev[1]['bssid'])
|
2018-10-03 12:17:15 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd2)
|
2018-03-24 10:28:10 +01:00
|
|
|
|
|
|
|
logger.info("FT protocol using the previously established FT key hierarchy from FILS authentication")
|
|
|
|
hapd.request("NOTE FT protocol back to AP1 using FT keys established during FILS FILS authentication")
|
|
|
|
dev[0].roam(apdev[0]['bssid'])
|
2018-10-03 12:17:15 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2018-03-24 10:28:10 +01:00
|
|
|
|
|
|
|
hapd.request("NOTE FT protocol back to AP2 using FT keys established during FILS FILS authentication")
|
|
|
|
dev[0].roam(apdev[1]['bssid'])
|
2018-10-03 12:17:15 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd2)
|
2018-03-24 10:28:10 +01:00
|
|
|
|
|
|
|
hapd.request("NOTE FT protocol back to AP1 using FT keys established during FILS FILS authentication (2)")
|
|
|
|
dev[0].roam(apdev[0]['bssid'])
|
2018-10-03 12:17:15 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2018-03-24 10:28:10 +01:00
|
|
|
|
|
|
|
def test_fils_and_ft_over_ds(dev, apdev, params):
|
|
|
|
"""FILS SK using ERP and FT-over-DS (SHA256)"""
|
|
|
|
run_fils_and_ft_over_ds(dev, apdev, params, "FT-FILS-SHA256")
|
|
|
|
|
2018-06-05 19:15:53 +02:00
|
|
|
def test_fils_and_ft_over_ds_sha384(dev, apdev, params):
|
|
|
|
"""FILS SK using ERP and FT-over-DS (SHA384)"""
|
|
|
|
run_fils_and_ft_over_ds(dev, apdev, params, "FT-FILS-SHA384")
|
|
|
|
|
2018-03-24 10:28:10 +01:00
|
|
|
def run_fils_and_ft_over_ds(dev, apdev, params, key_mgmt):
|
2018-10-03 12:17:15 +02:00
|
|
|
hapd, hapd2 = run_fils_and_ft_setup(dev, apdev, params, key_mgmt)
|
2018-03-24 10:28:10 +01:00
|
|
|
|
|
|
|
logger.info("FT protocol using FT key hierarchy established during FILS authentication")
|
|
|
|
dev[0].scan_for_bss(apdev[1]['bssid'], freq="2412", force_scan=True)
|
|
|
|
hapd.request("NOTE FT protocol to AP2 using FT keys established during FILS FILS authentication")
|
|
|
|
dev[0].roam_over_ds(apdev[1]['bssid'])
|
|
|
|
|
|
|
|
logger.info("FT protocol using the previously established FT key hierarchy from FILS authentication")
|
|
|
|
hapd.request("NOTE FT protocol back to AP1 using FT keys established during FILS FILS authentication")
|
|
|
|
dev[0].roam_over_ds(apdev[0]['bssid'])
|
|
|
|
|
|
|
|
hapd.request("NOTE FT protocol back to AP2 using FT keys established during FILS FILS authentication")
|
|
|
|
dev[0].roam_over_ds(apdev[1]['bssid'])
|
|
|
|
|
|
|
|
hapd.request("NOTE FT protocol back to AP1 using FT keys established during FILS FILS authentication (2)")
|
|
|
|
dev[0].roam_over_ds(apdev[0]['bssid'])
|
|
|
|
|
|
|
|
def run_fils_and_ft_setup(dev, apdev, params, key_mgmt):
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
er = start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2018-03-24 10:28:10 +01:00
|
|
|
|
|
|
|
logger.info("Set up ERP key hierarchy without FILS/FT authentication")
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = key_mgmt
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
params['ieee80211w'] = "2"
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
hapd.request("NOTE Initial association to establish ERP keys")
|
|
|
|
id = dev[0].connect("fils", key_mgmt=key_mgmt, ieee80211w="2",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
2019-12-18 15:30:40 +01:00
|
|
|
hapd.wait_sta()
|
2018-10-03 12:17:15 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2018-03-24 10:28:10 +01:00
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
hapd.disable()
|
|
|
|
dev[0].flush_scan_cache()
|
|
|
|
if "FAIL" in dev[0].request("PMKSA_FLUSH"):
|
|
|
|
raise Exception("PMKSA_FLUSH failed")
|
|
|
|
|
|
|
|
logger.info("Initial mobility domain association using FILS authentication")
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils-ft")
|
|
|
|
params['wpa_key_mgmt'] = key_mgmt
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
params["mobility_domain"] = "a1b2"
|
|
|
|
params["r0_key_lifetime"] = "10000"
|
|
|
|
params["pmk_r1_push"] = "1"
|
|
|
|
params["reassociation_deadline"] = "1000"
|
|
|
|
params['nas_identifier'] = "nas1.w1.fi"
|
|
|
|
params['r1_key_holder'] = "000102030405"
|
2019-03-15 11:10:37 +01:00
|
|
|
params['r0kh'] = ["02:00:00:00:03:00 nas1.w1.fi 100102030405060708090a0b0c0d0e0f100102030405060708090a0b0c0d0e0f",
|
|
|
|
"02:00:00:00:04:00 nas2.w1.fi 300102030405060708090a0b0c0d0e0f"]
|
2018-03-24 10:28:10 +01:00
|
|
|
params['r1kh'] = "02:00:00:00:04:00 00:01:02:03:04:06 200102030405060708090a0b0c0d0e0f"
|
|
|
|
params['ieee80211w'] = "2"
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
hapd.request("NOTE Initial FT mobility domain association using FILS authentication")
|
|
|
|
dev[0].set_network_quoted(id, "ssid", "fils-ft")
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"CTRL-EVENT-AUTH-REJECT",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using FILS/ERP timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if "CTRL-EVENT-AUTH-REJECT" in ev:
|
|
|
|
raise Exception("Authentication failed")
|
|
|
|
if "EVENT-ASSOC-REJECT" in ev:
|
|
|
|
raise Exception("Association failed")
|
2019-12-18 15:30:40 +01:00
|
|
|
hapd.wait_sta()
|
2018-03-24 10:28:10 +01:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
er.disable()
|
|
|
|
|
|
|
|
params['wpa_key_mgmt'] = key_mgmt
|
|
|
|
params['nas_identifier'] = "nas2.w1.fi"
|
|
|
|
params['r1_key_holder'] = "000102030406"
|
2019-03-15 11:10:37 +01:00
|
|
|
params['r0kh'] = ["02:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0e0f",
|
|
|
|
"02:00:00:00:04:00 nas2.w1.fi 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f"]
|
2018-03-24 10:28:10 +01:00
|
|
|
params['r1kh'] = "02:00:00:00:03:00 00:01:02:03:04:05 300102030405060708090a0b0c0d0e0f"
|
|
|
|
hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
|
|
|
|
|
2018-10-03 12:17:15 +02:00
|
|
|
return hapd, hapd2
|
2018-03-24 10:28:10 +01:00
|
|
|
|
2017-08-25 15:23:56 +02:00
|
|
|
def test_fils_assoc_replay(dev, apdev, params):
|
|
|
|
"""FILS AP and replayed Association Request frame"""
|
|
|
|
capfile = os.path.join(params['logdir'], "hwsim0.pcapng")
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
start_erp_as()
|
2017-08-25 15:23:56 +02:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
hapd.set("ext_mgmt_frame_handling", "1")
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
|
|
|
|
assocreq = None
|
|
|
|
count = 0
|
|
|
|
while count < 100:
|
|
|
|
req = hapd.mgmt_rx()
|
|
|
|
count += 1
|
|
|
|
hapd.dump_monitor()
|
2019-02-02 12:01:36 +01:00
|
|
|
hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + binascii.hexlify(req['frame']).decode())
|
2017-08-25 15:23:56 +02:00
|
|
|
if req['subtype'] == 0:
|
|
|
|
assocreq = req
|
|
|
|
ev = hapd.wait_event(["MGMT-TX-STATUS"], timeout=5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("No TX status seen")
|
|
|
|
cmd = "MGMT_TX_STATUS_PROCESS %s" % (" ".join(ev.split(' ')[1:4]))
|
|
|
|
if "OK" not in hapd.request(cmd):
|
|
|
|
raise Exception("MGMT_TX_STATUS_PROCESS failed")
|
|
|
|
break
|
|
|
|
hapd.set("ext_mgmt_frame_handling", "0")
|
|
|
|
if assocreq is None:
|
|
|
|
raise Exception("No Association Request frame seen")
|
|
|
|
dev[0].wait_connected()
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
hapd.dump_monitor()
|
|
|
|
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
logger.info("Replay the last Association Request frame")
|
|
|
|
hapd.dump_monitor()
|
|
|
|
hapd.set("ext_mgmt_frame_handling", "1")
|
2019-02-02 12:01:36 +01:00
|
|
|
hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + binascii.hexlify(req['frame']).decode())
|
2017-08-25 15:23:56 +02:00
|
|
|
ev = hapd.wait_event(["MGMT-TX-STATUS"], timeout=5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("No TX status seen")
|
|
|
|
cmd = "MGMT_TX_STATUS_PROCESS %s" % (" ".join(ev.split(' ')[1:4]))
|
|
|
|
if "OK" not in hapd.request(cmd):
|
|
|
|
raise Exception("MGMT_TX_STATUS_PROCESS failed")
|
|
|
|
hapd.set("ext_mgmt_frame_handling", "0")
|
|
|
|
|
|
|
|
try:
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
ok = True
|
|
|
|
except:
|
|
|
|
ok = False
|
|
|
|
|
|
|
|
ap = hapd.own_addr()
|
|
|
|
sta = dev[0].own_addr()
|
|
|
|
filt = "wlan.fc.type == 2 && " + \
|
|
|
|
"wlan.da == " + sta + " && " + \
|
|
|
|
"wlan.sa == " + ap + " && wlan.ccmp.extiv"
|
2019-03-15 11:10:37 +01:00
|
|
|
fields = ["wlan.ccmp.extiv"]
|
2017-08-25 15:23:56 +02:00
|
|
|
res = run_tshark(capfile, filt, fields)
|
|
|
|
vals = res.splitlines()
|
|
|
|
logger.info("CCMP PN: " + str(vals))
|
|
|
|
if len(vals) < 2:
|
|
|
|
raise Exception("Could not find all CCMP protected frames from capture")
|
|
|
|
if len(set(vals)) < len(vals):
|
|
|
|
raise Exception("Duplicate CCMP PN used")
|
|
|
|
|
|
|
|
if not ok:
|
|
|
|
raise Exception("The second hwsim connectivity test failed")
|
2018-08-23 11:11:44 +02:00
|
|
|
|
|
|
|
def test_fils_sk_erp_server_flush(dev, apdev, params):
|
|
|
|
"""FILS SK ERP and ERP flush on server, but not on peer"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
2019-05-06 22:36:30 +02:00
|
|
|
hapd_as = start_erp_as(msk_dump=os.path.join(params['logdir'], "msk.lst"))
|
2018-08-23 11:11:44 +02:00
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using FILS/ERP timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if "EVENT-ASSOC-REJECT" in ev:
|
|
|
|
raise Exception("Association failed")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
hapd_as.request("ERP_FLUSH")
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-AUTH-REJECT"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("No authentication rejection seen after ERP flush on server")
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"CTRL-EVENT-AUTH-REJECT",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection attempt using FILS/ERP timed out")
|
|
|
|
if "CTRL-EVENT-AUTH-REJECT" in ev:
|
|
|
|
raise Exception("Failed to recover from ERP flush on server")
|
|
|
|
if "EVENT-ASSOC-REJECT" in ev:
|
|
|
|
raise Exception("Association failed")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" not in ev:
|
|
|
|
raise Exception("New EAP exchange not seen")
|
|
|
|
dev[0].wait_connected(error="Connection timeout after ERP flush")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"CTRL-EVENT-AUTH-REJECT",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection attempt using FILS with new ERP keys timed out")
|
|
|
|
if "CTRL-EVENT-AUTH-REJECT" in ev:
|
|
|
|
raise Exception("Authentication failed with new ERP keys")
|
|
|
|
if "EVENT-ASSOC-REJECT" in ev:
|
|
|
|
raise Exception("Association failed with new ERP keys")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
2019-04-06 15:47:38 +02:00
|
|
|
|
|
|
|
def test_fils_sk_erp_radius_ext(dev, apdev, params):
|
|
|
|
"""FILS SK using ERP and external RADIUS server"""
|
|
|
|
as_hapd = hostapd.Hostapd("as")
|
|
|
|
try:
|
|
|
|
as_hapd.disable()
|
|
|
|
as_hapd.set("eap_server_erp", "1")
|
|
|
|
as_hapd.set("erp_domain", "erp.example.com")
|
|
|
|
as_hapd.enable()
|
|
|
|
run_fils_sk_erp_radius_ext(dev, apdev, params)
|
|
|
|
finally:
|
|
|
|
as_hapd.disable()
|
|
|
|
as_hapd.set("eap_server_erp", "0")
|
|
|
|
as_hapd.set("erp_domain", "")
|
|
|
|
as_hapd.enable()
|
|
|
|
|
|
|
|
def run_fils_sk_erp_radius_ext(dev, apdev, params):
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['erp_domain'] = 'erp.example.com'
|
|
|
|
params['fils_realm'] = 'erp.example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
|
|
|
|
eap="PWD", identity="pwd@erp.example.com",
|
|
|
|
password="secret password",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
dev[0].select_network(id, freq=2412)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"EVENT-ASSOC-REJECT",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using FILS/ERP timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if "EVENT-ASSOC-REJECT" in ev:
|
|
|
|
raise Exception("Association failed")
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2019-05-06 22:43:33 +02:00
|
|
|
|
2019-12-22 16:41:48 +01:00
|
|
|
def test_fils_sk_erp_radius_roam(dev, apdev):
|
|
|
|
"""FILS SK/ERP and roaming with different AKM"""
|
|
|
|
as_hapd = hostapd.Hostapd("as")
|
|
|
|
try:
|
|
|
|
as_hapd.disable()
|
|
|
|
as_hapd.set("eap_server_erp", "1")
|
|
|
|
as_hapd.set("erp_domain", "example.com")
|
|
|
|
as_hapd.enable()
|
|
|
|
run_fils_sk_erp_radius_roam(dev, apdev)
|
|
|
|
finally:
|
|
|
|
as_hapd.disable()
|
|
|
|
as_hapd.set("eap_server_erp", "0")
|
|
|
|
as_hapd.set("erp_domain", "")
|
|
|
|
as_hapd.enable()
|
|
|
|
|
|
|
|
def run_fils_sk_erp_radius_roam(dev, apdev):
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256 FILS-SHA384",
|
|
|
|
eap="PWD", identity="erp-pwd@example.com",
|
|
|
|
password="secret password",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
|
|
|
|
bssid2 = apdev[1]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA384"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
params['disable_pmksa_caching'] = '1'
|
|
|
|
hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid2, freq=2412)
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
if "OK" not in dev[0].request("ROAM " + bssid2):
|
|
|
|
raise Exception("ROAM failed")
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using PMKSA caching timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if bssid2 not in ev:
|
|
|
|
raise Exception("Failed to connect to the second AP")
|
|
|
|
|
|
|
|
hapd2.wait_sta()
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd2)
|
|
|
|
|
2019-05-06 22:43:33 +02:00
|
|
|
def test_fils_sk_erp_roam_diff_akm(dev, apdev, params):
|
|
|
|
"""FILS SK using ERP and SHA256/SHA384 change in roam"""
|
|
|
|
check_fils_capa(dev[0])
|
|
|
|
check_erp_capa(dev[0])
|
|
|
|
|
|
|
|
start_erp_as()
|
|
|
|
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid, freq=2412)
|
|
|
|
dev[0].request("ERP_FLUSH")
|
|
|
|
id = dev[0].connect("fils", key_mgmt="FILS-SHA256 FILS-SHA384",
|
|
|
|
eap="PSK", identity="psk.user@example.com",
|
|
|
|
password_hex="0123456789abcdef0123456789abcdef",
|
|
|
|
erp="1", scan_freq="2412")
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
dev[0].request("RECONNECT")
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Connection using FILS timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
|
|
|
|
bssid2 = apdev[1]['bssid']
|
|
|
|
params = hostapd.wpa2_eap_params(ssid="fils")
|
|
|
|
params['wpa_key_mgmt'] = "FILS-SHA256 FILS-SHA384"
|
|
|
|
params['auth_server_port'] = "18128"
|
|
|
|
params['erp_domain'] = 'example.com'
|
|
|
|
params['fils_realm'] = 'example.com'
|
|
|
|
hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(bssid2, freq=2412)
|
|
|
|
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
if "OK" not in dev[0].request("ROAM " + bssid2):
|
|
|
|
raise Exception("ROAM failed")
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
|
|
|
|
"CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Roaming using FILS timed out")
|
|
|
|
if "CTRL-EVENT-EAP-STARTED" in ev:
|
|
|
|
raise Exception("Unexpected EAP exchange")
|
|
|
|
if bssid2 not in ev:
|
|
|
|
raise Exception("Failed to connect to the second AP")
|
|
|
|
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd2)
|