pokusew / nfc-pcsc

Easy reading and writing NFC tags and cards in Node.js
MIT License
535 stars 132 forks source link

Mifare DESfire EV2 2k - error in step 2 - authenticate #131

Open SomeDevWeb opened 2 years ago

SomeDevWeb commented 2 years ago

Hi all, I am quite new in the NFC world, so I apologise for any silly things I say, but I have a Mifare DESfire EV2 2k that already has some employee data and I just need to get the ID from it. I installed this awesome vfc-pcsc package and I tried a Mifare Classic card, which worked fine with the "mifare-classic" example, but when I tried the "mifare-desfire" to read the DESfire EV2 2k, I get this error: This is the whole return code actually

[step 1 - select app] sending <Buffer 90 5a 00 00 03 00 00 00 00>
[step 1 - select app] received data <Buffer 91 00>
[step 2 - authenticate] sending <Buffer 90 0a 00 00 01 00 00>
[step 2 - authenticate] received data <Buffer 91 ae>
11:51:15 – ACS ACR1252 CL Reader PICC 0 error: error occurred during processing steps Error: error in step 2 - authenticate
    at authenticate (C:\Users\User\nfc-pcsc\examples\/mifare-desfire.js:103:11)
    at ACR122Reader.<anonymous> (C:\Users\User\nfc-pcsc\examples\/mifare-desfire.js:175:4)

I read and heard from a person that the card needs to have an original encryption key in order to authenticate. Is that correct? In any case, please shed some light on how to read this type of card. Thank you so much for your help!!!

bohdandakhno commented 2 years ago

Hi,

I'm also new to the NFC, but I've noticed a method loadAuthenticationKey() https://github.com/pokusew/nfc-pcsc/blob/8f47cf9e623f45d8318a13460084068889f76ede/src/Reader.js#L342 in the class Reader , which takes the key you pass and transmits it to load the keys to the NFC reader memory.

I am not sure, but probably you also need to have your key in the reader memory before trying to authenticate.

Hope it helps somehow