]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Check IMSI privacy support using a helper function
authorGlenn Strauss <gstrauss@gluelogic.com>
Tue, 8 Nov 2022 05:05:49 +0000 (00:05 -0500)
committerJouni Malinen <j@w1.fi>
Sun, 20 Nov 2022 15:23:10 +0000 (17:23 +0200)
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
tests/hwsim/test_ap_eap.py
tests/hwsim/test_ap_hs20.py
tests/hwsim/utils.py

index f5f77faa5bc5c59f6d5a2b10fa4f4d132cfb2cf9..12b770818280f202ca12fcf5ba7c18eb5c4d08ed 100644 (file)
@@ -309,9 +309,7 @@ def test_ap_wpa2_eap_sim_imsi_identity(dev, apdev, params):
     prefix = params['prefix']
     params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
     hapd = hostapd.add_ap(apdev[0], params)
-    tls = hapd.request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(hapd)
 
     imsi = "232010000000000"
     realm = "wlan.mnc232.mcc02.3gppnetwork.org"
@@ -347,15 +345,11 @@ def test_ap_wpa2_eap_sim_imsi_identity(dev, apdev, params):
 
 def test_ap_wpa2_eap_sim_imsi_privacy_key(dev, apdev):
     """WPA2-Enterprise connection using EAP-SIM and imsi_privacy_cert"""
-    tls = dev[0].request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(dev[0])
     check_hlr_auc_gw_support()
     params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
     hapd = hostapd.add_ap(apdev[0], params)
-    tls = hapd.request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(hapd)
 
     eap_connect(dev[0], hapd, "SIM",
                 "1232010000000000@wlan.mnc232.mcc02.3gppnetwork.org",
@@ -365,15 +359,11 @@ def test_ap_wpa2_eap_sim_imsi_privacy_key(dev, apdev):
 
 def test_ap_wpa2_eap_sim_imsi_privacy_attr(dev, apdev):
     """WPA2-Enterprise connection using EAP-SIM and imsi_privacy_cert/attr"""
-    tls = dev[0].request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(dev[0])
     check_hlr_auc_gw_support()
     params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
     hapd = hostapd.add_ap(apdev[0], params)
-    tls = hapd.request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(hapd)
 
     eap_connect(dev[0], hapd, "SIM",
                 "1232010000000000@wlan.mnc232.mcc02.3gppnetwork.org",
@@ -1112,9 +1102,7 @@ def test_ap_wpa2_eap_aka_imsi_identity(dev, apdev, params):
     prefix = params['prefix']
     params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
     hapd = hostapd.add_ap(apdev[0], params)
-    tls = hapd.request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(hapd)
 
     imsi = "232010000000000"
     realm = "wlan.mnc232.mcc02.3gppnetwork.org"
@@ -1150,15 +1138,11 @@ def test_ap_wpa2_eap_aka_imsi_identity(dev, apdev, params):
 
 def test_ap_wpa2_eap_aka_imsi_privacy_key(dev, apdev):
     """WPA2-Enterprise connection using EAP-AKA and imsi_privacy_cert"""
-    tls = dev[0].request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(dev[0])
     check_hlr_auc_gw_support()
     params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
     hapd = hostapd.add_ap(apdev[0], params)
-    tls = hapd.request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(hapd)
 
     eap_connect(dev[0], hapd, "AKA",
                 "0232010000000000@wlan.mnc232.mcc02.3gppnetwork.org",
@@ -1168,15 +1152,11 @@ def test_ap_wpa2_eap_aka_imsi_privacy_key(dev, apdev):
 
 def test_ap_wpa2_eap_aka_imsi_privacy_attr(dev, apdev):
     """WPA2-Enterprise connection using EAP-AKA and imsi_privacy_cert/attr"""
-    tls = dev[0].request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(dev[0])
     check_hlr_auc_gw_support()
     params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
     hapd = hostapd.add_ap(apdev[0], params)
-    tls = hapd.request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(hapd)
 
     eap_connect(dev[0], hapd, "AKA",
                 "0232010000000000@wlan.mnc232.mcc02.3gppnetwork.org",
@@ -1186,17 +1166,13 @@ def test_ap_wpa2_eap_aka_imsi_privacy_attr(dev, apdev):
 
 def test_ap_wpa2_eap_aka_imsi_privacy_key_expired(dev, apdev):
     """WPA2-Enterprise connection using EAP-AKA and expired imsi_privacy_cert"""
-    tls = dev[0].request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(dev[0])
     check_hlr_auc_gw_support()
     params = int_eap_server_params()
     params['eap_sim_db'] = 'unix:/tmp/hlr_auc_gw.sock'
     params['imsi_privacy_key'] = 'auth_serv/imsi-privacy-key-2.pem'
     hapd = hostapd.add_ap(apdev[0], params)
-    tls = hapd.request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(hapd)
 
     dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP WPA-EAP-SHA256",
                    eap="AKA",
@@ -1427,9 +1403,7 @@ def test_ap_wpa2_eap_aka_prime_imsi_identity(dev, apdev, params):
     prefix = params['prefix']
     params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
     hapd = hostapd.add_ap(apdev[0], params)
-    tls = hapd.request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(hapd)
 
     imsi = "555444333222111"
     realm = "wlan.mnc555.mcc44.3gppnetwork.org"
@@ -1465,15 +1439,11 @@ def test_ap_wpa2_eap_aka_prime_imsi_identity(dev, apdev, params):
 
 def test_ap_wpa2_eap_aka_prime_imsi_privacy_key(dev, apdev):
     """WPA2-Enterprise connection using EAP-AKA' and imsi_privacy_cert"""
-    tls = dev[0].request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(dev[0])
     check_hlr_auc_gw_support()
     params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
     hapd = hostapd.add_ap(apdev[0], params)
-    tls = hapd.request("GET tls_library")
-    if not tls.startswith("OpenSSL"):
-        raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+    check_imsi_privacy_support(hapd)
 
     eap_connect(dev[0], hapd, "AKA'",
                 "6555444333222111@wlan.mnc555.mcc44.3gppnetwork.org",
index c981b35470202b1f861ebd13a5e2e0de37da1638..49ab7efdb7f777a876e55100aba6a3f361525b51 100644 (file)
@@ -543,9 +543,7 @@ def hs20_simulated_sim(dev, ap, method, imsi_privacy=False,
     params = {'imsi': "555444-333222111", 'eap': method,
               'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123"}
     if imsi_privacy:
-        tls = dev.request("GET tls_library")
-        if not tls.startswith("OpenSSL"):
-            raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+        check_imsi_privacy_support(dev)
         params['imsi_privacy_cert'] = "auth_serv/imsi-privacy-cert.pem"
         if imsi_privacy_attr:
             params['imsi_privacy_attr'] = "Identifier=1234567"
index 1b1bc7a160a1b6168a1f5b0944ff34796838677b..5fd0457a4476564493785ff93f9200a17a9fe33d 100644 (file)
@@ -133,6 +133,12 @@ def check_fils_sk_pfs_capa(dev):
     if capa is None or "FILS-SK-PFS" not in capa:
         raise HwsimSkip("FILS-SK-PFS not supported")
 
+def check_imsi_privacy_support(dev):
+    tls = dev.request("GET tls_library")
+    if tls.startswith("OpenSSL"):
+        return
+    raise HwsimSkip("IMSI privacy not supported with this TLS library: " + tls)
+
 def check_tls_tod(dev):
     tls = dev.request("GET tls_library")
     if not tls.startswith("OpenSSL") and not tls.startswith("internal"):