]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: ERP/FILS with external hostapd process as RADIUS server
authorJouni Malinen <j@w1.fi>
Sat, 6 Apr 2019 13:47:38 +0000 (16:47 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 6 Apr 2019 13:47:38 +0000 (16:47 +0300)
Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/auth_serv/eap_user.conf
tests/hwsim/test_erp.py
tests/hwsim/test_fils.py

index c2c2cf500fc1fe1963eb425f0f35d9237b39fa9d..142dd4e12745da0ddbb95ff5c7f2afeb5a819882 100644 (file)
@@ -38,6 +38,8 @@
 "erp-ttls"     TTLS
 "erp-ttls"     TTLS-PAP        "password"      [2]
 "erp-ikev2@example.com"        IKEV2   "password"
+"psk@erp.example.com"  PSK     0123456789abcdef0123456789abcdef
+"pwd@erp.example.com"  PWD     "secret password"
 
 "vlan1"        PAX     0123456789abcdef0123456789abcdef
 radius_accept_attr=64:d:13
index 3bb47f1eb7f0620ac816597a00d09d4b784557a5..74c12de207693096811d42d0a700de35e78deba0 100644 (file)
@@ -156,6 +156,45 @@ def test_erp_radius(dev, apdev):
             raise Exception("Did not use ERP")
         dev[0].wait_connected(timeout=15, error="Reconnection timed out")
 
+def test_erp_radius_ext(dev, apdev):
+    """ERP enabled on a separate RADIUS server and peer"""
+    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_erp_radius_ext(dev, apdev)
+    finally:
+        as_hapd.disable()
+        as_hapd.set("eap_server_erp", "0")
+        as_hapd.set("erp_domain", "")
+        as_hapd.enable()
+
+def run_erp_radius_ext(dev, apdev):
+    check_erp_capa(dev[0])
+    params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
+    params['erp_send_reauth_start'] = '1'
+    params['erp_domain'] = 'erp.example.com'
+    params['disable_pmksa_caching'] = '1'
+    hapd = hostapd.add_ap(apdev[0], params)
+
+    dev[0].request("ERP_FLUSH")
+    dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP",
+                   eap="PSK", identity="psk@erp.example.com",
+                   password_hex="0123456789abcdef0123456789abcdef",
+                   erp="1", scan_freq="2412")
+    for i in range(3):
+        dev[0].request("DISCONNECT")
+        dev[0].wait_disconnected(timeout=15)
+        dev[0].request("RECONNECT")
+        ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15)
+        if ev is None:
+            raise Exception("EAP success timed out")
+        if "EAP re-authentication completed successfully" not in ev:
+            raise Exception("Did not use ERP")
+        dev[0].wait_connected(timeout=15, error="Reconnection timed out")
+
 def erp_test(dev, hapd, **kwargs):
     res = dev.get_capability("eap")
     if kwargs['eap'] not in res:
index a35c408104e6abe714499cbc0e223546bad1eab3..09f2362cd9bbb266fc25db192ac538e813fd1f17 100644 (file)
@@ -2100,3 +2100,53 @@ def test_fils_sk_erp_server_flush(dev, apdev, params):
         raise Exception("Association failed with new ERP keys")
     if "CTRL-EVENT-EAP-STARTED" in ev:
         raise Exception("Unexpected EAP exchange")
+
+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)