From 2940e4b1659db5d566b0c429f1b81d1d479bd708 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Wed, 28 Jun 2017 11:39:42 -0700 Subject: WifiConfigurationUtil: PSK hex string length should be 64 The length check was using an incorrect value of 128 in validatePsk(). Bug: 62987438 Test: Unit test Change-Id: I04c985946cec18cd07d40d35f22b3c14130abee2 --- service/java/com/android/server/wifi/WifiConfigurationUtil.java | 2 +- .../src/com/android/server/wifi/WifiConfigurationUtilTest.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/service/java/com/android/server/wifi/WifiConfigurationUtil.java b/service/java/com/android/server/wifi/WifiConfigurationUtil.java index a7a527b05..f706c4e1f 100644 --- a/service/java/com/android/server/wifi/WifiConfigurationUtil.java +++ b/service/java/com/android/server/wifi/WifiConfigurationUtil.java @@ -54,7 +54,7 @@ public class WifiConfigurationUtil { private static final int SSID_HEX_MAX_LEN = 64; private static final int PSK_ASCII_MIN_LEN = 8 + ENCLOSING_QUTOES_LEN; private static final int PSK_ASCII_MAX_LEN = 63 + ENCLOSING_QUTOES_LEN; - private static final int PSK_HEX_LEN = 128; + private static final int PSK_HEX_LEN = 64; @VisibleForTesting public static final String PASSWORD_MASK = "*"; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java index cc3f7092a..376d686a4 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java @@ -217,8 +217,7 @@ public class WifiConfigurationUtilTest { public void testValidatePositiveCases_Hex() { WifiConfiguration config = WifiConfigurationTestUtil.createPskNetwork(); config.SSID = "abcd1234555a"; - config.preSharedKey = "abcd1234551512345567889900345566673323456673223445566767432334454" - + "abcd12345515123455678899003455666733234566732234455667674323344"; + config.preSharedKey = "abcd123455151234556788990034556667332345667322344556676743233445"; assertTrue(WifiConfigurationUtil.validate(config, WifiConfigurationUtil.VALIDATE_FOR_ADD)); } -- cgit v1.2.3