You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current example for MIFARE Classic is misleading with regard to authentication. The example file currently suggests to do authentication for multiple sectors (and possible with multiple keys) before doing actual read/write operations:
// reader.authenticate(8, keyType, key), // add other lines to authenticate more blocks, resp. sectors
]);
// Note: writing might require to authenticate with a different key (based on the sector access rights)
However, this is not how MIFARE Classic authentication works. MIFARE Classic will only grant permissions based on the last authentication attempt. Consequently, if multiple reader.authenticate(...) commands are used, only the last one has an effect on all subsequent read/write operations.
Therefore, you would first authenticate to a specific sector. You can then read from/write to the blocks of that sector (subject to access conditions for the authenticated key). Only after that, you would want to authenticate to the next sector with a specific key to be able to read from/write to the blocks of that other sector.
E.g. like this:
constkey_a='FFFFFFFFFFFF';constkeyTypeA=KEY_TYPE_A;awaitreader.authenticate(4,keyTypeA,key_a);pretty.info(`sector authenticated`);constdata1=awaitreader.read(4,48,16);pretty.info(`data read for sector 1`,data1);awaitreader.authenticate(8,keyTypeA,key_a);constdata2=awaitreader.read(8,48,16);pretty.info(`data read for sector 2`,data2);
The text was updated successfully, but these errors were encountered:
Note that this issue is also discussed on StackOverflow: Error 6800 on reading 2nd sector and more of a MIFARE Classic card.
The current example for MIFARE Classic is misleading with regard to authentication. The example file currently suggests to do authentication for multiple sectors (and possible with multiple keys) before doing actual read/write operations:
nfc-pcsc/examples/mifare-classic.js
Lines 87 to 92 in d743ef6
However, this is not how MIFARE Classic authentication works. MIFARE Classic will only grant permissions based on the last authentication attempt. Consequently, if multiple
reader.authenticate(...)
commands are used, only the last one has an effect on all subsequent read/write operations.Therefore, you would first authenticate to a specific sector. You can then read from/write to the blocks of that sector (subject to access conditions for the authenticated key). Only after that, you would want to authenticate to the next sector with a specific key to be able to read from/write to the blocks of that other sector.
E.g. like this:
The text was updated successfully, but these errors were encountered: