From: Glenn Strauss Date: Tue, 8 Nov 2022 05:05:49 +0000 (-0500) Subject: tests: Check IMSI privacy support using a helper function X-Git-Tag: hostap_2_11~1517 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e364713ef28f76c72edd782f4c427f8ba573dbb;p=thirdparty%2Fhostap.git tests: Check IMSI privacy support using a helper function Signed-off-by: Glenn Strauss --- diff --git a/tests/hwsim/test_ap_eap.py b/tests/hwsim/test_ap_eap.py index f5f77faa5..12b770818 100644 --- a/tests/hwsim/test_ap_eap.py +++ b/tests/hwsim/test_ap_eap.py @@ -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", diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index c981b3547..49ab7efdb 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -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" diff --git a/tests/hwsim/utils.py b/tests/hwsim/utils.py index 1b1bc7a16..5fd0457a4 100644 --- a/tests/hwsim/utils.py +++ b/tests/hwsim/utils.py @@ -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"):