From 4a1a1513fcd2846f914f3134eb8db81e59073a2c Mon Sep 17 00:00:00 2001 From: Hai Shalom Date: Mon, 15 Oct 2018 16:14:04 -0700 Subject: opt/net/wifi: Add support for WPA3 and OWE Add support for WPA3-Personal (SAE), WPA3-Enterprise (SuiteB) and OWE (Enhanced Open). Changes include new types and new methods. Bug: 112195778 Test: atest com.android.server.wifi Change-Id: I5c1520bd951cd4b6110f573e3522073dec6e910a --- .../com/android/server/wifi/util/InformationElementUtilTest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java index a1b37ff7b..d921bf33d 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java @@ -267,7 +267,7 @@ public class InformationElementUtilTest { capabilities.from(ies, beaconCap); String result = capabilities.generateCapabilitiesString(); - assertEquals("[WPA2-PSK-CCMP+TKIP]", result); + assertEquals("[RSN-PSK-CCMP+TKIP]", result); } /** @@ -293,7 +293,7 @@ public class InformationElementUtilTest { capabilities.from(ies, beaconCap); String result = capabilities.generateCapabilitiesString(); - assertEquals("[WPA2]", result); + assertEquals("[RSN]", result); } /** @@ -383,7 +383,7 @@ public class InformationElementUtilTest { capabilities.from(ies, beaconCap); String result = capabilities.generateCapabilitiesString(); - assertEquals("[WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP]", result); + assertEquals("[WPA-PSK-CCMP+TKIP][RSN-PSK-CCMP+TKIP]", result); } /** @@ -415,7 +415,7 @@ public class InformationElementUtilTest { capabilities.from(ies, beaconCap); String result = capabilities.generateCapabilitiesString(); - assertEquals("[WPA][WPA2]", result); + assertEquals("[WPA][RSN]", result); } /** @@ -783,4 +783,5 @@ public class InformationElementUtilTest { assertEquals(0x112233445566L, interworking.hessid); } + // TODO: SAE, OWN, SUITE_B } -- cgit v1.2.3 From 7fa44346403d217fef581631f299758abe1e99d6 Mon Sep 17 00:00:00 2001 From: Hai Shalom Date: Thu, 25 Oct 2018 11:20:44 -0700 Subject: [WPA3] WiFi tests: Add unit tests for WPA3, SuiteB and OWE Add unit tests for WPA3, SuiteB and OWE. Fix broken unittests due to new flags and types. Bug: 112195778 Test: All unit tests passed. Change-Id: I6b037bfc80f32810e09d14cf927e969a3245ad02 --- .../server/wifi/NetworkListStoreDataTest.java | 6 + .../server/wifi/SupplicantStaIfaceHalTest.java | 19 +- .../server/wifi/SupplicantStaNetworkHalTest.java | 195 +++++++++++++++++++-- .../android/server/wifi/WifiBackupRestoreTest.java | 19 +- .../android/server/wifi/WifiConfigManagerTest.java | 39 ++++- .../android/server/wifi/WifiConfigStoreTest.java | 2 + .../server/wifi/WifiConfigurationTestUtil.java | 60 ++++++- 7 files changed, 314 insertions(+), 26 deletions(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java index 5fa15e81b..868e3aef6 100644 --- a/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java @@ -76,6 +76,8 @@ public class NetworkListStoreDataTest { + "\n" + "\n" + "\n" + + "\n" + + "\n" + "\n" + "\n" + "\n" @@ -128,6 +130,8 @@ public class NetworkListStoreDataTest { + "\n" + "\n" + "\n" + + "\n" + + "\n" + "\n" + "\n" + "\n" @@ -365,6 +369,8 @@ public class NetworkListStoreDataTest { + "\n" + "\n" + "\n" + + "\n" + + "\n" + "\n" + "\n" + "\n" diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java index 182b32626..c2bf0dcfa 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java @@ -15,7 +15,11 @@ */ package com.android.server.wifi; -import static org.junit.Assert.*; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyInt; @@ -23,7 +27,16 @@ import static org.mockito.Matchers.anyLong; import static org.mockito.Matchers.anyShort; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; import android.annotation.NonNull; import android.app.test.MockAnswerUtil; @@ -33,11 +46,11 @@ import android.hardware.wifi.supplicant.V1_0.ISupplicantIface; import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIface; import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIfaceCallback; import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIfaceCallback.BssidChangeReason; -import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetwork; import android.hardware.wifi.supplicant.V1_0.IfaceType; import android.hardware.wifi.supplicant.V1_0.SupplicantStatus; import android.hardware.wifi.supplicant.V1_0.SupplicantStatusCode; import android.hardware.wifi.supplicant.V1_0.WpsConfigMethods; +import android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork; import android.hidl.manager.V1_0.IServiceManager; import android.hidl.manager.V1_0.IServiceNotification; import android.net.IpConfiguration; diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java index a52cca87f..a4d799fcc 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java @@ -15,7 +15,12 @@ */ package com.android.server.wifi; -import static org.junit.Assert.*; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyString; @@ -27,7 +32,6 @@ import static org.mockito.Mockito.when; import android.app.test.MockAnswerUtil.AnswerWithArguments; import android.content.Context; import android.hardware.wifi.supplicant.V1_0.ISupplicantNetwork; -import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetwork; import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetworkCallback; import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetworkCallback .NetworkRequestEapSimGsmAuthParams; @@ -35,6 +39,7 @@ import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetworkCallback .NetworkRequestEapSimUmtsAuthParams; import android.hardware.wifi.supplicant.V1_0.SupplicantStatus; import android.hardware.wifi.supplicant.V1_0.SupplicantStatusCode; +import android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiEnterpriseConfig; import android.os.RemoteException; @@ -74,7 +79,7 @@ public class SupplicantStaNetworkHalTest { private SupplicantStatus mStatusFailure; @Mock private ISupplicantStaNetwork mISupplicantStaNetworkMock; @Mock - private android.hardware.wifi.supplicant.V1_1.ISupplicantStaNetwork mISupplicantStaNetworkV11; + private android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork mISupplicantStaNetworkV12; @Mock private Context mContext; @Mock private WifiMonitor mWifiMonitor; @@ -83,19 +88,20 @@ public class SupplicantStaNetworkHalTest { private ISupplicantStaNetworkCallback mISupplicantStaNetworkCallback; /** - * Spy used to return the V1_1 ISupplicantStaNetwork mock object to simulate the 1.1 HAL running + * Spy used to return the V1_2 ISupplicantStaNetwork mock object to simulate the 1.2 HAL running * on the device. */ - private class SupplicantStaNetworkHalSpyV1_1 extends SupplicantStaNetworkHal { - SupplicantStaNetworkHalSpyV1_1(ISupplicantStaNetwork iSupplicantStaNetwork, + private class SupplicantStaNetworkHalSpyV1_2 extends SupplicantStaNetworkHal { + SupplicantStaNetworkHalSpyV1_2(ISupplicantStaNetwork iSupplicantStaNetwork, String ifaceName, Context context, WifiMonitor monitor) { super(iSupplicantStaNetwork, ifaceName, context, monitor); } + @Override - protected android.hardware.wifi.supplicant.V1_1.ISupplicantStaNetwork - getSupplicantStaNetworkForV1_1Mockable() { - return mISupplicantStaNetworkV11; + protected android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork + getSupplicantStaNetworkForV1_2Mockable() { + return mISupplicantStaNetworkV12; } } @@ -112,6 +118,20 @@ public class SupplicantStaNetworkHalTest { createSupplicantStaNetwork(); } + /** + * Tests the saving of WifiConfiguration to wpa_supplicant. + */ + @Test + public void testOweNetworkWifiConfigurationSaveLoad() throws Exception { + // Now expose the V1.2 ISupplicantStaNetwork + mSupplicantNetwork = new SupplicantStaNetworkHalSpyV1_2(mISupplicantStaNetworkMock, + IFACE_NAME, mContext, mWifiMonitor); + + WifiConfiguration config = WifiConfigurationTestUtil.createOweNetwork(); + config.updateIdentifier = "46"; + testWifiConfigurationSaveLoad(config); + } + /** * Tests the saving of WifiConfiguration to wpa_supplicant. */ @@ -122,6 +142,27 @@ public class SupplicantStaNetworkHalTest { testWifiConfigurationSaveLoad(config); } + /** + * Tests the saving/loading of WifiConfiguration to wpa_supplicant with SAE password. + */ + @Test + public void testSaePasswordNetworkWifiConfigurationSaveLoad() throws Exception { + // Now expose the V1.2 ISupplicantStaNetwork + mSupplicantNetwork = new SupplicantStaNetworkHalSpyV1_2(mISupplicantStaNetworkMock, + IFACE_NAME, mContext, mWifiMonitor); + + WifiConfiguration config = WifiConfigurationTestUtil.createSaeNetwork(); + testWifiConfigurationSaveLoad(config); + verify(mISupplicantStaNetworkV12).setSaePassword(any(String.class)); + verify(mISupplicantStaNetworkV12, never()) + .getSaePassword(any(ISupplicantStaNetwork.getSaePasswordCallback.class)); + verify(mISupplicantStaNetworkV12, never()) + .getPskPassphrase(any(ISupplicantStaNetwork.getPskPassphraseCallback.class)); + verify(mISupplicantStaNetworkV12, never()).setPsk(any(byte[].class)); + verify(mISupplicantStaNetworkV12, never()) + .getPsk(any(ISupplicantStaNetwork.getPskCallback.class)); + } + /** * Tests the saving/loading of WifiConfiguration to wpa_supplicant with psk passphrase. */ @@ -222,6 +263,59 @@ public class SupplicantStaNetworkHalTest { testWifiConfigurationSaveLoad(config); } + /** + * Tests the saving/loading of WifiConfiguration to wpa_supplicant with Suite-B-192 + */ + @Test + public void testEapSuiteBRsaNetworkWifiConfigurationSaveLoad() throws Exception { + // Now expose the V1.2 ISupplicantStaNetwork + mSupplicantNetwork = new SupplicantStaNetworkHalSpyV1_2(mISupplicantStaNetworkMock, + IFACE_NAME, mContext, mWifiMonitor); + + WifiConfiguration config = WifiConfigurationTestUtil.createEapSuiteBNetwork(); + config.allowedSuiteBCiphers.set(WifiConfiguration.SuiteBCipher.ECDHE_RSA); + + testWifiConfigurationSaveLoad(config); + verify(mISupplicantStaNetworkV12, never()).enableSuiteBEapOpenSslCiphers(); + verify(mISupplicantStaNetworkV12).enableTlsSuiteBEapPhase1Param(anyBoolean()); + + verify(mISupplicantStaNetworkV12, never()).setSaePassword(any(String.class)); + verify(mISupplicantStaNetworkV12, never()) + .getSaePassword(any(ISupplicantStaNetwork.getSaePasswordCallback.class)); + verify(mISupplicantStaNetworkV12, never()) + .getPskPassphrase(any(ISupplicantStaNetwork.getPskPassphraseCallback.class)); + verify(mISupplicantStaNetworkV12, never()).setPsk(any(byte[].class)); + verify(mISupplicantStaNetworkV12, never()) + .getPsk(any(ISupplicantStaNetwork.getPskCallback.class)); + } + + /** + * Tests the saving/loading of WifiConfiguration to wpa_supplicant with Suite-B-192 + */ + @Test + public void testEapSuiteBEcdsaNetworkWifiConfigurationSaveLoad() throws Exception { + // Now expose the V1.2 ISupplicantStaNetwork + mSupplicantNetwork = new SupplicantStaNetworkHalSpyV1_2(mISupplicantStaNetworkMock, + IFACE_NAME, mContext, mWifiMonitor); + + WifiConfiguration config = WifiConfigurationTestUtil.createEapSuiteBNetwork(); + config.allowedSuiteBCiphers.set(WifiConfiguration.SuiteBCipher.ECDHE_ECDSA); + + testWifiConfigurationSaveLoad(config); + verify(mISupplicantStaNetworkV12).enableSuiteBEapOpenSslCiphers(); + verify(mISupplicantStaNetworkV12, never()) + .enableTlsSuiteBEapPhase1Param(any(boolean.class)); + + verify(mISupplicantStaNetworkV12, never()).setSaePassword(any(String.class)); + verify(mISupplicantStaNetworkV12, never()) + .getSaePassword(any(ISupplicantStaNetwork.getSaePasswordCallback.class)); + verify(mISupplicantStaNetworkV12, never()) + .getPskPassphrase(any(ISupplicantStaNetwork.getPskPassphraseCallback.class)); + verify(mISupplicantStaNetworkV12, never()).setPsk(any(byte[].class)); + verify(mISupplicantStaNetworkV12, never()) + .getPsk(any(ISupplicantStaNetwork.getPskCallback.class)); + } + /** * Tests the loading of network ID. */ @@ -281,7 +375,7 @@ public class SupplicantStaNetworkHalTest { @Test public void testInvalidKeyMgmtSaveFailure() throws Exception { WifiConfiguration config = WifiConfigurationTestUtil.createWepHiddenNetwork(); - config.allowedKeyManagement.set(10); + config.allowedKeyManagement.set(20); try { assertFalse(mSupplicantNetwork.saveWifiConfiguration(config)); } catch (IllegalArgumentException e) { @@ -631,11 +725,11 @@ public class SupplicantStaNetworkHalTest { assertTrue(mSupplicantNetwork.sendNetworkEapIdentityResponse(identityStr, encryptedIdentityStr)); - verify(mISupplicantStaNetworkV11, never()).sendNetworkEapIdentityResponse_1_1( + verify(mISupplicantStaNetworkV12, never()).sendNetworkEapIdentityResponse_1_1( any(ArrayList.class), any(ArrayList.class)); - // Now expose the V1.1 ISupplicantStaNetwork - mSupplicantNetwork = new SupplicantStaNetworkHalSpyV1_1(mISupplicantStaNetworkMock, + // Now expose the V1.2 ISupplicantStaNetwork + mSupplicantNetwork = new SupplicantStaNetworkHalSpyV1_2(mISupplicantStaNetworkMock, IFACE_NAME, mContext, mWifiMonitor); doAnswer(new AnswerWithArguments() { public SupplicantStatus answer(ArrayList identity, @@ -646,7 +740,7 @@ public class SupplicantStaNetworkHalTest { NativeUtil.stringFromByteArrayList(encryptedIdentity)); return mStatusSuccess; } - }).when(mISupplicantStaNetworkV11).sendNetworkEapIdentityResponse_1_1(any(ArrayList.class), + }).when(mISupplicantStaNetworkV12).sendNetworkEapIdentityResponse_1_1(any(ArrayList.class), any(ArrayList.class)); assertTrue(mSupplicantNetwork.sendNetworkEapIdentityResponse(identityStr, encryptedIdentityStr)); @@ -921,6 +1015,21 @@ public class SupplicantStaNetworkHalTest { }).when(mISupplicantStaNetworkMock) .getRequirePmf(any(ISupplicantStaNetwork.getRequirePmfCallback.class)); + /** SAE password */ + doAnswer(new AnswerWithArguments() { + public SupplicantStatus answer(String saePassword) throws RemoteException { + mSupplicantVariables.pskPassphrase = saePassword; + return mStatusSuccess; + } + }).when(mISupplicantStaNetworkV12).setSaePassword(any(String.class)); + doAnswer(new AnswerWithArguments() { + public void answer(ISupplicantStaNetwork.getPskPassphraseCallback cb) + throws RemoteException { + cb.onValues(mStatusSuccess, mSupplicantVariables.pskPassphrase); + } + }).when(mISupplicantStaNetworkV12) + .getSaePassword(any(ISupplicantStaNetwork.getSaePasswordCallback.class)); + /** PSK passphrase */ doAnswer(new AnswerWithArguments() { public SupplicantStatus answer(String pskPassphrase) throws RemoteException { @@ -994,6 +1103,20 @@ public class SupplicantStaNetworkHalTest { }).when(mISupplicantStaNetworkMock) .getKeyMgmt(any(ISupplicantStaNetwork.getKeyMgmtCallback.class)); + /** allowedKeyManagement v1.2 */ + doAnswer(new AnswerWithArguments() { + public SupplicantStatus answer(int mask) throws RemoteException { + mSupplicantVariables.keyMgmtMask = mask; + return mStatusSuccess; + } + }).when(mISupplicantStaNetworkV12).setKeyMgmt_1_2(any(int.class)); + doAnswer(new AnswerWithArguments() { + public void answer(ISupplicantStaNetwork.getKeyMgmtCallback cb) throws RemoteException { + cb.onValues(mStatusSuccess, mSupplicantVariables.keyMgmtMask); + } + }).when(mISupplicantStaNetworkV12) + .getKeyMgmt_1_2(any(ISupplicantStaNetwork.getKeyMgmt_1_2Callback.class)); + /** allowedProtocols */ doAnswer(new AnswerWithArguments() { public SupplicantStatus answer(int mask) throws RemoteException { @@ -1037,6 +1160,21 @@ public class SupplicantStaNetworkHalTest { }).when(mISupplicantStaNetworkMock) .getGroupCipher(any(ISupplicantStaNetwork.getGroupCipherCallback.class)); + /** allowedGroupCiphers v1.2*/ + doAnswer(new AnswerWithArguments() { + public SupplicantStatus answer(int mask) throws RemoteException { + mSupplicantVariables.groupCipherMask = mask; + return mStatusSuccess; + } + }).when(mISupplicantStaNetworkV12).setGroupCipher_1_2(any(int.class)); + doAnswer(new AnswerWithArguments() { + public void answer(ISupplicantStaNetwork.getGroupCipherCallback cb) + throws RemoteException { + cb.onValues(mStatusSuccess, mSupplicantVariables.groupCipherMask); + } + }).when(mISupplicantStaNetworkV12) + .getGroupCipher_1_2(any(ISupplicantStaNetwork.getGroupCipher_1_2Callback.class)); + /** allowedPairwiseCiphers */ doAnswer(new AnswerWithArguments() { public SupplicantStatus answer(int mask) throws RemoteException { @@ -1052,6 +1190,22 @@ public class SupplicantStaNetworkHalTest { }).when(mISupplicantStaNetworkMock) .getPairwiseCipher(any(ISupplicantStaNetwork.getPairwiseCipherCallback.class)); + /** allowedPairwiseCiphers v1.2 */ + doAnswer(new AnswerWithArguments() { + public SupplicantStatus answer(int mask) throws RemoteException { + mSupplicantVariables.pairwiseCipherMask = mask; + return mStatusSuccess; + } + }).when(mISupplicantStaNetworkV12).setPairwiseCipher_1_2(any(int.class)); + doAnswer(new AnswerWithArguments() { + public void answer(ISupplicantStaNetwork.getPairwiseCipherCallback cb) + throws RemoteException { + cb.onValues(mStatusSuccess, mSupplicantVariables.pairwiseCipherMask); + } + }).when(mISupplicantStaNetworkV12) + .getPairwiseCipher_1_2(any(ISupplicantStaNetwork + .getPairwiseCipher_1_2Callback.class)); + /** metadata: idstr */ doAnswer(new AnswerWithArguments() { public SupplicantStatus answer(String idStr) throws RemoteException { @@ -1314,6 +1468,19 @@ public class SupplicantStaNetworkHalTest { } }).when(mISupplicantStaNetworkMock) .registerCallback(any(ISupplicantStaNetworkCallback.class)); + + /** Suite-B*/ + doAnswer(new AnswerWithArguments() { + public SupplicantStatus answer(boolean enable) throws RemoteException { + return mStatusSuccess; + } + }).when(mISupplicantStaNetworkV12).enableTlsSuiteBEapPhase1Param(any(boolean.class)); + + doAnswer(new AnswerWithArguments() { + public SupplicantStatus answer() throws RemoteException { + return mStatusSuccess; + } + }).when(mISupplicantStaNetworkV12).enableSuiteBEapOpenSslCiphers(); } private SupplicantStatus createSupplicantStatus(int code) { diff --git a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java index 53d014b2e..1c238f9de 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java @@ -85,6 +85,7 @@ public class WifiBackupRestoreTest { // |AllowedKeyMgmt|, |AllowedProtocols|, |AllowedAuthAlgorithms|, |AllowedGroupCiphers| and // |AllowedPairwiseCiphers| fields have invalid values in them. + // NOTE: The byte values are encoded in little endian private static final String WIFI_BACKUP_DATA_WITH_UNSUPPORTED_VALUES_IN_BITSETS = "" + "" @@ -101,15 +102,15 @@ public class WifiBackupRestoreTest { + "" + "" // Valid Value: 01 - + "0101" + + "0180" // Valid Value: 03 + "0b" // Valid Value: 01 + "09" // Valid Value: 0f - + "2f" + + "4f" // Valid Value: 06 - + "0e" + + "26" + "" + "" + "" @@ -432,6 +433,7 @@ public class WifiBackupRestoreTest { public void testSingleEnterpriseNetworkNotBackupRestore() { List configurations = new ArrayList<>(); configurations.add(WifiConfigurationTestUtil.createEapNetwork()); + configurations.add(WifiConfigurationTestUtil.createEapSuiteBNetwork()); byte[] backupData = mWifiBackupRestore.retrieveBackupDataFromConfigurations(configurations); List retrievedConfigurations = @@ -527,6 +529,8 @@ public class WifiBackupRestoreTest { configurations.add(WifiConfigurationTestUtil.createWepNetwork()); configurations.add(WifiConfigurationTestUtil.createPskNetwork()); configurations.add(WifiConfigurationTestUtil.createOpenNetwork()); + configurations.add(WifiConfigurationTestUtil.createOweNetwork()); + configurations.add(WifiConfigurationTestUtil.createSaeNetwork()); byte[] backupData = mWifiBackupRestore.retrieveBackupDataFromConfigurations(configurations); List retrievedConfigurations = @@ -549,6 +553,7 @@ public class WifiBackupRestoreTest { expectedConfigurations.add(wepNetwork); configurations.add(WifiConfigurationTestUtil.createEapNetwork()); + configurations.add(WifiConfigurationTestUtil.createEapSuiteBNetwork()); WifiConfiguration pskNetwork = WifiConfigurationTestUtil.createPskNetwork(); configurations.add(pskNetwork); @@ -558,6 +563,14 @@ public class WifiBackupRestoreTest { configurations.add(openNetwork); expectedConfigurations.add(openNetwork); + WifiConfiguration saeNetwork = WifiConfigurationTestUtil.createSaeNetwork(); + configurations.add(saeNetwork); + expectedConfigurations.add(saeNetwork); + + WifiConfiguration oweNetwork = WifiConfigurationTestUtil.createOweNetwork(); + configurations.add(oweNetwork); + expectedConfigurations.add(oweNetwork); + byte[] backupData = mWifiBackupRestore.retrieveBackupDataFromConfigurations(configurations); List retrievedConfigurations = mWifiBackupRestore.retrieveConfigurationsFromBackupData(backupData); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index 79024c937..5198abf05 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -1130,6 +1130,12 @@ public class WifiConfigManagerTest { WifiConfigurationTestUtil.createPskNetwork()); verifyAddSingleNetworkAndMatchScanDetailToNetworkAndCache( WifiConfigurationTestUtil.createEapNetwork()); + verifyAddSingleNetworkAndMatchScanDetailToNetworkAndCache( + WifiConfigurationTestUtil.createSaeNetwork()); + verifyAddSingleNetworkAndMatchScanDetailToNetworkAndCache( + WifiConfigurationTestUtil.createOweNetwork()); + verifyAddSingleNetworkAndMatchScanDetailToNetworkAndCache( + WifiConfigurationTestUtil.createEapSuiteBNetwork()); } /** @@ -1144,18 +1150,27 @@ public class WifiConfigManagerTest { WifiConfiguration wepNetwork = WifiConfigurationTestUtil.createWepNetwork(); WifiConfiguration pskNetwork = WifiConfigurationTestUtil.createPskNetwork(); WifiConfiguration eapNetwork = WifiConfigurationTestUtil.createEapNetwork(); + WifiConfiguration saeNetwork = WifiConfigurationTestUtil.createSaeNetwork(); + WifiConfiguration oweNetwork = WifiConfigurationTestUtil.createOweNetwork(); + WifiConfiguration eapSuiteBNetwork = WifiConfigurationTestUtil.createEapSuiteBNetwork(); // Now add them to WifiConfigManager. verifyAddNetworkToWifiConfigManager(openNetwork); verifyAddNetworkToWifiConfigManager(wepNetwork); verifyAddNetworkToWifiConfigManager(pskNetwork); verifyAddNetworkToWifiConfigManager(eapNetwork); + verifyAddNetworkToWifiConfigManager(saeNetwork); + verifyAddNetworkToWifiConfigManager(oweNetwork); + verifyAddNetworkToWifiConfigManager(eapSuiteBNetwork); // Now create dummy scan detail corresponding to the networks. ScanDetail openNetworkScanDetail = createScanDetailForNetwork(openNetwork); ScanDetail wepNetworkScanDetail = createScanDetailForNetwork(wepNetwork); ScanDetail pskNetworkScanDetail = createScanDetailForNetwork(pskNetwork); ScanDetail eapNetworkScanDetail = createScanDetailForNetwork(eapNetwork); + ScanDetail saeNetworkScanDetail = createScanDetailForNetwork(saeNetwork); + ScanDetail oweNetworkScanDetail = createScanDetailForNetwork(oweNetwork); + ScanDetail eapSuiteBNetworkScanDetail = createScanDetailForNetwork(eapSuiteBNetwork); // Now mix and match parameters from different scan details. openNetworkScanDetail.getScanResult().SSID = @@ -1165,8 +1180,15 @@ public class WifiConfigManagerTest { pskNetworkScanDetail.getScanResult().capabilities = eapNetworkScanDetail.getScanResult().capabilities; eapNetworkScanDetail.getScanResult().capabilities = + saeNetworkScanDetail.getScanResult().capabilities; + saeNetworkScanDetail.getScanResult().capabilities = + oweNetworkScanDetail.getScanResult().capabilities; + oweNetworkScanDetail.getScanResult().capabilities = + eapSuiteBNetworkScanDetail.getScanResult().capabilities; + eapSuiteBNetworkScanDetail.getScanResult().capabilities = openNetworkScanDetail.getScanResult().capabilities; + // Try to lookup a saved network using the modified scan details. All of these should fail. assertNull(mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache( openNetworkScanDetail)); @@ -1176,12 +1198,21 @@ public class WifiConfigManagerTest { pskNetworkScanDetail)); assertNull(mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache( eapNetworkScanDetail)); + assertNull(mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache( + saeNetworkScanDetail)); + assertNull(mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache( + oweNetworkScanDetail)); + assertNull(mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache( + eapSuiteBNetworkScanDetail)); // All the cache's should be empty as well. assertNull(mWifiConfigManager.getScanDetailCacheForNetwork(openNetwork.networkId)); assertNull(mWifiConfigManager.getScanDetailCacheForNetwork(wepNetwork.networkId)); assertNull(mWifiConfigManager.getScanDetailCacheForNetwork(pskNetwork.networkId)); assertNull(mWifiConfigManager.getScanDetailCacheForNetwork(eapNetwork.networkId)); + assertNull(mWifiConfigManager.getScanDetailCacheForNetwork(saeNetwork.networkId)); + assertNull(mWifiConfigManager.getScanDetailCacheForNetwork(oweNetwork.networkId)); + assertNull(mWifiConfigManager.getScanDetailCacheForNetwork(eapSuiteBNetwork.networkId)); } /** @@ -1420,11 +1451,11 @@ public class WifiConfigManagerTest { } /** - * Verifies that hasEverConnected is not cleared when a network config |requirePMF| is + * Verifies that hasEverConnected is cleared when a network config |requirePMF| is * updated. */ @Test - public void testUpdateRequirePMFDoesNotClearHasEverConnected() { + public void testUpdateRequirePMFClearsHasEverConnected() { WifiConfiguration pskNetwork = WifiConfigurationTestUtil.createPskNetwork(); verifyAddNetworkHasEverConnectedFalse(pskNetwork); verifyUpdateNetworkAfterConnectHasEverConnectedTrue(pskNetwork.networkId); @@ -1436,9 +1467,9 @@ public class WifiConfigManagerTest { verifyUpdateNetworkToWifiConfigManagerWithoutIpChange(pskNetwork); WifiConfiguration retrievedNetwork = mWifiConfigManager.getConfiguredNetwork(result.getNetworkId()); - assertTrue("Updating network non-credentials config should not clear hasEverConnected.", + assertFalse("Updating network credentials config must clear hasEverConnected.", retrievedNetwork.getNetworkSelectionStatus().getHasEverConnected()); - assertFalse(result.hasCredentialChanged()); + assertTrue(result.hasCredentialChanged()); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java index 0240a67ab..508cc2630 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java @@ -81,6 +81,8 @@ public class WifiConfigStoreTest { + "\n" + "\n" + "\n" + + "\n" + + "\n" + "\n" + "\n" + "\n" diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java index 97d7e4f22..6755e5476 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java @@ -46,6 +46,9 @@ public class WifiConfigurationTestUtil { public static final int SECURITY_WEP = 1 << 0; public static final int SECURITY_PSK = 1 << 1; public static final int SECURITY_EAP = 1 << 2; + public static final int SECURITY_SAE = 1 << 3; + public static final int SECURITY_OWE = 1 << 4; + public static final int SECURITY_EAP_SUITE_B = 1 << 5; /** * These values are used to describe ip configuration parameters for a network. @@ -138,11 +141,27 @@ public class WifiConfigurationTestUtil { config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); } + if ((security & SECURITY_SAE) != 0) { + config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.SAE); + config.requirePMF = true; + } + + if ((security & SECURITY_OWE) != 0) { + config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.OWE); + config.requirePMF = true; + } + if ((security & SECURITY_EAP) != 0) { config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP); config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X); config.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TTLS); } + + if ((security & SECURITY_EAP_SUITE_B) != 0) { + config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.SUITE_B_192); + config.requirePMF = true; + } + } return config; } @@ -224,6 +243,15 @@ public class WifiConfigurationTestUtil { * Helper methods to generate predefined WifiConfiguration objects of the required type. These * use a static index to avoid duplicate configurations. */ + public static WifiConfiguration createOweNetwork() { + return createOweNetwork(createNewSSID()); + } + + public static WifiConfiguration createOweNetwork(String ssid) { + return generateWifiConfig(TEST_NETWORK_ID, TEST_UID, ssid, true, true, null, + null, SECURITY_OWE); + } + public static WifiConfiguration createOpenNetwork() { return createOpenNetwork(createNewSSID()); } @@ -245,6 +273,17 @@ public class WifiConfigurationTestUtil { return configuration; } + public static WifiConfiguration createSaeNetwork() { + WifiConfiguration configuration = + generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, null, + null, SECURITY_SAE); + + // SAE password uses the same member. + configuration.preSharedKey = TEST_PSK; + configuration.requirePMF = true; + return configuration; + } + public static WifiConfiguration createPskNetwork() { WifiConfiguration configuration = generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, null, @@ -317,6 +356,17 @@ public class WifiConfigurationTestUtil { return configuration; } + public static WifiConfiguration createEapSuiteBNetwork() { + WifiConfiguration configuration = + generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, + null, null, SECURITY_EAP_SUITE_B); + + configuration.requirePMF = true; + configuration.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TLS); + configuration.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.NONE); + return configuration; + } + public static WifiConfiguration createPasspointNetwork() { WifiConfiguration configuration = generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, @@ -430,13 +480,19 @@ public class WifiConfigurationTestUtil { public static String getScanResultCapsForNetwork(WifiConfiguration configuration) { String caps; if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WPA_PSK)) { - caps = "[WPA2-PSK-CCMP]"; + caps = "[RSN-PSK-CCMP]"; } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WPA_EAP) || configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.IEEE8021X)) { - caps = "[WPA2-EAP-CCMP]"; + caps = "[RSN-EAP-CCMP]"; } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.NONE) && WifiConfigurationUtil.hasAnyValidWepKey(configuration.wepKeys)) { caps = "[WEP]"; + } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.SAE)) { + caps = "[RSN-SAE-CCMP]"; + } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.OWE)) { + caps = "[RSN-OWE-CCMP]"; + } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.SUITE_B_192)) { + caps = "[RSN-SUITE-B-192-CCMP]"; } else { caps = "[]"; } -- cgit v1.2.3