step3 method

void step3(
  1. BigInt m2
)

Implementation

void step3(final BigInt m2) {
  this.m2 = m2;

  if (state != SrpState.step2) {
    throw IllegalStateException(
        "State violation: Session must be in STEP_2 state");
  }

  if (hasTimedOut()) {
    throw SRP6Exception("Session timeout", CauseType.timeout);
  }

  BigInt computedM2;

  if (serverEvidenceRoutine != null) {
    SRP6ServerEvidenceContext ctx = SRP6ServerEvidenceContext(A!, m1!, S!);
    computedM2 = serverEvidenceRoutine!.computeServerEvidence(config!, ctx);
  } else {
    Hash digest = config!.getMessageDigestInstance();
    computedM2 = SRP6Routines.computeServerEvidence(digest, A!, m1!, S!);
  }

  if (computedM2 != m2) {
    throw SRP6Exception("Bad server credentials", CauseType.badCredentials);
  }

  state = SrpState.step3;

  updateLastActivityTime();
}