Future<Uint8List> getChallenge() async {
Uint8List challengeApdu =
Uint8List.fromList([0x00, 0x84, 0x00, 0x00, 0x08]);
var response = await FlutterNfcKit.transceive(challengeApdu);
// Vérifier que la réponse contient bien 8 octets
if (response.length >= 8) {
Uint8List rndIc = Uint8List.fromList(response.sublist(0, 8));
print("Challenge correct (rndIc) : ${uint8ListToHex(rndIc)}");
return rndIc;
} else {
throw Exception("Challenge trop court !");
}
}
it gives me a correct challenge but when i try this one :
Uint8List apduCommand =
Uint8List.fromList([0x00, 0x82, 0x00, 0x00, 0x28, ...cmdData, 0x28]);
print("APDU envoyée : ${uint8ListToHex(apduCommand)}");
logMessage("APDU : ${uint8ListToHex(apduCommand)}");
// Envoi de la commande APDU
var response = await FlutterNfcKit.transceive(apduCommand);
print(
"Réponse brute de la carte : ${uint8ListToHex(Uint8List.fromList(response))}");
logMessage(
"Réponse brute de la carte : ${uint8ListToHex(Uint8List.fromList(response))}");
// Vérification du code d'erreur dans la réponse APDU
if (response.length >= 2) {
int statusCode1 = response[
response.length - 2]; // Penultimate byte (first byte of status)
int statusCode2 =
response[response.length - 1]; // Last byte (second byte of status)
print(
"Code d'erreur de la carte : 0x${statusCode1.toRadixString(16).padLeft(2, '0')} 0x${statusCode2.toRadixString(16).padLeft(2, '0')}");
// Vérification si l'authentification a réussi
if (statusCode1 == 0x90 && statusCode2 == 0x00) {
print("✅ Authentification externe réussie !");
} else {
print("❌ Authentification externe échouée !");
}
}
} catch (e) {
print("Erreur lors de l'envoi de l'APDU : $e");
}
}
the result is 6A88 error instead of 9000 the "cmd_data" has been calculated with the documentation of icao (when i try with the reference values from the docs i get the same results as the example)