diff options
author | Jimmy Chen <jimmycmchen@google.com> | 2020-05-25 07:28:33 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-05-25 07:28:33 +0000 |
commit | 573ce2e5a0fdad896804f6a2408b6802c29588dd (patch) | |
tree | 66c6a8df83b8a825c112fdb88884126fa304e71b /service | |
parent | 8dddd90021f0d9419a3caf4cd07ba4c5af8746c7 (diff) | |
parent | 00cc98847315c3887f8c0119088843e2fd7edcba (diff) |
Merge "wifi: update passphrase after configuring security type" into rvc-dev
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/SupplicantStaNetworkHal.java | 111 |
1 files changed, 55 insertions, 56 deletions
diff --git a/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java b/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java index cfbbfad0e..68623fb7e 100644 --- a/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java +++ b/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java @@ -303,62 +303,6 @@ public class SupplicantStaNetworkHal { return false; } } - /** Pre Shared Key */ - // For PSK, this can either be quoted ASCII passphrase or hex string for raw psk. - // For SAE, password must be a quoted ASCII string - if (config.preSharedKey != null) { - if (config.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WAPI_PSK)) { - if (!setPskPassphrase(config.preSharedKey)) { - Log.e(TAG, "failed to set wapi psk passphrase"); - return false; - } - } else if (config.preSharedKey.startsWith("\"")) { - if (config.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.SAE)) { - /* WPA3 case, field is SAE Password */ - if (!setSaePassword( - NativeUtil.removeEnclosingQuotes(config.preSharedKey))) { - Log.e(TAG, "failed to set sae password"); - return false; - } - } else { - if (!setPskPassphrase( - NativeUtil.removeEnclosingQuotes(config.preSharedKey))) { - Log.e(TAG, "failed to set psk passphrase"); - return false; - } - } - } else { - if (config.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.SAE)) { - return false; - } - if (!setPsk(NativeUtil.hexStringToByteArray(config.preSharedKey))) { - Log.e(TAG, "failed to set psk"); - return false; - } - } - } - - /** Wep Keys */ - boolean hasSetKey = false; - if (config.wepKeys != null) { - for (int i = 0; i < config.wepKeys.length; i++) { - if (config.wepKeys[i] != null) { - if (!setWepKey( - i, NativeUtil.hexOrQuotedStringToBytes(config.wepKeys[i]))) { - Log.e(TAG, "failed to set wep_key " + i); - return false; - } - hasSetKey = true; - } - } - } - /** Wep Tx Key Idx */ - if (hasSetKey) { - if (!setWepTxKeyIdx(config.wepTxKeyIndex)) { - Log.e(TAG, "failed to set wep_tx_keyidx: " + config.wepTxKeyIndex); - return false; - } - } /** HiddenSSID */ if (!setScanSsid(config.hiddenSSID)) { Log.e(TAG, config.SSID + ": failed to set hiddenSSID: " + config.hiddenSSID); @@ -414,6 +358,61 @@ public class SupplicantStaNetworkHal { Log.e(TAG, "failed to set PairwiseCipher"); return false; } + /** Pre Shared Key */ + // For PSK, this can either be quoted ASCII passphrase or hex string for raw psk. + // For SAE, password must be a quoted ASCII string + if (config.preSharedKey != null) { + if (config.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WAPI_PSK)) { + if (!setPskPassphrase(config.preSharedKey)) { + Log.e(TAG, "failed to set wapi psk passphrase"); + return false; + } + } else if (config.preSharedKey.startsWith("\"")) { + if (config.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.SAE)) { + /* WPA3 case, field is SAE Password */ + if (!setSaePassword( + NativeUtil.removeEnclosingQuotes(config.preSharedKey))) { + Log.e(TAG, "failed to set sae password"); + return false; + } + } else { + if (!setPskPassphrase( + NativeUtil.removeEnclosingQuotes(config.preSharedKey))) { + Log.e(TAG, "failed to set psk passphrase"); + return false; + } + } + } else { + if (config.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.SAE)) { + return false; + } + if (!setPsk(NativeUtil.hexStringToByteArray(config.preSharedKey))) { + Log.e(TAG, "failed to set psk"); + return false; + } + } + } + /** Wep Keys */ + boolean hasSetKey = false; + if (config.wepKeys != null) { + for (int i = 0; i < config.wepKeys.length; i++) { + if (config.wepKeys[i] != null) { + if (!setWepKey( + i, NativeUtil.hexOrQuotedStringToBytes(config.wepKeys[i]))) { + Log.e(TAG, "failed to set wep_key " + i); + return false; + } + hasSetKey = true; + } + } + } + /** Wep Tx Key Idx */ + if (hasSetKey) { + if (!setWepTxKeyIdx(config.wepTxKeyIndex)) { + Log.e(TAG, "failed to set wep_tx_keyidx: " + config.wepTxKeyIndex); + return false; + } + } /** metadata: FQDN + ConfigKey + CreatorUid */ final Map<String, String> metadata = new HashMap<String, String>(); if (config.isPasspoint()) { |