I'm working on a Flutter app using the flutter_nfc_kit package to manage NFC cards (NTAG213). I have successfully implemented password protection for NTAG213 cards, but I am facing a critical issue while trying to remove the password.
The problem occurs when I modify the AUTH0 page during the password removal process. Specifically:
Here’s the specific part of my code related to the issue:
Future<bool> removePasswordProtection({
required List<int> password,
}) async {
try {
setStatus('Checking NFC availability...');
var availability = await FlutterNfcKit.nfcAvailability;
if (availability != NFCAvailability.available) {
setStatus('NFC not available');
return false;
}
setStatus('Scanning for NFC tag...');
setScanning(true);
var tag = await FlutterNfcKit.poll(
timeout: const Duration(seconds: 10), androidCheckNDEF: true);
setStatus('Checking if card is NTAG213...');
if (!await isNTAG213(tag)) {
setStatus('Not an NTAG213 card');
return false;
}
setStatus('Attempting authentication...');
var authCommand = Uint8List.fromList([
0x1B, // PWD_AUTH command
password[0],
password[1],
password[2],
password[3]
]);
try {
var authResponse = await FlutterNfcKit.transceive(authCommand);
print('Auth Response: ${authResponse.map((e) => e.toRadixString(16).padLeft(2, '0')).join(' ')}');
if (authResponse.length < 2) {
setStatus('Authentication failed: Invalid response');
return false;
}
} catch (e) {
setStatus('Authentication Error: $e');
return false;
}
// Remove password
await FlutterNfcKit.transceive(
Uint8List.fromList([0xA2, 0x2B, 0xFF, 0xFF, 0xFF, 0xFF])); // Clear password
await FlutterNfcKit.transceive(
Uint8List.fromList([0xA2, 0x2C, 0x00, 0x00, 0x00, 0x00])); // Clear PACK
await FlutterNfcKit.transceive(
Uint8List.fromList([0xA2, 0x29, 0xFF, 0x00, 0x00, 0x00])); // Modify AUTH0
setStatus('Password protection reset successfully');
await FlutterNfcKit.finish();
setScanning(false);
return true;
} catch (e) {
setStatus('Error: $e');
await FlutterNfcKit.finish();
setScanning(false);
return false;
}
}
Setting the AUTH0 page value to:
Confirming that the card is indeed NTAG213 using a capability container check.
Writing and verifying the password during the protection setup process works as expected.
Any insights or guidance on resolving this issue would be greatly appreciated!
Hi @Fabian_R ,
Thank you for your detailed response and for sharing insights. Your explanation was really helpful, and I truly appreciate the effort you put into guiding me.
A big apology for my very late reply—I genuinely appreciate your patience. Kudos to you for the great support!
Thanks again for your time and assistance!
Best regards,
Kamal
Hello, Thank you for your interest in our products.
AUTH0 is intended to be used for defining the starting page address of the protected area in Sector 0. Please take a look at the Memory Organization of the NTAG I2C. The starting address for AUTH0 is shown in the following image:
This is from section 8.3.1 Memory map from NFC perspective. Please keep in mind that the value cant exceed 0xE0. 0xFF will result in an error that could lock the NTAG.
Unfortunately, the use of Flutter is out of my scope but, please take a look at RFIDDiscover for configuring the NTAGs using a GUI. The output log of this action will help you for implementing it to your Flutter application.