From 3ab74308e7ba1fda02d3427ec795eac397707199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 5 May 2014 15:13:47 +0200 Subject: Sign up methods to be tested. --- .../java/se/leap/bitmaskclient/LeapSRPSession.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java index a317d95e..db091300 100644 --- a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java +++ b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java @@ -155,12 +155,25 @@ public class LeapSRPSession { return x_digest_bytes; } + public byte[] calculateSaltedPassword() { + try { + BigInteger salt = new BigInteger(128, SecureRandom.getInstance("SHA1PRNG")); + MessageDigest salted_password = newDigest(); + salted_password.update(salt.toByteArray()); + salted_password.update(password.getBytes()); + return salted_password.digest(); + } catch (NoSuchAlgorithmException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } /** * Calculates the parameter V of the SRP-6a algorithm. - * @param k_string constant k predefined by the SRP server implementation. * @return the value of V */ - private BigInteger calculateV(String k_string) { + public BigInteger calculateV() { + String k_string = "bf66c44a428916cad64aa7c679f3fd897ad4c375e9bbb4cbf2f5de241d618ef0"; BigInteger k = new BigInteger(k_string, 16); BigInteger v = k.multiply(g.modPow(x, N)); // g^x % N return v; @@ -217,8 +230,7 @@ public class LeapSRPSession { this.x = new BigInteger(1, xb); // Calculate v = kg^x mod N - String k_string = "bf66c44a428916cad64aa7c679f3fd897ad4c375e9bbb4cbf2f5de241d618ef0"; - this.v = calculateV(k_string); + this.v = calculateV(); // H(N) byte[] digest_of_n = newDigest().digest(N_bytes); -- cgit v1.2.3