There are different smart cards supporting ISO 14443-4. For example, Mifare Plus with its native command set. Or other cards with different command sets (i.e. 7816-4 APDUs).
I develop some software for a card reader and I need to identify which commands the card supports (for example, if it supports commands in ISO 7816-4 structure or not).
What is the recommended way to distinguish between them? Should I just try some commands from Mifare Plus command set and check if I get correct replies? Or is there any smarter way to do it?
There are two types under ISO/IEC 14443 standard, that Type A and Type B, both of which communicate via radio at 13.56 MHz (RFID HIGH FREQUENCY). The main differences between these two kinds concern modulation methods, coding schemes (Part 2) and protocol initialization procedures (Part 3).
The MIFARE Ultralight EV1, MIFARE Plus EV1, MIFARE Plus EV2, MIFARE DESFire EV2, MIFARE DESFire EV3 and MIFARE DESFire Light support the command “GetVersion” to exactly identify the IC. It is recommended to use only the GetVersion command to identify which IC Type currently is present on a reader.
ISO 14443 is a standard designed for proximity or contactless smart card communication. It typically uses a 13.56MHz radio frequency that only transmits digital data within a short range - about 4 centimeters or less - beyond, the signal is too weak. It can never exceed 10 centimeters.
The MIFARE Plus product family adds security to Smart City services by enabling a seamless migration of contactless infrastructures to higher security, and its backward compatibility allows for a cost-efficient way to upgrade the security level of in-place smart card applications.
During the connection protocol some parameters are exchanged that you can use to determine the card's capabilities. For example, the SAK byte will inform the reader whether the card is ISO 14443-4, and even if it is MIFARE Plus (there is an NXP document explaining which bits you have to read). Then you have ATS (Answer To Select), which contains a lot of useful information about the card. Have a look at ISO 14443-4 and at ISO 7816-4.
Never use ATQ! Use SAK only for non 14443-4 cards(e.g. Mifare Classic)! ATS is also bad practice as different card vendor can set it differently.
Now how to do it:
Only way how to think about card and don't get crazy is imagine it like it is full communication stack(see OSI model).
Keep in mind that your goal is to connect two applications, one in the card and one in your computer. 14443-4 provides mechanism for sending messages and don't care about its content.
On top of it there are implemented interfaces of different cards and if both sides: card - carddriver are compatible they will communicate. If not, there will be errors on that level. So you know you will need to use different card driver.
Complete communication stack will look like this:
Your Application
| CardProtocol/7816-4
| | 14443-4
| | | 14443
| | | | radio waves
| | | 14443 (in card)
| | 14443-4 (in card)
| CardProtocol/7816-4 (in card)
Application/Appdata (in card)
Of course between every layer has to be some interface.
If you have two applications which wants to communicate try one and then try second.
error on application level => there is no compatible application on card
error on CardProtocol level => there is not compatible card
Point is your communication has to succed on all levels so don't worry to try to communicate with card by not compatible protocol - if you (by some miracle) will not get error on CardProtocol level you will definitely get one on your application level and result will be same. Good Luck!
P.S. There are some more complex situations like "one app over two protocols/types of cards" but they can be handled easily too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With