如何检测机器人从NFC标签UID是否是随机的?机器人、标签、NFC、UID

2023-09-05 01:13:41 作者:余生去浪

我的工作依赖于已发现的NFC标签来处理标签的唯一的UID的Andr​​oid项目。我用下面的code提取这个UID:

I am working on an Android project which relies on the unique UID of a discovered NFC tag to process the tag. I extract this UID using the following code:

byte[] extraID = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);

然而,对于某些技术将此UID是随机出于安全的目的产生的。没有任何人有一个想法如何,我可以发现,这是一个随机生成的UID?是否有某种标志,它被设置?

However, for some technologies this UID is randomly generated for security purposes. Does anybody have an idea how I could detect that this is a randomly generated UID? Is there some kind of flag that is set?

请注意:一个简单的解决办法是将读取标​​签两次,比较的UID。不过,我想避免这种情况。

note: a simple solution would be to read the tag twice and compare the UIDs. However, I would like to avoid this.

推荐答案

有关NFCA(和IsoDep和/或MifareClassic结合NFCA),该ID是随机的,如果它正好是4个字节长,并开始与0x08的。有一些卡(MIFARE DESFire非),可以用随机的ID是4字节长,并开始与0x80的配置。

For NfcA (and IsoDep and/or MifareClassic combined with NfcA), the ID is random if it exactly 4 bytes long and starts with 0x08. There are some cards (MIFARE DESFire) that can be configured with a random ID that is 4 bytes long and starts with 0x80.

有关NfcB(和IsoDep结合NfcB),有保留用于随机ID的无predetermined ID范围。事实上,任何NfcB ID可以是随机的。该NfcB ID实际上是所谓的PUPI,它的全称是伪唯一PICC标识符。所以,这个名字已经表明,唯一性无法得到保证。

For NfcB (and IsoDep combined with NfcB), there is no predetermined ID range that is reserved for random IDs. In fact, any NfcB ID can be a random one. The NfcB ID is actually called PUPI, which stands for "Pseudo Unique PICC Identifier". So the name already indicates that uniqueness is not guaranteed.

有关NfcF和NfcV,该ID一般不会是随机的。

For NfcF and NfcV, the ID will generally not be random.

读取标签两次检测随机ID只有从射频场中删除标记的工作。一个标记通常会保持相同的随机ID,只要它保持供电的RF场。

Reading the tag twice to detect a random ID only works if you remove the tag from the RF field. A tag will usually keep the same random ID as long as it stays powered by the Rf field.