timmerk / libfreefare

Automatically exported from code.google.com/p/libfreefare
Other
0 stars 0 forks source link

Dual interface cards with MF Classic emulation authentication problem #19

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi, when I call mifare_classic_authenticate for Classic 1k (sak 0x88) 
everything is fine. But when I do same for Dual interface card i'm getting 
"-1" error code and error:

"error  libnfc.chip.pn53x   Buffer size is too short: 1 available(s), 2 needed"

What can be wrong?

I'm using libnfc 1.7.0 with ACR-122U-A9

Original issue reported on code.google.com by maximch...@gmail.com on 20 Dec 2013 at 11:38

GoogleCodeExporter commented 9 years ago
Please provide a trace of the execution with:
LIBNFC_LOG_LEVEL=3 mifare_classic_authenticate
I don't have such card so I cannot test myself.

Original comment by yob...@gmail.com on 20 Dec 2013 at 3:58

GoogleCodeExporter commented 9 years ago
debug   libnfc.chip.pn53x   InDataExchange
debug   libnfc.chip.pn53x   No timeout
debug   libnfc.driver.acr122_usb    TX: 6f 14 00 00 00 00 00 00 00 00 ff 00 00 00 0f 
d4 40 01 60 04 ff ff ff ff ff ff a0 d9 89 78 
debug   libnfc.driver.acr122_usb    RX: 80 07 00 00 00 00 00 00 81 00 d5 41 00 67 00 
90 00 
error   libnfc.chip.pn53x   Buffer size is too short: 1 available(s), 2 needed

Original comment by maximch...@gmail.com on 20 Dec 2013 at 5:11

GoogleCodeExporter commented 9 years ago
For regular Mifare Classic card it's a little bit different:

debug   libnfc.chip.pn53x   InDataExchange
debug   libnfc.chip.pn53x   No timeout
debug   libnfc.driver.acr122_usb    TX: 6f 14 00 00 00 00 00 00 00 00 ff 00 00 00 0f 
d4 40 01 60 04 ff ff ff ff ff ff e7 38 a1 4a 
debug   libnfc.driver.acr122_usb    RX: 80 05 00 00 00 00 00 00 81 00 d5 41 00 90 00

so I guess second byte of RX is a length of response that probably was 
hardcoded somewhere.

Original comment by maximch...@gmail.com on 20 Dec 2013 at 5:49

GoogleCodeExporter commented 9 years ago
Ok I figured out that this issue is a duplicate of 
https://code.google.com/p/libnfc/issues/detail?id=229

I added:

nfc_set_property_bool(pnd, NP_AUTO_ISO14443_4, false) 

before calling mifare_classic_connect

and it fixed my problem

Original comment by maximch...@gmail.com on 20 Dec 2013 at 8:26

GoogleCodeExporter commented 9 years ago
As mifare_classic_connect() implies connecting to MIFARE Classic, which is not 
a ISO14443-4 card, we maybe could disable NP_AUTO_ISO14443_4 feature in 
libfreefare ?

Note: we will need to re-enable it before connection to DESFire.

Original comment by romu...@libnfc.org on 20 Dec 2013 at 10:47

GoogleCodeExporter commented 9 years ago
This makes sense to me, yes.
Note that at the moment current examples mifare-classic-format etc are also 
buggy.

Original comment by yob...@gmail.com on 20 Dec 2013 at 11:31