From 2bdea8391e029b88e8d8fcce0f06205a9e000999 Mon Sep 17 00:00:00 2001 From: Hai Shalom Date: Tue, 21 Apr 2020 17:49:31 -0700 Subject: [SupplicantHal] Check HAL version before setting GCMP_256 Check SupplicantStaNetworkHal v1.2 or higher before passing PairwiseCipher and GroupCipher of GCMP_256 down to the HAL. These bits were added in 1.2, and enabled by default. Causes connection error when running latest framework version with a 1.1 or older HAL. Bug: 153923541 Test: atest SupplicantStaNetworkHalTest Change-Id: I67cb190a627cb64fb799bad30dc4cc461316ee42 --- .../server/wifi/SupplicantStaNetworkHalTest.java | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java index 0e1c9806b..49ae7a756 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java @@ -196,6 +196,14 @@ public class SupplicantStaNetworkHalTest extends WifiBaseTest { public void testPskPassphraseNetworkWifiConfigurationSaveLoad() throws Exception { WifiConfiguration config = WifiConfigurationTestUtil.createPskNetwork(); config.requirePmf = true; + + // Set the new defaults + config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.GCMP_256); + config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); + config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256); + config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); + config.allowedGroupManagementCiphers + .set(WifiConfiguration.GroupMgmtCipher.BIP_GMAC_256); testWifiConfigurationSaveLoad(config); verify(mISupplicantStaNetworkMock).setPskPassphrase(anyString()); verify(mISupplicantStaNetworkMock) @@ -203,6 +211,10 @@ public class SupplicantStaNetworkHalTest extends WifiBaseTest { verify(mISupplicantStaNetworkMock, never()).setPsk(any(byte[].class)); verify(mISupplicantStaNetworkMock, never()) .getPsk(any(ISupplicantStaNetwork.getPskCallback.class)); + verify(mISupplicantStaNetworkMock) + .setPairwiseCipher(ISupplicantStaNetwork.PairwiseCipherMask.CCMP); + verify(mISupplicantStaNetworkMock) + .setGroupCipher(ISupplicantStaNetwork.GroupCipherMask.CCMP); } /** @@ -948,6 +960,12 @@ public class SupplicantStaNetworkHalTest extends WifiBaseTest { } private void testWifiConfigurationSaveLoad(WifiConfiguration config) { + if (mSupplicantNetwork.getSupplicantStaNetworkForV1_2Mockable() == null) { + // Clear unsupported settings in HAL v1.0 + config.allowedPairwiseCiphers.clear(WifiConfiguration.PairwiseCipher.GCMP_256); + config.allowedGroupCiphers.clear(WifiConfiguration.GroupCipher.GCMP_256); + } + // Save the configuration using the default supplicant network HAL v1.0 assertTrue(mSupplicantNetwork.saveWifiConfiguration(config)); WifiConfiguration loadConfig = new WifiConfiguration(); Map networkExtras = new HashMap<>(); @@ -1038,6 +1056,38 @@ public class SupplicantStaNetworkHalTest extends WifiBaseTest { assertNull(mSupplicantVariables.serializedPmkCache); } + /** + * Tests the saving/loading of WifiConfiguration to wpa_supplicant with psk passphrase for + * HAL v1.2 or higher + */ + @Test + public void testPskPassphraseNetworkWifiConfigurationSaveLoad1_2OrHigher() throws Exception { + createSupplicantStaNetwork(SupplicantStaNetworkVersion.V1_2); + WifiConfiguration config = WifiConfigurationTestUtil.createPskNetwork(); + config.requirePmf = true; + + // Set the new defaults + config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.GCMP_256); + config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); + config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256); + config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); + testWifiConfigurationSaveLoad(config); + verify(mISupplicantStaNetworkMock).setPskPassphrase(anyString()); + verify(mISupplicantStaNetworkMock) + .getPskPassphrase(any(ISupplicantStaNetwork.getPskPassphraseCallback.class)); + verify(mISupplicantStaNetworkMock, never()).setPsk(any(byte[].class)); + verify(mISupplicantStaNetworkMock, never()) + .getPsk(any(ISupplicantStaNetwork.getPskCallback.class)); + verify(mISupplicantStaNetworkV12) + .setPairwiseCipher_1_2(ISupplicantStaNetwork.PairwiseCipherMask.CCMP + | android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork + .PairwiseCipherMask.GCMP_256); + verify(mISupplicantStaNetworkV12) + .setGroupCipher_1_2(ISupplicantStaNetwork.GroupCipherMask.CCMP + | android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork + .GroupCipherMask.GCMP_256); + } + /** * Sets up the HIDL interface mock with all the setters/getter values. * Note: This only sets up the mock to return success on all methods. -- cgit v1.2.3