From 9d8bc7f0dfb352e3369c26c1e6e5a697b75dfa31 Mon Sep 17 00:00:00 2001 From: Hai Shalom Date: Tue, 14 May 2019 16:45:05 -0700 Subject: [PSK/EAP] Do not add SHA256 Key mgmt for SupplicantHal < 1.2 Following on GSI Q on P failure: Do not add SHA256 Key management where Supplicant HAL version is lower than 1.2, where it is not supported. Bug: 132656148 Test: atest SupplicantStaNetworkHalTest Change-Id: Idf6f85fa409082b3b88dd36b624f8878be695709 --- .../server/wifi/SupplicantStaNetworkHal.java | 8 ++++++ .../server/wifi/SupplicantStaNetworkHalTest.java | 30 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java b/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java index 059ea797c..9255fc231 100644 --- a/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java +++ b/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java @@ -3012,6 +3012,14 @@ public class SupplicantStaNetworkHal { private BitSet addSha256KeyMgmtFlags(BitSet keyManagementFlags) { synchronized (mLock) { BitSet modifiedFlags = (BitSet) keyManagementFlags.clone(); + android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork + iSupplicantStaNetworkV12; + iSupplicantStaNetworkV12 = getV1_2StaNetwork(); + if (iSupplicantStaNetworkV12 == null) { + // SHA256 key management requires HALv1.2 or higher + return modifiedFlags; + } + if (keyManagementFlags.get(WifiConfiguration.KeyMgmt.WPA_PSK)) { modifiedFlags.set(WifiConfiguration.KeyMgmt.WPA_PSK_SHA256); } diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java index f8896f44c..796dce1df 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java @@ -841,6 +841,36 @@ public class SupplicantStaNetworkHalTest { WifiConfigurationTestUtil.assertConfigurationEqualForSupplicant(config, loadConfig); } + /** + * Tests the addition of SHA256 flags (WPA_PSK_SHA256) is ignored on HAL v1.1 or lower + */ + @Test + public void testAddPskSha256FlagsHal1_1OrLower() throws Exception { + WifiConfiguration config = WifiConfigurationTestUtil.createPskNetwork(); + assertTrue(mSupplicantNetwork.saveWifiConfiguration(config)); + + // Check the supplicant variables to ensure that we have NOT added the SHA256 flags. + assertFalse((mSupplicantVariables.keyMgmtMask + & android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork.KeyMgmtMask + .WPA_PSK_SHA256) == android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork + .KeyMgmtMask.WPA_PSK_SHA256); + } + + /** + * Tests the addition of SHA256 flags (WPA_EAP_SHA256) is ignored on HAL v1.1 or lower + */ + @Test + public void testAddEapSha256FlagsHal1_1OrLower() throws Exception { + WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(); + assertTrue(mSupplicantNetwork.saveWifiConfiguration(config)); + + // Check the supplicant variables to ensure that we have NOT added the SHA256 flags. + assertFalse((mSupplicantVariables.keyMgmtMask + & android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork.KeyMgmtMask + .WPA_EAP_SHA256) == android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork + .KeyMgmtMask.WPA_EAP_SHA256); + } + /** * Tests the retrieval of WPS NFC token. */ -- cgit v1.2.3