summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient/ConfigHelper.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-06-20 17:47:07 +0200
committerParménides GV <parmegv@sdf.org>2013-06-20 17:47:07 +0200
commit65e2f56a8a10877964fb9fc57963d1bf8104801a (patch)
tree101aedd9ca3c9a66f9f109c5ec45f6cfaa2aaccf /src/se/leap/leapclient/ConfigHelper.java
parentf4956bb818fb9ed04760e6de3b53b876272da5cc (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.java20
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
*/