summaryrefslogtreecommitdiffstats
path: root/wifi
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2012-03-27 20:42:15 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-03-27 20:42:15 -0700
commit4898087be98d9df1b6c86cc1802894e1844c6e3d (patch)
tree228ec8065abbb712c9c228af2255d8e8e3a025b0 /wifi
parentfa7887bebf57f3dcb8283d73e69ba1daa115225f (diff)
parent565f9f216aa87f11d451ae6532d5153001a386bf (diff)
downloadframeworks_base-4898087be98d9df1b6c86cc1802894e1844c6e3d.zip
frameworks_base-4898087be98d9df1b6c86cc1802894e1844c6e3d.tar.gz
frameworks_base-4898087be98d9df1b6c86cc1802894e1844c6e3d.tar.bz2
Merge changes Ibdf23227,I3681f98c
* changes: Update Wifi to use new keystore function Add signing to keystore
Diffstat (limited to 'wifi')
-rw-r--r--wifi/java/android/net/wifi/WifiConfigStore.java63
-rw-r--r--wifi/java/android/net/wifi/WifiConfiguration.java35
2 files changed, 94 insertions, 4 deletions
diff --git a/wifi/java/android/net/wifi/WifiConfigStore.java b/wifi/java/android/net/wifi/WifiConfigStore.java
index 5dec269..a9dbd10 100644
--- a/wifi/java/android/net/wifi/WifiConfigStore.java
+++ b/wifi/java/android/net/wifi/WifiConfigStore.java
@@ -25,6 +25,7 @@ import android.net.NetworkUtils;
import android.net.NetworkInfo.DetailedState;
import android.net.ProxyProperties;
import android.net.RouteInfo;
+import android.net.wifi.WifiConfiguration.EnterpriseField;
import android.net.wifi.WifiConfiguration.IpAssignment;
import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.net.wifi.WifiConfiguration.ProxySettings;
@@ -1140,7 +1141,7 @@ class WifiConfigStore {
String varName = field.varName();
String value = field.value();
if (value != null) {
- if (field != config.eap) {
+ if (field != config.eap && field != config.engine) {
value = (value.length() == 0) ? "NULL" : convertToQuotedString(value);
}
if (!mWifiNative.setNetworkVariable(
@@ -1449,10 +1450,68 @@ class WifiConfigStore {
value = mWifiNative.getNetworkVariable(netId,
field.varName());
if (!TextUtils.isEmpty(value)) {
- if (field != config.eap) value = removeDoubleQuotes(value);
+ if (field != config.eap && field != config.engine) {
+ value = removeDoubleQuotes(value);
+ }
field.setValue(value);
}
}
+
+ migrateOldEapTlsIfNecessary(config, netId);
+ }
+
+ /**
+ * Migration code for old EAP-TLS configurations. This should only be used
+ * when restoring an old wpa_supplicant.conf or upgrading from a previous
+ * platform version.
+ *
+ * @param config the configuration to be migrated
+ * @param netId the wpa_supplicant's net ID
+ * @param value the old private_key value
+ */
+ private void migrateOldEapTlsIfNecessary(WifiConfiguration config, int netId) {
+ String value = mWifiNative.getNetworkVariable(netId,
+ WifiConfiguration.OLD_PRIVATE_KEY_NAME);
+ /*
+ * If the old configuration value is not present, then there is nothing
+ * to do.
+ */
+ if (TextUtils.isEmpty(value)) {
+ return;
+ } else {
+ // Also ignore it if it's empty quotes.
+ value = removeDoubleQuotes(value);
+ if (TextUtils.isEmpty(value)) {
+ return;
+ }
+ }
+
+ config.engine.setValue(WifiConfiguration.ENGINE_ENABLE);
+ config.engine_id.setValue(convertToQuotedString(WifiConfiguration.KEYSTORE_ENGINE_ID));
+
+ /*
+ * The old key started with the keystore:// URI prefix, but we don't
+ * need that anymore. Trim it off if it exists.
+ */
+ final String keyName;
+ if (value.startsWith(WifiConfiguration.KEYSTORE_URI)) {
+ keyName = new String(value.substring(WifiConfiguration.KEYSTORE_URI.length()));
+ } else {
+ keyName = value;
+ }
+ config.key_id.setValue(convertToQuotedString(keyName));
+
+ // Now tell the wpa_supplicant the new configuration values.
+ final EnterpriseField needsUpdate[] = { config.engine, config.engine_id, config.key_id };
+ for (EnterpriseField field : needsUpdate) {
+ mWifiNative.setNetworkVariable(netId, field.varName(), field.value());
+ }
+
+ // Remove old private_key string so we don't run this again.
+ mWifiNative.setNetworkVariable(netId, WifiConfiguration.OLD_PRIVATE_KEY_NAME,
+ convertToQuotedString(""));
+
+ saveConfig();
}
private String removeDoubleQuotes(String string) {
diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java
index 85a6f27..dfc1b18 100644
--- a/wifi/java/android/net/wifi/WifiConfiguration.java
+++ b/wifi/java/android/net/wifi/WifiConfiguration.java
@@ -29,6 +29,33 @@ import java.util.BitSet;
*/
public class WifiConfiguration implements Parcelable {
+ /**
+ * In old configurations, the "private_key" field was used. However, newer
+ * configurations use the key_id field with the engine_id set to "keystore".
+ * If this field is found in the configuration, the migration code is
+ * triggered.
+ * @hide
+ */
+ public static final String OLD_PRIVATE_KEY_NAME = "private_key";
+
+ /**
+ * String representing the keystore OpenSSL ENGINE's ID.
+ * @hide
+ */
+ public static final String KEYSTORE_ENGINE_ID = "keystore";
+
+ /**
+ * String representing the keystore URI used for wpa_supplicant.
+ * @hide
+ */
+ public static final String KEYSTORE_URI = "keystore://";
+
+ /**
+ * String to set the engine value to when it should be enabled.
+ * @hide
+ */
+ public static final String ENGINE_ENABLE = "1";
+
/** {@hide} */
public static final String ssidVarName = "ssid";
/** {@hide} */
@@ -82,14 +109,18 @@ public class WifiConfiguration implements Parcelable {
/** {@hide} */
public EnterpriseField client_cert = new EnterpriseField("client_cert");
/** {@hide} */
- public EnterpriseField private_key = new EnterpriseField("private_key");
+ public EnterpriseField engine = new EnterpriseField("engine");
+ /** {@hide} */
+ public EnterpriseField engine_id = new EnterpriseField("engine_id");
+ /** {@hide} */
+ public EnterpriseField key_id = new EnterpriseField("key_id");
/** {@hide} */
public EnterpriseField ca_cert = new EnterpriseField("ca_cert");
/** {@hide} */
public EnterpriseField[] enterpriseFields = {
eap, phase2, identity, anonymous_identity, password, client_cert,
- private_key, ca_cert };
+ engine, engine_id, key_id, ca_cert };
/**
* Recognized key management schemes.