From ba56826969e31e7ef166c8fb47716bdcfd6f2255 Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Wed, 29 Sep 2010 19:46:55 +0000 Subject: [PATCH] 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. --- libfreefare/freefare.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libfreefare/freefare.c b/libfreefare/freefare.c index bd1b380..2e17db8 100644 --- a/libfreefare/freefare.c +++ b/libfreefare/freefare.c @@ -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;