Search code examples
androidauthenticationnfcrfidmifare

How to properly start a connection with a Mifare Ultralight C?


I have tried to start the 3DES protocol on a Mifare Ultralight C. In the product datasheet they specify that you have to start by sending the command 1A (and I found this post that everyone who asks is redirected to: Android: Authenticating with NXP MiFare Ultralight C).

So I tried to do something similar in the code below:

nfca.connect();
byte[] authData = new byte[] { 0x1A, 0x00};
encRndB = nfca.transceive(authData);

But I always get the following error at the transceive operation:

W/System.err: android.nfc.TagLostException: Tag was lost.

Am I doing something wrong or I should do it in some other way?


Solution

  • Getting a TagLostException in response to a command can mean two things:

    1. Communication with the tag was actually interrupted (by tearing the tag) or due to bad coupling between the reader and the tag.
    2. The tag does not support the command and "responded" with a passive NACK (i.e. it did not respond to generate a timeout). Type 2 tags may to this if they receive commands that they do not support.

    Consequently, the second case is a clear indication that the tag did not support the MIFARE Ultralight C authentication command. This means that the tag probably is no MIFARE Ultralight C tag. You may check Distinguish different types of MIFARE Ultralight for a starting point on fingerprinting the actual tag type.