mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Bug Fix:
When a 64 bit hex password is entered, wpa_supplicant fails with the error: "wpa_supplicant (pid) Line 0: Invalid passphrase length 64 (expected: 8..63)" The fix is to not quote 64 char long hexadecimal passwords. Tested dd-wrt on a 64 char hex password. git-svn-id: https://zxing.googlecode.com/svn/trunk@1468 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
7a8081f238
commit
b8f4061c39
|
@ -46,7 +46,7 @@ final class NetworkUtil {
|
|||
int lastPos = string.length() - 1;
|
||||
if (lastPos < 0 || (string.charAt(0) == '"' && string.charAt(lastPos) == '"')) {
|
||||
return string;
|
||||
}
|
||||
}
|
||||
return '\"' + string + '\"';
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ final class NetworkUtil {
|
|||
if (!(c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,12 +124,22 @@ public class WifiActivity extends Activity {
|
|||
// Adding a WPA or WPA2 network
|
||||
private int changeNetworkWPA(NetworkSetting input) {
|
||||
WifiConfiguration config = changeNetworkCommon(input);
|
||||
config.preSharedKey = NetworkUtil.convertToQuotedString(input.getPassword());
|
||||
final String pass = input.getPassword();
|
||||
// Hex passwords that are 64 bits long are not to be quoted.
|
||||
if (pass.matches("[0-9A-Fa-f]{64}")){
|
||||
Log.d(TAG, "A 64 bit hex password entered.");
|
||||
config.preSharedKey = pass;
|
||||
} else {
|
||||
Log.d(TAG, "A normal password entered: I am quoting it.");
|
||||
config.preSharedKey = NetworkUtil.convertToQuotedString(pass);
|
||||
}
|
||||
config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
|
||||
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
|
||||
// For WPA
|
||||
config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
|
||||
// For WPA2
|
||||
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
|
||||
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
|
||||
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
|
||||
config.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
|
||||
return requestNetworkChange(config);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue