nfcsmartcardapdusmartcard-reader

Relation between APDU and higher level NFC protocols (such as ISO 14443-3A)?


I started reading into the topic of NFC/Smartcard-Communication and I found many different standards and commands depending on the Tag type (for example see here)

I also came across the APDU-commands which seem universal to the communication of nfc/smartcards?

Does this mean, that these higher level protocols are all based on apdu and can be translated?

As an example, I found NFC 14443-A commands implemented with the android.nfc.tech.NfcA library, such as:

Action Byte
Read 0x30
Write 0xA2

And APDU commands like these:

Action CLA INS P1 P2 LC
READ BINARY 0xFF 0xB0 ... ... ...
UPDATE BINARY 0xFF 0xD6 ... ... ...
GET DATA 0xFF 0xCA ... ... ...
MIFARE CLASSIC READ 0xFF 0xF3 ... ... ...
MIFARE CLASSIC WRITE 0xFF 0xF4 ... ... ...

The commands seem to be completely different.

It would also help alot, if someone could point to good documentation on the topic


Documentation I have found so far:

The Android documentation on nfca (Link)

APDU description on wikipedia Link (The german version contains some return codes)

APDU commands (by a card-reader manufacturer) Link


Solution

  • You have it a bit wrong, 14443-3A is lower level that APDU's which come from the higher level ISO 7816 protocol.

    But the Byte's ( 0x30 and 0xA2) you reference as NFC 14443-A are not from NFC 14443-A but look like vendor specific Mifare Ultralight protocol commands which are again above NFC 14443-A

    There is also a complication and probably the reason you are confused with APDU's you listed according to the ISO 7816 spec, all the APDU's you specified have a CLA of 0xFF are "invalid".

    The reason for this is that a USB readers also use ISO 7816 for the host CPU to talk the NFC chip to work mainly with NFC Type 4 Tags, because 0xFF are invalid for ISO 7816 the reader uses them for other non ISO 7816 things the NFC chip can do, e.g. communicate to non standard Mifare classic commands, turn on/off the LED's on the USB reader, etc

    So really CLA's of 0xFF are just a way to wrap other commands.

    Or in a rough pictorial form

    enter image description here

    I would read as much of the Standard specification documents shown in the Stackoverflow you linked to and I wrote. There are a lot of specifications used/part used

    I know that they are really pay for items but they are out there on the Internet.

    e.g.

    http://www.emutag.com/iso/14443-3.pdf

    http://www.emutag.com/iso/14443-4.pdf

    For the higher level NDEF stuff https://github.com/haldean/ndef/tree/master/docs

    For the Various NFC Forum Standards

    Google Index of the 4 Types