From 667ba72dbdd8b58c90e8780bc4b444a8d19a9859 Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Tue, 30 Mar 2010 16:05:01 +0000 Subject: [PATCH] Strip CT (Cascade Tag) from UIDs in nfc_initiator_select_tag(). --- src/lib/nfc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lib/nfc.c b/src/lib/nfc.c index 415fe37..d09fe4d 100644 --- a/src/lib/nfc.c +++ b/src/lib/nfc.c @@ -488,6 +488,17 @@ bool nfc_initiator_select_tag(const nfc_device_t* pnd, const nfc_modulation_t nm } else { pnti->nai.szAtsLen = 0; } + + // Strip CT (Cascade Tag) to retrieve and store the _real_ UID + // (e.g. 0x8801020304050607 is in fact 0x01020304050607) + if ((pnti->nai.szUidLen == 8) && (pnti->nai.abtUid[0] == 0x88)) { + pnti->nai.szUidLen = 7; + memmove (pnti->nai.abtUid, pnti->nai.abtUid + 1, 7) + } else if ((pnti->nai.szUidLen == 12) && (pnti->nai.abtUid[0] == 0x88) && (pnti->nai.abtUid[4] == 0x88)) { + pnti->nai.szUidLen = 10; + memmove (pnti->nai.abtUid, pnti->nai.abtUid + 1, 3); + memmove (pnti->nai.abtUid + 3, pnti->nai.abtUid + 5, 7); + } break; case NM_FELICA_212: