diff options
author | Parménides GV <parmegv@sdf.org> | 2013-06-20 17:47:07 +0200 |
---|---|---|
committer | Parménides GV <parmegv@sdf.org> | 2013-06-20 17:47:07 +0200 |
commit | 65e2f56a8a10877964fb9fc57963d1bf8104801a (patch) | |
tree | 101aedd9ca3c9a66f9f109c5ec45f6cfaa2aaccf /src/se/leap/leapclient/ConfigHelper.java | |
parent | f4956bb818fb9ed04760e6de3b53b876272da5cc (diff) |
No binary library needed.
I've decided not to include any lib, but to copy the SRPParameters class
to our codebase and Util.trim method to ConfigHelper.
Diffstat (limited to 'src/se/leap/leapclient/ConfigHelper.java')
-rw-r--r-- | src/se/leap/leapclient/ConfigHelper.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/se/leap/leapclient/ConfigHelper.java b/src/se/leap/leapclient/ConfigHelper.java index cb4a550f..dd20112c 100644 --- a/src/se/leap/leapclient/ConfigHelper.java +++ b/src/se/leap/leapclient/ConfigHelper.java @@ -208,6 +208,26 @@ public class ConfigHelper { } /** + * Treat the input as the MSB representation of a number, + * and lop off leading zero elements. For efficiency, the + * input is simply returned if no leading zeroes are found. + * + * @param in array to be trimmed + */ + public static byte[] trim(byte[] in) { + if(in.length == 0 || in[0] != 0) + return in; + + int len = in.length; + int i = 1; + while(in[i] == 0 && i < len) + ++i; + byte[] ret = new byte[len - i]; + System.arraycopy(in, i, ret, 0, len - i); + return ret; + } + + /** * Sets class scope Shared Preferences * @param shared_preferences */ |