From 24dc2eff406fec24068f1b067125234880845cc9 Mon Sep 17 00:00:00 2001 From: Alexandre Fenyo Date: Wed, 19 May 2021 20:08:37 +0200 Subject: [PATCH] support of a new ATS for DESFire EV1 on JCOP3 Adding support of a new ATS sent by a DESFire EV1 applet found on a JCOP3 P60 chip. I've split the check of the ATS length into two checks. --- libfreefare/mifare_desfire.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libfreefare/mifare_desfire.c b/libfreefare/mifare_desfire.c index efa05052..86fd63de 100644 --- a/libfreefare/mifare_desfire.c +++ b/libfreefare/mifare_desfire.c @@ -271,19 +271,21 @@ le24toh(uint8_t data[3]) bool mifare_desfire_taste(nfc_device *device, nfc_target target) { - // We have two different ATS prefixes to - // check for, standalone and JCOP. - static const char STANDALONE_DESFIRE[] = { 0x75, 0x77, 0x81, 0x02}; + // We have three different ATS prefixes to + // check for, standalone, JCOP and JCOP3. + static const char STANDALONE_DESFIRE[] = { 0x75, 0x77, 0x81, 0x02 }; static const char JCOP_DESFIRE[] = { 0x75, 0xf7, 0xb1, 0x02 }; + static const char JCOP3_DESFIRE[] = { 0x78, 0x77, 0x71, 0x02 }; (void) device; return target.nm.nmt == NMT_ISO14443A && - target.nti.nai.btSak == 0x20 && + target.nti.nai.btSak == 0x20 && (( target.nti.nai.szAtsLen >= 5 && ( memcmp(target.nti.nai.abtAts, STANDALONE_DESFIRE, sizeof(STANDALONE_DESFIRE)) == 0 || - memcmp(target.nti.nai.abtAts, JCOP_DESFIRE, sizeof(JCOP_DESFIRE)) == 0 - ); + memcmp(target.nti.nai.abtAts, JCOP_DESFIRE, sizeof(JCOP_DESFIRE)) == 0)) + || (target.nti.nai.szAtsLen == 4 && + memcmp(target.nti.nai.abtAts, JCOP3_DESFIRE, sizeof(JCOP3_DESFIRE)) == 0)); } /*