getChallenge method

Future<Uint8List> getChallenge({
  1. required int challengeLength,
  2. int cla = ISO7816_CLA.NO_SM,
})

Sends GET CHALLENGE command to ICC and ICC should return challengeLength long challenge. Can throw ICCError or ComProviderError.

Implementation

Future<Uint8List> getChallenge({ required int challengeLength, int cla = ISO7816_CLA.NO_SM }) async {
  final rapdu = await _transceive(
    CommandAPDU(cla: cla, ins: ISO7816_INS.GET_CHALLENGE, p1: 0x00, p2: 0x00, ne: challengeLength)
  );
  if(rapdu.status != StatusWord.success) {
    throw ICCError("Get challenge failed", rapdu.status, rapdu.data);
  }
  return rapdu.data!;
}