Don't check the ATQA to determine tags type, it should not be used.

This commit is contained in:
Romuald Conty
2010-08-13 13:53:43 +00:00
parent aa39875853
commit 3594e199d1
+24 -30
View File
@@ -47,7 +47,7 @@ static byte_t abtFelica[5] = { 0x00, 0xff, 0xff, 0x00, 0x00 };
#define MAX_ATS_LENGTH 32
struct iso14443a_tag {
uint8_t ATQA[2], SAK;
uint8_t SAK;
const char *name;
size_t ATS_length;
uint8_t ATS[MAX_ATS_LENGTH];
@@ -74,35 +74,31 @@ Innovision R&T Jewel 0C 00
*/
struct iso14443a_tag iso14443a_tags[] = {
{ { 0x00, 0x44 }, 0x00, "NXP MIFARE UltraLight", 0, { 0 } },
{ { 0x00, 0x44 }, 0x00, "NXP MIFARE UltraLight C", 0, { 0 } },
{ { 0x00, 0x04 }, 0x09, "NXP MIFARE Mini", 0, { 0 } },
{ { 0x00, 0x04 }, 0x08, "NXP MIFARE Classic 1k", 0, { 0 } },
{ { 0x00, 0x02 }, 0x18, "NXP MIFARE Classic 4k", 0, { 0 } },
{ 0x00, "NXP MIFARE UltraLight", 0, { 0 } },
{ 0x00, "NXP MIFARE UltraLight C", 0, { 0 } },
{ 0x09, "NXP MIFARE Mini", 0, { 0 } },
{ 0x08, "NXP MIFARE Classic 1k", 0, { 0 } },
{ 0x18, "NXP MIFARE Classic 4k", 0, { 0 } },
{ { 0x00, 0x04 }, 0x08, "NXP MIFARE Plus 1k", 0, { 0 } },
{ { 0x00, 0x04 }, 0x18, "NXP MIFARE Plus 4k", 0, { 0 } },
{ { 0x00, 0x02 }, 0x08, "NXP MIFARE Plus 1k", 0, { 0 } },
{ { 0x00, 0x02 }, 0x18, "NXP MIFARE Plus 4k", 0, { 0 } },
{ { 0x00, 0x04 }, 0x10, "NXP MIFARE Plus 1k", 0, { 0 } },
{ { 0x00, 0x04 }, 0x11, "NXP MIFARE Plus 4k", 0, { 0 } },
{ { 0x00, 0x02 }, 0x10, "NXP MIFARE Plus 1k", 0, { 0 } },
{ { 0x00, 0x02 }, 0x11, "NXP MIFARE Plus 4k", 0, { 0 } },
{ { 0x00, 0x04 }, 0x20, "NXP MIFARE Plus 1k", 0, { 0 } },
{ { 0x00, 0x04 }, 0x20, "NXP MIFARE Plus 4k", 0, { 0 } },
{ { 0x00, 0x02 }, 0x20, "NXP MIFARE Plus 1k/4k", 11, { 0x75, 0x77, 0x80, 0x02, 0xc1, 0x05, 0x2f, 0x2f, 0x01, 0xbc, 0xd6} },
{ { 0x00, 0x44 }, 0x20, "NXP MIFARE Plus 2k/4k", 11, { 0x75, 0x77, 0x80, 0x02, 0xc1, 0x05, 0x2f, 0x2f, 0x01, 0xbc, 0xd6 } },
{ 0x08, "NXP MIFARE Plus 1k", 0, { 0 } },
{ 0x18, "NXP MIFARE Plus 4k", 0, { 0 } },
{ 0x10, "NXP MIFARE Plus 1k", 0, { 0 } },
{ 0x11, "NXP MIFARE Plus 4k", 0, { 0 } },
{ 0x20, "NXP MIFARE Plus 1k", 0, { 0 } },
{ 0x20, "NXP MIFARE Plus 4k", 0, { 0 } },
{ 0x20, "NXP MIFARE Plus 1k/4k", 11, { 0x75, 0x77, 0x80, 0x02, 0xc1, 0x05, 0x2f, 0x2f, 0x01, 0xbc, 0xd6} },
{ 0x20, "NXP MIFARE Plus 2k/4k", 11, { 0x75, 0x77, 0x80, 0x02, 0xc1, 0x05, 0x2f, 0x2f, 0x01, 0xbc, 0xd6 } },
{ { 0x00, 0x04 }, 0x88, "Infineon MIFARE Classic 1k", 0, { 0 } },
{ { 0x00, 0x02 }, 0x38, "Nokia MIFARE Classic 4k (Emulated)", 0, { 0 } },
{ { 0x03, 0x44 }, 0x20, "NXP MIFARE DESFire", 5, { 0x75, 0x77, 0x81, 0x02, 0x80 } },
{ { 0x03, 0x04 }, 0x28, "NXP JCOP31", 0, { 0 } },
{ 0x88, "Infineon MIFARE Classic 1k", 0, { 0 } },
{ 0x38, "Nokia MIFARE Classic 4k (Emulated)", 0, { 0 } },
{ 0x20, "NXP MIFARE DESFire", 5, { 0x75, 0x77, 0x81, 0x02, 0x80 } },
{ 0x28, "NXP JCOP31", 0, { 0 } },
/* @todo handle ATS to be able to know which one is it. */
{ { 0x00, 0x48 }, 0x20, "NXP JCOP31 or JCOP41", 0, { 0 } },
{ { 0x00, 0x04 }, 0x28, "NXP JCOP41", 0, { 0 } },
{ { 0x00, 0x02 }, 0x98, "Gemplus MPCOS", 0, { 0 } },
{ 0x20, "NXP JCOP31 or JCOP41", 0, { 0 } },
{ 0x28, "NXP JCOP41", 0, { 0 } },
{ 0x98, "Gemplus MPCOS", 0, { 0 } },
/* @note I'm not sure that Jewel can be detected using this modulation but I haven't Jewel tags to test. */
{ { 0x00, 0x02 }, 0x98, "Innovision R&T Jewel", 0, { 0 } },
{ 0x98, "Innovision R&T Jewel", 0, { 0 } },
};
void
@@ -128,7 +124,7 @@ main (int argc, const char *argv[])
// Try to open the NFC device
if (!(pnddDevices = malloc (MAX_DEVICE_COUNT * sizeof (*pnddDevices)))) {
fprintf (stderr, "malloc() failed\n");
ERR ("%s", "malloc() failed\n");
return EXIT_FAILURE;
}
@@ -171,9 +167,7 @@ main (int argc, const char *argv[])
const char *tag_name = NULL;
for (size_t i = 0; i < sizeof (iso14443a_tags) / sizeof (struct iso14443a_tag); i++) {
if ((nti.nai.abtAtqa[0] == iso14443a_tags[i].ATQA[0]) &&
(nti.nai.abtAtqa[1] == iso14443a_tags[i].ATQA[1]) &&
(nti.nai.btSak == iso14443a_tags[i].SAK)) {
if ( (nti.nai.btSak == iso14443a_tags[i].SAK) ) {
// printf("DBG: iso14443a_tags[i].ATS_length = %d , nti.nai.szAtsLen = %d", iso14443a_tags[i].ATS_length, nti.nai.szAtsLen);
if( iso14443a_tags[i].ATS_length == 0 ) {
tag_name = (iso14443a_tags[i].name);