challenge method

  1. @override
Future<Authenticate> challenge(
  1. Extra extra
)
override

This method accepts the servers challenge and responds with the according authentication method, that is to be sent to the server to authenticate the session. It calculates the client proof according to the WAMP-SCRAM specs where authId is the username that has already been saslpreped with Saslprep.saslprep(input) and helloNonce is a randomly generated nonce according to the WAMP-SCRAM specs. The keylength is 32 according to the WAMP-SCRAM specs

Implementation

@override
Future<Authenticate> challenge(Extra extra) {
  if (extra.nonce == null ||
      _helloNonce == null ||
      !_helloNonce!
          .contains(extra.nonce!.substring(0, _helloNonce!.length))) {
    return Future.error(Exception('Wrong nonce'));
  }

  if (extra.kdf != kdfArgon && extra.kdf != kdfPbkdf2) {
    return Future.error(Exception(
        'not supported key derivation function used ${extra.kdf!}'));
  }

  var authenticate = Authenticate();

  authenticate.extra = HashMap<String, Object?>();
  authenticate.extra!['nonce'] = extra.nonce;
  authenticate.extra!['channel_binding'] = null;
  authenticate.extra!['cbind_data'] = null;

  authenticate.signature = createSignature(_authid!, _helloNonce!, extra,
      authenticate.extra as HashMap<String, Object?>);
  return Future.value(authenticate);
}