diff options
author | Jimmy Chen <jimmycmchen@google.com> | 2020-05-25 08:13:24 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-05-25 08:13:24 +0000 |
commit | c9efaf56af99aaf43787fd738a709d20f741f7c4 (patch) | |
tree | 40b4daf3e56f082c06d1124a3406f38a49cc3ad8 /service | |
parent | bd49dba53e859da8640a7cd1b5c17e86ef957da3 (diff) | |
parent | d0c5cc895c14558191d4e4893ad9676c8e338641 (diff) |
Merge "wifi: update passphrase after configuring security type" into rvc-dev am: 573ce2e5a0 am: d0c5cc895c
Change-Id: Ic333def12af9f4689b0b2c659f2f86e48f5c0a22
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()) { |