Get Static NFC Tag Id with HCE mode
Asked Answered
P

1

6

I'm new in NFC thing, so I tested several phones with calling getTagId() method in HCE mode, and this is the result:

device       | UID
LG G2        | random
LG G3        | static
S4           | random
HTC One Mini | static
Xiaomi mi3   | static

My questions:

  1. Why do some phones have static UID and some do not? Is this chipset related?
  2. Is it possible to get a fixed UID? I need it to authenticate the device.
  3. On other side, I'm using Kitkat CyanogenMod 11 on Xperia M, but I did not manage to use it for HCE, why?

Any documents that can explain/support the answer?

Publicness answered 1/12, 2014 at 23:46 Comment(2)
What getTagId() method are you using? Could you describe your test setup?Perfecto
Hi Roland, i was using getTagId in onTagDiscovered(Tag tag) on reader sidePublicness
P
7

Why do some phones have static UID and some do not? Is this chipset related?

That depends on the chipset and the implementation of the NFC stack. As far as I'm aware of, there are three different scenarios used by various Android NFC devices:

  • The device has a secure element and uses the static UID of that secure element.
  • The device generates a new random UID whenever it is turned on.
  • The device generates a new random UID on every activation by an external reader device. I.e. whenever an external HF field is applied to the NFC antenna of the Android device.
  • The device has no secure element but still uses a static UID (typically not unique), e.g. 0x01020304. [Thanks to ErikM for pointing this out.]

Is it possible to get a fixed UID?

Typically, you can't influence this. Specifically without modifying the Android device firmware (changes to the NFC stack) it's definitely not possible. See this answer for a method to set the UID value on Broadcom chipsets through modifying the libnfc-nci library.

I need it to authenticate the device.

Don't do this! See this answer for more information on that.

Perfecto answered 17/1, 2015 at 9:45 Comment(2)
Adding one more scenario here: The device has no secure element and uses a static UID, namely 01020304. Mainly used by Sony.Repp
Well, it's not in my hand what design the given entity (office, college, etc.) uses for authentication. If they're using a system solely based on UID, all answers saying "don't do this" aren't helpful at all. I just want to know how to emulate, not how to design an authentication system.Veradi

© 2022 - 2024 — McMap. All rights reserved.