@@ -0,0 +1,2451 @@
+import java.math.BigInteger;%0Aimport org.bouncycastle.crypto.Digest;%0Aimport org.bouncycastle.crypto.agreement.srp.SRP6Util;%0A%0A/**%0A *  Custom extension of the BouncyCastle's default org.bouncycastle.crypto.agreement.srp.SRP6Util, %0A *  adding the methods for the calculation of M1, M2, and Key%0A * @author Daniele Grasso%0A */%0Apublic class SRP6UtilCustom extends SRP6Util %7B%0A%0A%09/**%0A%09 * Computes the client evidence message (M1) according to the standard routine:%0A%09 * M1 = H( A %7C B %7C S )%0A%09 * @param digest The Digest used as the hashing function H%0A%09 * @param A The public client value%0A%09 * @param B The public server value%0A%09 * @param S The secret calculated by both sides%0A%09 * @return M1 The calculated client evidence message%0A%09 */%0A%09public static BigInteger calculateM1(Digest digest, BigInteger A, BigInteger B, BigInteger S) %7B%0A%09%09byte%5B%5D _output = new byte%5Bdigest.getDigestSize()%5D;%0A%09%09byte%5B%5D _A = A.toByteArray();%0A%09%09byte%5B%5D _B = B.toByteArray();%0A%09%09byte%5B%5D _S = S.toByteArray();%0A%09%09digest.update(_A, 0, _A.length);%0A%09%09digest.update(_B, 0, _B.length);%0A%09%09digest.update(_S, 0, _S.length);%0A%09%09digest.doFinal(_output, 0);%0A%09%09BigInteger M1 = new BigInteger(1, _output);%0A%09%09return M1;%0A%09%7D%0A%0A%09/**%0A%09 * Computes the server evidence message (M2) according to the standard routine:%0A%09 * M2 = H( A %7C M1 %7C S )%0A%09 * @param digest The Digest used as the hashing function H%0A%09 * @param A The public client value%0A%09 * @param M1 The client evidence message%0A%09 * @param S The secret calculated by both sides%0A%09 * @return M2 The calculated server evidence message%0A%09 */%0A%09public static BigInteger calculateM2(Digest digest, BigInteger A, BigInteger M1, BigInteger S)%7B%0A%09%09byte%5B%5D _output = new byte%5Bdigest.getDigestSize()%5D;%0A%09%09byte%5B%5D _A = A.toByteArray();%0A%09%09byte%5B%5D _M1 = M1.toByteArray();%0A%09%09byte%5B%5D _S = S.toByteArray();%0A%09%09digest.update(_A, 0, _A.length);%0A%09%09digest.update(_M1,0,_M1.length);%0A%09%09digest.update(_S, 0, _S.length);%0A%09%09digest.doFinal(_output, 0);%0A%09%09BigInteger M2 = new BigInteger(1, _output);%0A%09%09return M2;%0A%09%7D%0A%0A%09/**%0A%09 * Computes the final Key according to the standard routine: Key = H(S)%0A%09 * @param digest The Digest used as the hashing function H%0A%09 * @param S The secret calculated by both sides%0A%09 * @return%0A%09 */%0A%09public static BigInteger calculateKey(Digest digest, BigInteger S) %7B%0A%09%09byte%5B%5D _output = new byte%5Bdigest.getDigestSize()%5D;%0A%09%09byte%5B%5D _S = S.toByteArray();%0A%09%09digest.update(_S, 0, _S.length);%0A%09%09digest.doFinal(_output, 0);%0A%09%09BigInteger Key = new BigInteger(1, _output);%0A%09%09return Key;%0A%09%7D%0A%7D%0A

Create SRP6UtilCustom.java