@@ -0,0 +1,2595 @@
+import java.math.BigInteger;%0Aimport org.bouncycastle.crypto.CryptoException;%0Aimport org.bouncycastle.crypto.agreement.srp.SRP6Server;%0A%0A/** Custom extension of the BouncyCastle's default org.bouncycastle.crypto.agreement.srp.SRP6Server %0A * M1, M2, Key calculation methods added.%0A * @author Daniele Grasso%0A */%0Apublic class SRP6ServerCustom extends SRP6Server %7B%0A%09protected BigInteger M1;%0A%09protected BigInteger M2;%0A%09protected BigInteger Key;%0A%09%0A%09public SRP6ServerCustom()%7B%0A%09%09super();%0A%09%7D%0A%09%0A%09/** %0A%09 * Authenticates the received client evidence message M1 and saves it only if correct.%0A%09 * To be called after calculating the secret S.%0A%09 * @param M1: the client side generated evidence message%0A%09 * @return A boolean indicating if the client message M1 was the expected one.%0A%09 * @throws CryptoException %0A%09 */%0A%09public boolean verifyClientEvidenceMessage(BigInteger clientM1) throws CryptoException%7B%0A%09%09//verify pre-requirements%0A%09%09if ((this.A==null)%7C%7C(this.B==null)%7C%7C(this.S==null))%7B%0A%09%09%09throw new CryptoException(%22Impossible to compute and verify M1: some data are missing from the previous operations (A,B,S)%22);%0A%09%09%7D%0A%09%09// Compute the own client evidence message 'M1'%0A%09%09BigInteger computedM1 = SRP6UtilCustom.calculateM1(digest, A, B, S);%0A%09%09if (computedM1.equals(clientM1))%7B%0A%09%09%09this.M1 = clientM1;%0A%09%09%09return true;%0A%09%09%7D%0A%09%09return false;%0A%09%7D%0A%09%0A%09/**%0A%09 * Computes the server evidence message M2 using the previously verified values.%0A%09 * To be called after successfully verifying the client evidence message M1.%0A%09 * @return M2: the server side generated evidence message%0A%09 * @throws CryptoException%0A%09 */%0A%09public BigInteger calculateServerEvidenceMessage() throws CryptoException%7B%0A%09%09//verify pre-requirements%0A%09%09if ((this.A==null)%7C%7C(this.M1==null)%7C%7C(this.S==null))%7B%0A%09%09%09throw new CryptoException(%22Impossible to compute M2: some data are missing from the previous operations (A,M1,S)%22);%0A%09%09%7D%0A%09%09// Compute the server evidence message 'M2'%0A%09%09this.M2 = SRP6UtilCustom.calculateM2(digest, A, M1, S);  %0A%09%09return M2;%0A%09%7D%0A%09%0A%09/**%0A%09 * Computes the final session key as a result of the SRP successful mutual authentication%0A%09 * To be called after calculating the server evidence message M2.%0A%09 * @return Key: the mutual authenticated symmetric session key%0A%09 * @throws CryptoException%0A%09 */%0A%09public BigInteger calculateSessionKey() throws CryptoException%7B%0A%09%09//verify pre-requirements%0A%09%09if ((this.S==null)%7C%7C(this.M1==null)%7C%7C(this.M2==null))%7B%0A%09%09%09throw new CryptoException(%22Impossible to compute Key: some data are missing from the previous operations (S,M1,M2)%22);%0A%09%09%7D%0A%09%09this.Key = SRP6UtilCustom.calculateKey(digest,S);%0A%09%09return Key;%0A%09%7D%0A%7D%0A

Create SRP6ServerCustom.java