1
votes

I'm currently making a project where I want to use my Windows 10 phone featuring NFC to read the UID/serial number of a smart card to find the ID of a person. The card I'm trying to get the UID/serial number from is an NXP MIFARE DESFire EV1. The ID I'm looking for is printed on the card and I managed to access it using my friend's phone with an Android app which means that the number is accessible although I don't know how.

I'm able to send APDU commands to the card but I don't know which one to use to get the UID/serial number I'm looking for.

What APDU commands do I need to send to the card to obtain the ID? The ID I'm looking for is 7 bytes long.

1
Sorry, reading of non-smart cards is strongly dependent on the translation services of reader and you did not mention one. You may find a starting point in this question.guidot

1 Answers

5
votes

In general retrieving parameters such as the anti-collision identifier (UID) of contactless cards depends very much on the reader and the abstraction layers between the reader and your application. For instance, on Android there is a simple method getId() to get the anti-collision identifier of an NFC tag/contactless smartcard.

However, for MIFARE DESFire there is also a way to obtain that parameter by means of APDUs. You can simply send a GET VERSION command to query version information (and also the card UID):

C-APDU: 90 60 0000 00
R-APDU: 04 01 YY 01 00 ZZ 05 91AF

C-APDU: 90 AF 0000 00
R-APDU: 04 01 01 01 04 ZZ 05 91AF

C-APDU: 90 AF 0000 00
R-APDU: XXXXXXXXXXXXXX UUUUUUUUUU VV WW 9100

The value XXXXXXXXXXXXXX is the UID of the card (or all zeros if the card is in random anti-collision identifier mode).

Note that there even exists a parser for the MIFARE DESFire version information here (as ThomasRS pointed out in a comment).