challenge method

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

This method is called by the session if the router returns the challenge or the challenges extra respectively. This method uses the passed hex encoded challenge and signs it with the given private key

Implementation

@override
Future<Authenticate> challenge(Extra extra) {
  if (extra.channelBinding != channelBinding) {
    return Future.error(Exception('Channel Binding does not match'));
  }
  if (extra.challenge!.length % 2 != 0) {
    return Future.error(Exception('Wrong challenge length'));
  }
  var authenticate = Authenticate();

  authenticate.extra = HashMap<String, Object?>();
  authenticate.extra!['channel_binding'] = channelBinding;
  var binaryChallenge = hexToBin(extra.challenge);
  authenticate.signature =
      privateKey.sign(binaryChallenge).encode(Base16Encoder.instance);
  return Future.value(authenticate);
}