diff options
-rw-r--r-- | service/java/com/android/server/wifi/util/InformationElementUtil.java | 42 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java | 152 |
2 files changed, 176 insertions, 18 deletions
diff --git a/service/java/com/android/server/wifi/util/InformationElementUtil.java b/service/java/com/android/server/wifi/util/InformationElementUtil.java index 26ede7047..f75d57eff 100644 --- a/service/java/com/android/server/wifi/util/InformationElementUtil.java +++ b/service/java/com/android/server/wifi/util/InformationElementUtil.java @@ -406,15 +406,16 @@ public class InformationElementUtil { private static final int WPA_AKM_EAP = 0x01f25000; private static final int WPA_AKM_PSK = 0x02f25000; - private static final int WPA2_AKM_EAP = 0x01ac0f00; - private static final int WPA2_AKM_PSK = 0x02ac0f00; - private static final int WPA2_AKM_FT_EAP = 0x03ac0f00; - private static final int WPA2_AKM_FT_PSK = 0x04ac0f00; - private static final int WPA2_AKM_EAP_SHA256 = 0x05ac0f00; - private static final int WPA2_AKM_PSK_SHA256 = 0x06ac0f00; - private static final int WPA2_AKM_SAE = 0x08ac0f00; - private static final int WPA2_AKM_OWE = 0x12ac0f00; - private static final int WPA2_AKM_EAP_SUITE_B_192 = 0x0cac0f00; + private static final int RSN_AKM_EAP = 0x01ac0f00; + private static final int RSN_AKM_PSK = 0x02ac0f00; + private static final int RSN_AKM_FT_EAP = 0x03ac0f00; + private static final int RSN_AKM_FT_PSK = 0x04ac0f00; + private static final int RSN_AKM_EAP_SHA256 = 0x05ac0f00; + private static final int RSN_AKM_PSK_SHA256 = 0x06ac0f00; + private static final int RSN_AKM_SAE = 0x08ac0f00; + private static final int RSN_AKM_FT_SAE = 0x09ac0f00; + private static final int RSN_AKM_OWE = 0x12ac0f00; + private static final int RSN_AKM_EAP_SUITE_B_192 = 0x0cac0f00; private static final int WPA_CIPHER_NONE = 0x00f25000; private static final int WPA_CIPHER_TKIP = 0x02f25000; @@ -483,31 +484,34 @@ public class InformationElementUtil { for (int i = 0; i < akmCount; i++) { int akm = buf.getInt(); switch (akm) { - case WPA2_AKM_EAP: + case RSN_AKM_EAP: rsnKeyManagement.add(ScanResult.KEY_MGMT_EAP); break; - case WPA2_AKM_PSK: + case RSN_AKM_PSK: rsnKeyManagement.add(ScanResult.KEY_MGMT_PSK); break; - case WPA2_AKM_FT_EAP: + case RSN_AKM_FT_EAP: rsnKeyManagement.add(ScanResult.KEY_MGMT_FT_EAP); break; - case WPA2_AKM_FT_PSK: + case RSN_AKM_FT_PSK: rsnKeyManagement.add(ScanResult.KEY_MGMT_FT_PSK); break; - case WPA2_AKM_EAP_SHA256: + case RSN_AKM_EAP_SHA256: rsnKeyManagement.add(ScanResult.KEY_MGMT_EAP_SHA256); break; - case WPA2_AKM_PSK_SHA256: + case RSN_AKM_PSK_SHA256: rsnKeyManagement.add(ScanResult.KEY_MGMT_PSK_SHA256); break; - case WPA2_AKM_SAE: + case RSN_AKM_SAE: rsnKeyManagement.add(ScanResult.KEY_MGMT_SAE); break; - case WPA2_AKM_OWE: + case RSN_AKM_FT_SAE: + rsnKeyManagement.add(ScanResult.KEY_MGMT_FT_SAE); + break; + case RSN_AKM_OWE: rsnKeyManagement.add(ScanResult.KEY_MGMT_OWE); break; - case WPA2_AKM_EAP_SUITE_B_192: + case RSN_AKM_EAP_SUITE_B_192: rsnKeyManagement.add(ScanResult.KEY_MGMT_EAP_SUITE_B_192); break; default: @@ -756,6 +760,8 @@ public class InformationElementUtil { return "OWE"; case ScanResult.KEY_MGMT_SAE: return "SAE"; + case ScanResult.KEY_MGMT_FT_SAE: + return "FT/SAE"; case ScanResult.KEY_MGMT_EAP_SUITE_B_192: return "EAP_SUITE_B_192"; default: 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 b7a6cefb9..cbb728644 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java @@ -388,6 +388,158 @@ public class InformationElementUtilTest { } /** + * Test Capabilities.generateCapabilitiesString() with RSN IE, CCMP and PSK+SAE transition mode. + * Expect the function to return a string with the proper security information. + */ + @Test + public void buildCapabilities_rsnPskSaeTransitionElement() { + InformationElement ieRsn = new InformationElement(); + ieRsn.id = InformationElement.EID_RSN; + ieRsn.bytes = new byte[] { + // RSNE Version (0x0001) + (byte) 0x01, (byte) 0x00, + // Group cipher suite: CCMP + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x04, + // Number of cipher suites (1) + (byte) 0x01, (byte) 0x00, + // Cipher suite: CCMP + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x04, + // Number of AKMs (2) + (byte) 0x02, (byte) 0x00, + // PSK AKM + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x02, + // SAE AKM + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x08, + // Padding + (byte) 0x00, (byte) 0x00 }; + + InformationElement[] ies = new InformationElement[] { ieRsn }; + + BitSet beaconCap = new BitSet(16); + beaconCap.set(4); + + InformationElementUtil.Capabilities capabilities = + new InformationElementUtil.Capabilities(); + capabilities.from(ies, beaconCap); + String result = capabilities.generateCapabilitiesString(); + + assertEquals("[RSN-PSK+SAE-CCMP]", result); + } + + /** + * Test Capabilities.generateCapabilitiesString() with RSN IE, CCMP and SAE+FT/SAE. + * Expect the function to return a string with the proper security information. + */ + @Test + public void buildCapabilities_rsnSaeFtSaeElement() { + InformationElement ieRsn = new InformationElement(); + ieRsn.id = InformationElement.EID_RSN; + ieRsn.bytes = new byte[] { + // RSNE Version (0x0001) + (byte) 0x01, (byte) 0x00, + // Group cipher suite: CCMP + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x04, + // Number of cipher suites (1) + (byte) 0x01, (byte) 0x00, + // Cipher suite: CCMP + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x04, + // Number of AKMs (2) + (byte) 0x02, (byte) 0x00, + // SAE AKM + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x08, + // FT/SAE AKM + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x09, + // Padding + (byte) 0x00, (byte) 0x00 }; + + InformationElement[] ies = new InformationElement[] { ieRsn }; + + BitSet beaconCap = new BitSet(16); + beaconCap.set(4); + + InformationElementUtil.Capabilities capabilities = + new InformationElementUtil.Capabilities(); + capabilities.from(ies, beaconCap); + String result = capabilities.generateCapabilitiesString(); + + assertEquals("[RSN-SAE+FT/SAE-CCMP]", result); + } + + /** + * Test Capabilities.generateCapabilitiesString() with RSN IE, CCMP and OWE. + * Expect the function to return a string with the proper security information. + */ + @Test + public void buildCapabilities_rsnOweElement() { + InformationElement ieRsn = new InformationElement(); + ieRsn.id = InformationElement.EID_RSN; + ieRsn.bytes = new byte[] { + // RSNE Version (0x0001) + (byte) 0x01, (byte) 0x00, + // Group cipher suite: CCMP + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x04, + // Number of cipher suites (1) + (byte) 0x01, (byte) 0x00, + // Cipher suite: CCMP + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x04, + // Number of AKMs (1) + (byte) 0x01, (byte) 0x00, + // OWE AKM + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x12, + // Padding + (byte) 0x00, (byte) 0x00 }; + + InformationElement[] ies = new InformationElement[] { ieRsn }; + + BitSet beaconCap = new BitSet(16); + beaconCap.set(4); + + InformationElementUtil.Capabilities capabilities = + new InformationElementUtil.Capabilities(); + capabilities.from(ies, beaconCap); + String result = capabilities.generateCapabilitiesString(); + + assertEquals("[RSN-OWE-CCMP]", result); + } + + /** + * Test Capabilities.generateCapabilitiesString() with RSN IE, GCMP-256 and SUITE_B_192. + * Expect the function to return a string with the proper security information. + */ + @Test + public void buildCapabilities_rsnSuiteB192Element() { + InformationElement ieRsn = new InformationElement(); + ieRsn.id = InformationElement.EID_RSN; + ieRsn.bytes = new byte[] { + // RSNE Version (0x0001) + (byte) 0x01, (byte) 0x00, + // Group cipher suite: GCMP-256 + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x09, + // Number of cipher suites (1) + (byte) 0x01, (byte) 0x00, + // Cipher suite: GCMP-256 + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x09, + // Number of AKMs (1) + (byte) 0x01, (byte) 0x00, + // SUITE_B_192 AKM + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x0C, + // Padding + (byte) 0x00, (byte) 0x00 }; + + InformationElement[] ies = new InformationElement[] { ieRsn }; + + BitSet beaconCap = new BitSet(16); + beaconCap.set(4); + + InformationElementUtil.Capabilities capabilities = + new InformationElementUtil.Capabilities(); + capabilities.from(ies, beaconCap); + String result = capabilities.generateCapabilitiesString(); + + assertEquals("[RSN-EAP_SUITE_B_192-GCMP-256]", result); + } + + /** * Test Capabilities.generateCapabilitiesString() with both RSN and WPA1 IE which are malformed. * Expect the function to return a string with empty key management & pairswise cipher security * information. |