/** * Return the value M(2) that should be sent to the client * * @return M(2) */ public BigInteger getEvidenceValue_M2() { if (fEvidenceValue_M1 == null) { throw new IllegalStateException("computeCommonValue_S() has not been called yet."); } return SRPUtils.calcM2(fPublicKey_A, fEvidenceValue_M1, fCommonValue_S); }
/** * When the server sends M(2), call this method to validate the number. * * @param evidenceValueFromServer_M2 M(2) from the server. * @throws SRPAuthenticationFailedException if M(2) is incorrect */ public void validateServerEvidenceValue_M2(BigInteger evidenceValueFromServer_M2) throws SRPAuthenticationFailedException { if (fEvidenceValue_M1 == null) { throw new IllegalStateException("computeCommonValue_S() has not been called yet."); } BigInteger M2 = SRPUtils.calcM2(fPublicKey_A, fEvidenceValue_M1, fCommonValue_S); if (!evidenceValueFromServer_M2.equals(M2)) { throw new SRPAuthenticationFailedException("M(2) is incorrect"); } }