diff options
author | Roshan Pius <rpius@google.com> | 2017-05-30 09:05:22 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2017-05-30 09:26:26 -0700 |
commit | 3e80f5fa9e07c935c328fd06de555cfd5f43ed26 (patch) | |
tree | aedd37e2d48bf41f94fa7e634b51a07fc8f71409 /tests | |
parent | 54a43675ba622c77dbbcc4ff12fa2c4a92578683 (diff) |
InformationElementUtil: Handle malformed scan results
Malformed scan results will leave the |protocol|, |keyManagement| and
|pairwiseCipher| fields in inconsistent after IE parsing. Handle this
in the |generateCapabilitiesString()| method.
This CL restores the handling of these malformed scan results prior to
ag/2285932.
Bug: 62154614
Test: Unit tests
Change-Id: I1e8998c9d951c7dc4e2d7163c80091fd40ca3672
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java | 82 |
1 files changed, 82 insertions, 0 deletions
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 f914da2f2..b9a8c31e3 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java @@ -271,6 +271,32 @@ public class InformationElementUtilTest { } /** + * Test Capabilities.generateCapabilitiesString() with a RSN IE which is malformed. + * Expect the function to return a string with empty key management & pairswise cipher security + * information. + */ + @Test + public void buildCapabilities_malformedRsnElement() { + InformationElement ie = new InformationElement(); + ie.id = InformationElement.EID_RSN; + ie.bytes = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x0F, + (byte) 0xAC, (byte) 0x02, (byte) 0x02, (byte) 0x00, + (byte) 0x00, (byte) 0x0F, (byte) 0xAC }; + + InformationElement[] ies = new InformationElement[] { ie }; + + BitSet beaconCap = new BitSet(16); + beaconCap.set(4); + + InformationElementUtil.Capabilities capabilities = + new InformationElementUtil.Capabilities(); + capabilities.from(ies, beaconCap); + String result = capabilities.generateCapabilitiesString(); + + assertEquals("[WPA2]", result); + } + + /** * Test Capabilities.generateCapabilitiesString() with a WPA type 1 IE. * Expect the function to return a string with the proper security information. */ @@ -299,6 +325,30 @@ public class InformationElementUtilTest { } /** + * Test Capabilities.generateCapabilitiesString() with a WPA type 1 IE which is malformed. + * Expect the function to return a string with empty key management & pairswise cipher security + * information. + */ + @Test + public void buildCapabilities_malformedWpa1Element() { + InformationElement ie = new InformationElement(); + ie.id = InformationElement.EID_VSA; + ie.bytes = new byte[] { (byte) 0x00, (byte) 0x50, (byte) 0xF2, (byte) 0x01, + (byte) 0x01, (byte) 0x00 }; + + InformationElement[] ies = new InformationElement[] { ie }; + + BitSet beaconCap = new BitSet(16); + beaconCap.set(4); + InformationElementUtil.Capabilities capabilities = + new InformationElementUtil.Capabilities(); + capabilities.from(ies, beaconCap); + String result = capabilities.generateCapabilitiesString(); + + assertEquals("[WPA]", result); + } + + /** * Test Capabilities.generateCapabilitiesString() with both RSN and WPA1 IE. * Expect the function to return a string with the proper security information. */ @@ -337,6 +387,38 @@ public class InformationElementUtilTest { } /** + * 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. + */ + @Test + public void buildCapabilities_malformedRsnAndWpaElement() { + InformationElement ieRsn = new InformationElement(); + ieRsn.id = InformationElement.EID_RSN; + ieRsn.bytes = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x0F, + (byte) 0xAC, (byte) 0x02, (byte) 0x02 }; + + InformationElement ieWpa = new InformationElement(); + ieWpa.id = InformationElement.EID_VSA; + ieWpa.bytes = new byte[] { (byte) 0x00, (byte) 0x50, (byte) 0xF2, (byte) 0x01, + (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x50, + (byte) 0xF2, (byte) 0x02, (byte) 0x02, (byte) 0x00, + (byte) 0x00, (byte) 0x50 }; + + InformationElement[] ies = new InformationElement[] { ieWpa, ieRsn }; + + BitSet beaconCap = new BitSet(16); + beaconCap.set(4); + + InformationElementUtil.Capabilities capabilities = + new InformationElementUtil.Capabilities(); + capabilities.from(ies, beaconCap); + String result = capabilities.generateCapabilitiesString(); + + assertEquals("[WPA][WPA2]", result); + } + + /** * Test Capabilities.generateCapabilitiesString() with both WPS and WPA1 IE. * Expect the function to return a string with the proper security information. */ |