From 1c243e402b137aeb48e4d56b269b4734fee19ea6 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 12 Mar 2017 22:46:50 +0200 Subject: [PATCH] tests: FILS SK with PFS Signed-off-by: Jouni Malinen --- tests/hwsim/example-hostapd.config | 1 + tests/hwsim/example-wpa_supplicant.config | 1 + tests/hwsim/test_fils.py | 116 ++++++++++++++++++++++ tests/hwsim/wpasupplicant.py | 2 +- 4 files changed, 119 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/example-hostapd.config b/tests/hwsim/example-hostapd.config index 2c8509b54..9c672269f 100644 --- a/tests/hwsim/example-hostapd.config +++ b/tests/hwsim/example-hostapd.config @@ -105,4 +105,5 @@ CONFIG_MBO=y CONFIG_IAPP=y CONFIG_TAXONOMY=y CONFIG_FILS=y +CONFIG_FILS_SK_PFS=y CONFIG_OWE=y diff --git a/tests/hwsim/example-wpa_supplicant.config b/tests/hwsim/example-wpa_supplicant.config index a1acdc095..d78ebb54f 100644 --- a/tests/hwsim/example-wpa_supplicant.config +++ b/tests/hwsim/example-wpa_supplicant.config @@ -147,5 +147,6 @@ CONFIG_SUITEB=y #LIBS_p += -fsanitize=undefined CONFIG_MBO=y CONFIG_FILS=y +CONFIG_FILS_SK_PFS=y CONFIG_PMKSA_CACHE_EXTERNAL=y CONFIG_OWE=y diff --git a/tests/hwsim/test_fils.py b/tests/hwsim/test_fils.py index 62f5f969e..eb8b35fd0 100644 --- a/tests/hwsim/test_fils.py +++ b/tests/hwsim/test_fils.py @@ -1250,3 +1250,119 @@ def test_fils_sk_erp_sim(dev, apdev): raise Exception("Unexpected EAP exchange") if "EVENT-ASSOC-REJECT" in ev: raise Exception("Association failed") + +def test_fils_sk_pfs_19(dev, apdev): + """FILS SK with PFS (DH group 19)""" + rul_fils_sk_pfs(dev, apdev, "19") + +def test_fils_sk_pfs_20(dev, apdev): + """FILS SK with PFS (DH group 20)""" + rul_fils_sk_pfs(dev, apdev, "20") + +def test_fils_sk_pfs_21(dev, apdev): + """FILS SK with PFS (DH group 21)""" + rul_fils_sk_pfs(dev, apdev, "21") + +def test_fils_sk_pfs_25(dev, apdev): + """FILS SK with PFS (DH group 25)""" + rul_fils_sk_pfs(dev, apdev, "25") + +def test_fils_sk_pfs_26(dev, apdev): + """FILS SK with PFS (DH group 26)""" + rul_fils_sk_pfs(dev, apdev, "26") + +def test_fils_sk_pfs_27(dev, apdev): + """FILS SK with PFS (DH group 27)""" + rul_fils_sk_pfs(dev, apdev, "27") + +def test_fils_sk_pfs_28(dev, apdev): + """FILS SK with PFS (DH group 28)""" + rul_fils_sk_pfs(dev, apdev, "28") + +def test_fils_sk_pfs_29(dev, apdev): + """FILS SK with PFS (DH group 29)""" + rul_fils_sk_pfs(dev, apdev, "29") + +def test_fils_sk_pfs_30(dev, apdev): + """FILS SK with PFS (DH group 30)""" + rul_fils_sk_pfs(dev, apdev, "30") + +def rul_fils_sk_pfs(dev, apdev, group): + check_fils_capa(dev[0]) + check_erp_capa(dev[0]) + + tls = dev[0].request("GET tls_library") + if int(group) in [ 27, 28, 29, 30 ]: + 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") + + start_erp_as(apdev[1]) + + 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) + +def test_fils_sk_pfs_group_mismatch(dev, apdev): + """FILS SK PFS DH group mismatch""" + check_fils_capa(dev[0]) + check_erp_capa(dev[0]) + + start_erp_as(apdev[1]) + + 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) diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index c6fabdf38..65686d1e0 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -1025,7 +1025,7 @@ class WpaSupplicant: "ht40_intolerant", "update_identifier", "mac_addr", "erp", "bg_scan_period", "bssid_blacklist", "bssid_whitelist", "mem_only_psk", "eap_workaround", - "engine" ] + "engine", "fils_dh_group" ] for field in not_quoted: if field in kwargs and kwargs[field]: self.set_network(id, field, kwargs[field])