Compare only the 4 first bytes of ATS.

The 5th byte of Mifare DESFire being a "historical character" and being
user-tweakable for Mifare DESFire EV1, we should not use it when comparing the
ATS with our Mifare DESFire reference ATS to determine if a given tag is a
Mifare DESFire or not.
This commit is contained in:
Romain Tartiere 2010-09-29 19:46:55 +00:00
parent 9a2a07ea53
commit ba56826969

View file

@ -28,11 +28,14 @@
#define NXP_MANUFACTURER_CODE 0x04
/* Number of bytes of ATS to compare */
#define ATS_LENGTH 4
struct supported_tag supported_tags[] = {
{ CLASSIC_1K, "Mifare Classic 1k", 0x08, 0, { 0x00 } },
{ CLASSIC_4K, "Mifare Classic 4k", 0x18, 0, { 0x00 } },
{ CLASSIC_4K, "Mifare Classic 4k (Emulated)", 0x38, 0, { 0x00 } },
{ DESFIRE, "Mifare DESFire", 0x20, 5, { 0x75, 0x77, 0x81, 0x02, 0x80 }},
{ DESFIRE, "Mifare DESFire", 0x20, 5, { 0x75, 0x77, 0x81, 0x02 /*, 0xXX */ }},
{ ULTRALIGHT, "Mifare UltraLight", 0x00, 0, { 0x00 } },
};
@ -51,7 +54,7 @@ freefare_tag_new (nfc_device_t *device, nfc_iso14443a_info_t nai)
if (((nai.szUidLen == 4) || (nai.abtUid[0] == NXP_MANUFACTURER_CODE)) &&
(nai.btSak == supported_tags[i].SAK) &&
(nai.szAtsLen == supported_tags[i].ATS_length) &&
(0 == memcmp (nai.abtAts, supported_tags[i].ATS, supported_tags[i].ATS_length))) {
(0 == memcmp (nai.abtAts, supported_tags[i].ATS, ATS_LENGTH))) {
tag_info = &(supported_tags[i]);
found = true;