-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MIFARE Classic example is misleading #80
Comments
Hi @michaelroland, thank you very much for reporting the issue here and for answering the question on Stack Overflow. I've rewritten the MIFARE Classic example to remove all the misleading information and to clarify how the MIFARE Classic authentication works. Here is the current version: https://github.com/pokusew/nfc-pcsc/blob/master/examples/mifare-classic.js Feel free to post your thoughts or suggestions here. Thank you very much for your time. 🙂 |
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: