summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient/LeapSRPSession.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-05-29 19:54:26 +0200
committerParménides GV <parmegv@sdf.org>2013-05-29 19:54:26 +0200
commit7b75fbe9ca3b2d6175b124b26f5d8f527b15d1bd (patch)
tree56a4b5d0f91fba8695847c15de5dffe440a6c43e /src/se/leap/leapclient/LeapSRPSession.java
parentc76baffeb884aa9bc7bfdd481fe57312c736c390 (diff)
Fixed passwords with strange characters?
Using two test with values from my localhost leap_web deployment, I've achieved to login with passwords containing ! and $ without problems. This should fix bug #2348.
Diffstat (limited to 'src/se/leap/leapclient/LeapSRPSession.java')
-rw-r--r--src/se/leap/leapclient/LeapSRPSession.java21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/se/leap/leapclient/LeapSRPSession.java b/src/se/leap/leapclient/LeapSRPSession.java
index 7b32e791..715e9de1 100644
--- a/src/se/leap/leapclient/LeapSRPSession.java
+++ b/src/se/leap/leapclient/LeapSRPSession.java
@@ -95,35 +95,24 @@ public class LeapSRPSession {
MessageDigest x_digest = newDigest();
// Try to convert the username to a byte[] using UTF-8
byte[] user = null;
+ byte[] password_bytes = null;
byte[] colon = {};
try {
user = Util.trim(username.getBytes("UTF-8"));
colon = Util.trim(":".getBytes("UTF-8"));
+ password_bytes = Util.trim(password.getBytes("UTF-8"));
}
catch(UnsupportedEncodingException e) {
// Use the default platform encoding
user = Util.trim(username.getBytes());
colon = Util.trim(":".getBytes());
+ password_bytes = Util.trim(password.getBytes());
}
-
- byte[] passBytes = new byte[2*password.toCharArray().length];
- int passBytesLength = 0;
- for(int p = 0; p < password.toCharArray().length; p++) {
- int c = (password.toCharArray()[p] & 0x00FFFF);
- // The low byte of the char
- byte b0 = (byte) (c & 0x0000FF);
- // The high byte of the char
- byte b1 = (byte) ((c & 0x00FF00) >> 8);
- passBytes[passBytesLength ++] = b0;
- // Only encode the high byte if c is a multi-byte char
- if( c > 255 )
- passBytes[passBytesLength ++] = b1;
- }
-
+
// Build the hash
x_digest.update(user);
x_digest.update(colon);
- x_digest.update(passBytes, 0, passBytesLength);
+ x_digest.update(password_bytes);
byte[] h = x_digest.digest();
//h = Util.trim(h);