verifyServerEvidenceMessage method

  1. @override
bool verifyServerEvidenceMessage(
  1. BigInt serverM2
)
override

Authenticates the server evidence message M2 received and saves it only if correct. serverM2 the server side generated evidence message return A boolean indicating if the server message M2 was the expected one. throws Exception

Implementation

@override
bool verifyServerEvidenceMessage(BigInt serverM2) {
  // Verify pre-requirements
  if (A == null || M1 == null || S == null) {
    throw Exception('Impossible to compute and verify M2: '
        'some data are missing from the previous operations (A,M1,S)');
  }
  // Compute the own server evidence message 'M2'
  var computedM2 = SRP6Util.calculateM2(digest, N, A, M1, S);
  if (computedM2.compareTo(serverM2) == 0) {
    M2 = serverM2;
    return true;
  }
  return false;
}