1

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.

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
ZakFS
  • 63
  • 1
  • 7
  • 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](http://stackoverflow.com/q/12174000/1435475). – guidot Jan 31 '17 at 08:10

1 Answers1

5

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).

Community
  • 1
  • 1
Michael Roland
  • 39,663
  • 10
  • 99
  • 206
  • 1
    Works perfectly. Thank you so much for your precious time. You have no idea how helpful for me amd for others this is going to be. I'll never forget you – ZakFS Feb 01 '17 at 03:17
  • 2
    Parser at https://github.com/skjolber/external-nfc-api/blob/master/externalNFCClient/src/main/java/com/skjolberg/nfc/desfire/VersionInfo.java – ThomasRS Feb 13 '17 at 13:24