astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60

This commit is contained in:
Philippe Teuwen 2012-05-29 15:52:51 +00:00
parent 26569c2202
commit a2cd236441
45 changed files with 1096 additions and 1082 deletions

View file

@ -62,34 +62,34 @@ nfc_initiator_mifare_cmd (nfc_device *pnd, const mifare_cmd mc, const uint8_t ui
abtCmd[1] = ui8Block; // The block address (1K=0x00..0x39, 4K=0x00..0xff)
switch (mc) {
// Read and store command have no parameter
case MC_READ:
case MC_STORE:
szParamLen = 0;
break;
// Read and store command have no parameter
case MC_READ:
case MC_STORE:
szParamLen = 0;
break;
// Authenticate command
case MC_AUTH_A:
case MC_AUTH_B:
szParamLen = sizeof (struct mifare_param_auth);
break;
// Authenticate command
case MC_AUTH_A:
case MC_AUTH_B:
szParamLen = sizeof (struct mifare_param_auth);
break;
// Data command
case MC_WRITE:
szParamLen = sizeof (struct mifare_param_data);
break;
// Data command
case MC_WRITE:
szParamLen = sizeof (struct mifare_param_data);
break;
// Value command
case MC_DECREMENT:
case MC_INCREMENT:
case MC_TRANSFER:
szParamLen = sizeof (struct mifare_param_value);
break;
// Value command
case MC_DECREMENT:
case MC_INCREMENT:
case MC_TRANSFER:
szParamLen = sizeof (struct mifare_param_value);
break;
// Please fix your code, you never should reach this statement
default:
return false;
break;
// Please fix your code, you never should reach this statement
default:
return false;
break;
}
// When available, copy the parameter bytes

View file

@ -98,7 +98,7 @@ uint8_t nfcforum_capability_container[] = {
0x00, 0xFF, /* MLc Maximum C-ADPU data size */
0x04, /* T field of the NDEF File-Control TLV */
0x06, /* L field of the NDEF File-Control TLV */
/* V field of the NDEF File-Control TLV */
/* V field of the NDEF File-Control TLV */
0xE1, 0x04, /* File identifier */
0xFF, 0xFE, /* Maximum NDEF Size */
0x00, /* NDEF file read access condition */
@ -143,79 +143,79 @@ nfcforum_tag4_io (struct nfc_emulator *emulator, const uint8_t *data_in, const s
#define ISO7816_UPDATE_BINARY 0xD6
switch(data_in[INS]) {
case ISO7816_SELECT:
case ISO7816_SELECT:
switch (data_in[P1]) {
case 0x00: /* Select by ID */
if ((data_in[P2] | 0x0C) != 0x0C)
return -ENOTSUP;
switch (data_in[P1]) {
case 0x00: /* Select by ID */
if ((data_in[P2] | 0x0C) != 0x0C)
return -ENOTSUP;
const uint8_t ndef_capability_container[] = { 0xE1, 0x03 };
const uint8_t ndef_file[] = { 0xE1, 0x04 };
if ((data_in[LC] == sizeof (ndef_capability_container)) && (0 == memcmp (ndef_capability_container, data_in + DATA, data_in[LC]))) {
memcpy (data_out, "\x90\x00", res = 2);
state_machine_data->current_file = CC_FILE;
} else if ((data_in[LC] == sizeof (ndef_file)) && (0 == memcmp (ndef_file, data_in + DATA, data_in[LC]))) {
memcpy (data_out, "\x90\x00", res = 2);
state_machine_data->current_file = NDEF_FILE;
} else {
memcpy (data_out, "\x6a\x00", res = 2);
state_machine_data->current_file = NONE;
const uint8_t ndef_capability_container[] = { 0xE1, 0x03 };
const uint8_t ndef_file[] = { 0xE1, 0x04 };
if ((data_in[LC] == sizeof (ndef_capability_container)) && (0 == memcmp (ndef_capability_container, data_in + DATA, data_in[LC]))) {
memcpy (data_out, "\x90\x00", res = 2);
state_machine_data->current_file = CC_FILE;
} else if ((data_in[LC] == sizeof (ndef_file)) && (0 == memcmp (ndef_file, data_in + DATA, data_in[LC]))) {
memcpy (data_out, "\x90\x00", res = 2);
state_machine_data->current_file = NDEF_FILE;
} else {
memcpy (data_out, "\x6a\x00", res = 2);
state_machine_data->current_file = NONE;
}
break;
case 0x04: /* Select by name */
if (data_in[P2] != 0x00)
return -ENOTSUP;
const uint8_t ndef_tag_application_name_v1[] = { 0xD2, 0x76, 0x00, 0x00, 0x85, 0x01, 0x00 };
const uint8_t ndef_tag_application_name_v2[] = { 0xD2, 0x76, 0x00, 0x00, 0x85, 0x01, 0x01 };
if ((type4v == 1) && (data_in[LC] == sizeof (ndef_tag_application_name_v1)) && (0 == memcmp (ndef_tag_application_name_v1, data_in + DATA, data_in[LC])))
memcpy (data_out, "\x90\x00", res = 2);
else if ((type4v == 2) && (data_in[LC] == sizeof (ndef_tag_application_name_v2)) && (0 == memcmp (ndef_tag_application_name_v2, data_in + DATA, data_in[LC])))
memcpy (data_out, "\x90\x00", res = 2);
else
memcpy (data_out, "\x6a\x82", res = 2);
break;
default:
return -ENOTSUP;
}
break;
case 0x04: /* Select by name */
if (data_in[P2] != 0x00)
return -ENOTSUP;
const uint8_t ndef_tag_application_name_v1[] = { 0xD2, 0x76, 0x00, 0x00, 0x85, 0x01, 0x00 };
const uint8_t ndef_tag_application_name_v2[] = { 0xD2, 0x76, 0x00, 0x00, 0x85, 0x01, 0x01 };
if ((type4v == 1) && (data_in[LC] == sizeof (ndef_tag_application_name_v1)) && (0 == memcmp (ndef_tag_application_name_v1, data_in + DATA, data_in[LC])))
memcpy (data_out, "\x90\x00", res = 2);
else if ((type4v == 2) && (data_in[LC] == sizeof (ndef_tag_application_name_v2)) && (0 == memcmp (ndef_tag_application_name_v2, data_in + DATA, data_in[LC])))
memcpy (data_out, "\x90\x00", res = 2);
else
memcpy (data_out, "\x6a\x82", res = 2);
case ISO7816_READ_BINARY:
if ((size_t)(data_in[LC] + 2) > data_out_len) {
return -ENOSPC;
}
switch (state_machine_data->current_file) {
case NONE:
memcpy (data_out, "\x6a\x82", res = 2);
break;
case CC_FILE:
memcpy (data_out, nfcforum_capability_container + (data_in[P1] << 8) + data_in[P2], data_in[LC]);
memcpy (data_out + data_in[LC], "\x90\x00", 2);
res = data_in[LC] + 2;
break;
case NDEF_FILE:
memcpy (data_out, ndef_data->ndef_file + (data_in[P1] << 8) + data_in[P2], data_in[LC]);
memcpy (data_out + data_in[LC], "\x90\x00", 2);
res = data_in[LC] + 2;
break;
}
break;
default:
return -ENOTSUP;
}
break;
case ISO7816_READ_BINARY:
if ((size_t)(data_in[LC] + 2) > data_out_len) {
return -ENOSPC;
}
switch (state_machine_data->current_file) {
case NONE:
memcpy (data_out, "\x6a\x82", res = 2);
case ISO7816_UPDATE_BINARY:
memcpy (ndef_data->ndef_file + (data_in[P1] << 8) + data_in[P2], data_in + DATA, data_in[LC]);
if ((data_in[P1] << 8) + data_in[P2] == 0) {
ndef_data->ndef_file_len = (ndef_data->ndef_file[0] << 8) + ndef_data->ndef_file[1] + 2;
}
memcpy (data_out, "\x90\x00", res = 2);
break;
case CC_FILE:
memcpy (data_out, nfcforum_capability_container + (data_in[P1] << 8) + data_in[P2], data_in[LC]);
memcpy (data_out + data_in[LC], "\x90\x00", 2);
res = data_in[LC] + 2;
break;
case NDEF_FILE:
memcpy (data_out, ndef_data->ndef_file + (data_in[P1] << 8) + data_in[P2], data_in[LC]);
memcpy (data_out + data_in[LC], "\x90\x00", 2);
res = data_in[LC] + 2;
break;
}
break;
case ISO7816_UPDATE_BINARY:
memcpy (ndef_data->ndef_file + (data_in[P1] << 8) + data_in[P2], data_in + DATA, data_in[LC]);
if ((data_in[P1] << 8) + data_in[P2] == 0) {
ndef_data->ndef_file_len = (ndef_data->ndef_file[0] << 8) + ndef_data->ndef_file[1] + 2;
}
memcpy (data_out, "\x90\x00", res = 2);
break;
default: // Unknown
if (!quiet_output) {
printf("Unknown frame, emulated target abort.\n");
}
res = -ENOTSUP;
default: // Unknown
if (!quiet_output) {
printf("Unknown frame, emulated target abort.\n");
}
res = -ENOTSUP;
}
} else {
res = -ENOTSUP;

View file

@ -130,10 +130,10 @@ main (int argc, const char *argv[])
ERR ("Unable to open NFC device: %s", connstrings[i]);
continue;
}
if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE);
}
if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE);
}
printf ("NFC device: %s opened\n", nfc_device_get_name (pnd));

View file

@ -468,131 +468,131 @@ main (int argc, const char *argv[])
}
switch (atAction) {
case ACTION_USAGE:
print_usage (argv[0]);
exit (EXIT_FAILURE);
break;
case ACTION_READ:
case ACTION_WRITE:
if (bUseKeyFile) {
pfKeys = fopen (argv[4], "rb");
if (pfKeys == NULL) {
printf ("Could not open keys file: %s\n", argv[4]);
exit (EXIT_FAILURE);
}
if (fread (&mtKeys, 1, sizeof (mtKeys), pfKeys) != sizeof (mtKeys)) {
printf ("Could not read keys file: %s\n", argv[4]);
fclose (pfKeys);
exit (EXIT_FAILURE);
}
fclose (pfKeys);
}
if (atAction == ACTION_READ) {
memset (&mtDump, 0x00, sizeof (mtDump));
} else {
pfDump = fopen (argv[3], "rb");
if (pfDump == NULL) {
printf ("Could not open dump file: %s\n", argv[3]);
exit (EXIT_FAILURE);
}
if (fread (&mtDump, 1, sizeof (mtDump), pfDump) != sizeof (mtDump)) {
printf ("Could not read dump file: %s\n", argv[3]);
fclose (pfDump);
exit (EXIT_FAILURE);
}
fclose (pfDump);
}
// printf("Successfully opened required files\n");
nfc_init (NULL);
// Try to open the NFC reader
pnd = nfc_open (NULL, NULL);
if (pnd == NULL) {
printf ("Error opening NFC reader\n");
case ACTION_USAGE:
print_usage (argv[0]);
exit (EXIT_FAILURE);
}
if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE);
};
// Let the reader only try once to find a tag
if (nfc_device_set_property_bool (pnd, NP_INFINITE_SELECT, false) < 0) {
nfc_perror (pnd, "nfc_device_set_property_bool");
exit (EXIT_FAILURE);
}
// Disable ISO14443-4 switching in order to read devices that emulate Mifare Classic with ISO14443-4 compliance.
nfc_device_set_property_bool (pnd, NP_AUTO_ISO14443_4, false);
printf ("NFC reader: %s opened\n", nfc_device_get_name (pnd));
// Try to find a MIFARE Classic tag
if (nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nt) < 0) {
printf ("Error: no tag was found\n");
nfc_close (pnd);
nfc_exit (NULL);
exit (EXIT_FAILURE);
}
// Test if we are dealing with a MIFARE compatible tag
if ((nt.nti.nai.btSak & 0x08) == 0) {
printf ("Warning: tag is probably not a MFC!\n");
}
// Get the info from the current tag
pbtUID = nt.nti.nai.abtUid;
if (bUseKeyFile) {
uint8_t fileUid[4];
memcpy (fileUid, mtKeys.amb[0].mbm.abtUID, 4);
// Compare if key dump UID is the same as the current tag UID, at least for the first 4 bytes
if (memcmp (pbtUID, fileUid, 4) != 0) {
printf ("Expected MIFARE Classic card with UID starting as: %02x%02x%02x%02x\n",
fileUid[0], fileUid[1], fileUid[2], fileUid[3]);
}
}
printf ("Found MIFARE Classic card:\n");
print_nfc_iso14443a_info (nt.nti.nai, false);
// Guessing size
if ((nt.nti.nai.abtAtqa[1] & 0x02) == 0x02)
// 4K
uiBlocks = 0xff;
else if ((nt.nti.nai.btSak & 0x01) == 0x01)
// 320b
uiBlocks = 0x13;
else
// 1K
// TODO: for MFP it is 0x7f (2K) but how to be sure it's a MFP? Try to get RATS?
uiBlocks = 0x3f;
printf ("Guessing size: seems to be a %i-byte card\n", (uiBlocks + 1) * 16);
if (atAction == ACTION_READ) {
if (read_card (unlock)) {
printf ("Writing data to file: %s ...", argv[3]);
fflush (stdout);
pfDump = fopen (argv[3], "wb");
if (pfDump == NULL) {
printf ("Could not open dump file: %s\n", argv[3]);
exit (EXIT_FAILURE);
}
if (fwrite (&mtDump, 1, sizeof (mtDump), pfDump) != sizeof (mtDump)) {
printf ("\nCould not write to file: %s\n", argv[3]);
break;
case ACTION_READ:
case ACTION_WRITE:
if (bUseKeyFile) {
pfKeys = fopen (argv[4], "rb");
if (pfKeys == NULL) {
printf ("Could not open keys file: %s\n", argv[4]);
exit (EXIT_FAILURE);
}
if (fread (&mtKeys, 1, sizeof (mtKeys), pfKeys) != sizeof (mtKeys)) {
printf ("Could not read keys file: %s\n", argv[4]);
fclose (pfKeys);
exit (EXIT_FAILURE);
}
fclose (pfKeys);
}
if (atAction == ACTION_READ) {
memset (&mtDump, 0x00, sizeof (mtDump));
} else {
pfDump = fopen (argv[3], "rb");
if (pfDump == NULL) {
printf ("Could not open dump file: %s\n", argv[3]);
exit (EXIT_FAILURE);
}
if (fread (&mtDump, 1, sizeof (mtDump), pfDump) != sizeof (mtDump)) {
printf ("Could not read dump file: %s\n", argv[3]);
fclose (pfDump);
exit (EXIT_FAILURE);
}
printf ("Done.\n");
fclose (pfDump);
}
} else if (atAction == ACTION_WRITE) {
write_card (unlock);
}
// printf("Successfully opened required files\n");
nfc_close (pnd);
break;
nfc_init (NULL);
// Try to open the NFC reader
pnd = nfc_open (NULL, NULL);
if (pnd == NULL) {
printf ("Error opening NFC reader\n");
exit (EXIT_FAILURE);
}
if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE);
};
// Let the reader only try once to find a tag
if (nfc_device_set_property_bool (pnd, NP_INFINITE_SELECT, false) < 0) {
nfc_perror (pnd, "nfc_device_set_property_bool");
exit (EXIT_FAILURE);
}
// Disable ISO14443-4 switching in order to read devices that emulate Mifare Classic with ISO14443-4 compliance.
nfc_device_set_property_bool (pnd, NP_AUTO_ISO14443_4, false);
printf ("NFC reader: %s opened\n", nfc_device_get_name (pnd));
// Try to find a MIFARE Classic tag
if (nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nt) < 0) {
printf ("Error: no tag was found\n");
nfc_close (pnd);
nfc_exit (NULL);
exit (EXIT_FAILURE);
}
// Test if we are dealing with a MIFARE compatible tag
if ((nt.nti.nai.btSak & 0x08) == 0) {
printf ("Warning: tag is probably not a MFC!\n");
}
// Get the info from the current tag
pbtUID = nt.nti.nai.abtUid;
if (bUseKeyFile) {
uint8_t fileUid[4];
memcpy (fileUid, mtKeys.amb[0].mbm.abtUID, 4);
// Compare if key dump UID is the same as the current tag UID, at least for the first 4 bytes
if (memcmp (pbtUID, fileUid, 4) != 0) {
printf ("Expected MIFARE Classic card with UID starting as: %02x%02x%02x%02x\n",
fileUid[0], fileUid[1], fileUid[2], fileUid[3]);
}
}
printf ("Found MIFARE Classic card:\n");
print_nfc_iso14443a_info (nt.nti.nai, false);
// Guessing size
if ((nt.nti.nai.abtAtqa[1] & 0x02) == 0x02)
// 4K
uiBlocks = 0xff;
else if ((nt.nti.nai.btSak & 0x01) == 0x01)
// 320b
uiBlocks = 0x13;
else
// 1K
// TODO: for MFP it is 0x7f (2K) but how to be sure it's a MFP? Try to get RATS?
uiBlocks = 0x3f;
printf ("Guessing size: seems to be a %i-byte card\n", (uiBlocks + 1) * 16);
if (atAction == ACTION_READ) {
if (read_card (unlock)) {
printf ("Writing data to file: %s ...", argv[3]);
fflush (stdout);
pfDump = fopen (argv[3], "wb");
if (pfDump == NULL) {
printf ("Could not open dump file: %s\n", argv[3]);
exit (EXIT_FAILURE);
}
if (fwrite (&mtDump, 1, sizeof (mtDump), pfDump) != sizeof (mtDump)) {
printf ("\nCould not write to file: %s\n", argv[3]);
exit (EXIT_FAILURE);
}
printf ("Done.\n");
fclose (pfDump);
}
} else if (atAction == ACTION_WRITE) {
write_card (unlock);
}
nfc_close (pnd);
break;
};
nfc_exit (NULL);

View file

@ -116,8 +116,8 @@ main (int argc, const char *argv[])
}
nfc_close (pnd);
} else {
printf("nfc_open failed for %s\n", connstrings[i]);
}
printf("nfc_open failed for %s\n", connstrings[i]);
}
}
res = EXIT_SUCCESS;

View file

@ -60,9 +60,9 @@ static nfc_device *pnd;
static void
print_usage(char *progname)
{
fprintf (stderr, "usage: %s -o FILE\n", progname);
fprintf (stderr, "\nOptions:\n");
fprintf (stderr, " -o Extract NDEF message if available in FILE\n");
fprintf (stderr, "usage: %s -o FILE\n", progname);
fprintf (stderr, "\nOptions:\n");
fprintf (stderr, " -o Extract NDEF message if available in FILE\n");
}
static void stop_select (int sig)
@ -89,11 +89,11 @@ static int
nfc_forum_tag_type3_check (nfc_device *dev, const nfc_target nt, const uint16_t block, const uint8_t block_count, uint8_t *data, size_t *data_len)
{
uint8_t payload[1024] = {
1, // Services
0x0B, 0x00, // NFC Forum Tag Type 3's Service code
block_count,
0x80, block, // block 0
};
1, // Services
0x0B, 0x00, // NFC Forum Tag Type 3's Service code
block_count,
0x80, block, // block 0
};
size_t payload_len = 1 + 2 + 1;
for (uint8_t b = 0; b < block_count; b++) {
@ -157,19 +157,19 @@ main(int argc, char *argv[])
char *ndef_output = NULL;
while ((ch = getopt (argc, argv, "ho:")) != -1) {
switch (ch) {
case 'h':
print_usage(argv[0]);
exit (EXIT_SUCCESS);
break;
case 'o':
ndef_output = optarg;
break;
case '?':
if (optopt == 'o')
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
default:
print_usage (argv[0]);
exit (EXIT_FAILURE);
case 'h':
print_usage(argv[0]);
exit (EXIT_SUCCESS);
break;
case 'o':
ndef_output = optarg;
break;
case '?':
if (optopt == 'o')
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
default:
print_usage (argv[0]);
exit (EXIT_FAILURE);
}
}

View file

@ -395,7 +395,7 @@ main (int argc, char *argv[])
szCapduLen = (size_t) res;
if (target_only_mode) {
if (print_hex_fd4(abtCapdu, szCapduLen, "C-APDU") != EXIT_SUCCESS) {
fprintf (stderr, "Error while printing C-APDU to FD4\n");
fprintf (stderr, "Error while printing C-APDU to FD4\n");
nfc_close (pndTarget);
nfc_exit (NULL);
exit(EXIT_FAILURE);
@ -461,7 +461,7 @@ main (int argc, char *argv[])
}
} else {
if (print_hex_fd4(abtRapdu, szRapduLen, "R-APDU") != EXIT_SUCCESS) {
fprintf (stderr, "Error while printing R-APDU to FD4\n");
fprintf (stderr, "Error while printing R-APDU to FD4\n");
nfc_close (pndInitiator);
nfc_exit (NULL);
exit(EXIT_FAILURE);

View file

@ -38,65 +38,79 @@
struct card_atqa
{
uint16_t atqa;
uint16_t mask;
char type[128];
// list of up to 8 SAK values compatible with this ATQA
int saklist[8];
uint16_t atqa;
uint16_t mask;
char type[128];
// list of up to 8 SAK values compatible with this ATQA
int saklist[8];
};
struct card_sak
{
uint8_t sak;
uint8_t mask;
char type[128];
uint8_t sak;
uint8_t mask;
char type[128];
};
struct card_atqa const_ca[] = {
{0x0044, 0xffff, "MIFARE Ultralight",
{0, -1} },
{0x0044, 0xffff, "MIFARE Ultralight C",
{0, -1} },
{0x0004, 0xff0f, "MIFARE Mini 0.3K",
{1, -1} },
{0x0004, 0xff0f, "MIFARE Classic 1K",
{2, -1} },
{0x0002, 0xff0f, "MIFARE Classic 4K",
{3, -1} },
{0x0004, 0xffff, "MIFARE Plus (4 Byte UID or 4 Byte RID)",
{4, 5, 6, 7, 8, 9, -1} },
{0x0002, 0xffff, "MIFARE Plus (4 Byte UID or 4 Byte RID)",
{4, 5, 6, 7, 8, 9, -1} },
{0x0044, 0xffff, "MIFARE Plus (7 Byte UID)",
{4, 5, 6, 7, 8, 9, -1} },
{0x0042, 0xffff, "MIFARE Plus (7 Byte UID)",
{4, 5, 6, 7, 8, 9, -1} },
{0x0344, 0xffff, "MIFARE DESFire",
{10, 11, -1} },
{0x0044, 0xffff, "P3SR008",
{-1} }, // TODO we need SAK info
{0x0004, 0xf0ff, "SmartMX with MIFARE 1K emulation",
{12, -1} },
{0x0002, 0xf0ff, "SmartMX with MIFARE 4K emulation",
{12, -1} },
{0x0048, 0xf0ff, "SmartMX with 7 Byte UID",
{12, -1} }
{ 0x0044, 0xffff, "MIFARE Ultralight",
{0, -1}
},
{ 0x0044, 0xffff, "MIFARE Ultralight C",
{0, -1}
},
{ 0x0004, 0xff0f, "MIFARE Mini 0.3K",
{1, -1}
},
{ 0x0004, 0xff0f, "MIFARE Classic 1K",
{2, -1}
},
{ 0x0002, 0xff0f, "MIFARE Classic 4K",
{3, -1}
},
{ 0x0004, 0xffff, "MIFARE Plus (4 Byte UID or 4 Byte RID)",
{4, 5, 6, 7, 8, 9, -1}
},
{ 0x0002, 0xffff, "MIFARE Plus (4 Byte UID or 4 Byte RID)",
{4, 5, 6, 7, 8, 9, -1}
},
{ 0x0044, 0xffff, "MIFARE Plus (7 Byte UID)",
{4, 5, 6, 7, 8, 9, -1}
},
{ 0x0042, 0xffff, "MIFARE Plus (7 Byte UID)",
{4, 5, 6, 7, 8, 9, -1}
},
{ 0x0344, 0xffff, "MIFARE DESFire",
{10, 11, -1}
},
{ 0x0044, 0xffff, "P3SR008",
{-1}
}, // TODO we need SAK info
{ 0x0004, 0xf0ff, "SmartMX with MIFARE 1K emulation",
{12, -1}
},
{ 0x0002, 0xf0ff, "SmartMX with MIFARE 4K emulation",
{12, -1}
},
{ 0x0048, 0xf0ff, "SmartMX with 7 Byte UID",
{12, -1}
}
};
struct card_sak const_cs[] = {
{0x00, 0xff, "" }, // 00 MIFARE Ultralight / Ultralight C
{0x09, 0xff, "" }, // 01 MIFARE Mini 0.3K
{0x08, 0xff, "" }, // 02 MIFARE Classic 1K
{0x18, 0xff, "" }, // 03 MIFARE Classik 4K
{0x08, 0xff, " 2K, Security level 1" }, // 04 MIFARE Plus
{0x18, 0xff, " 4K, Security level 1" }, // 05 MIFARE Plus
{0x10, 0xff, " 2K, Security level 2" }, // 06 MIFARE Plus
{0x11, 0xff, " 4K, Security level 2" }, // 07 MIFARE Plus
{0x20, 0xff, " 2K, Security level 3" }, // 08 MIFARE Plus
{0x20, 0xff, " 4K, Security level 3" }, // 09 MIFARE Plus
{0x20, 0xff, " 4K" }, // 10 MIFARE DESFire
{0x20, 0xff, " EV1 2K/4K/8K" }, // 11 MIFARE DESFire
{0x00, 0x00, "" }, // 12 SmartMX
{0x00, 0xff, "" }, // 00 MIFARE Ultralight / Ultralight C
{0x09, 0xff, "" }, // 01 MIFARE Mini 0.3K
{0x08, 0xff, "" }, // 02 MIFARE Classic 1K
{0x18, 0xff, "" }, // 03 MIFARE Classik 4K
{0x08, 0xff, " 2K, Security level 1" }, // 04 MIFARE Plus
{0x18, 0xff, " 4K, Security level 1" }, // 05 MIFARE Plus
{0x10, 0xff, " 2K, Security level 2" }, // 06 MIFARE Plus
{0x11, 0xff, " 4K, Security level 2" }, // 07 MIFARE Plus
{0x20, 0xff, " 2K, Security level 3" }, // 08 MIFARE Plus
{0x20, 0xff, " 4K, Security level 3" }, // 09 MIFARE Plus
{0x20, 0xff, " 4K" }, // 10 MIFARE DESFire
{0x20, 0xff, " EV1 2K/4K/8K" }, // 11 MIFARE DESFire
{0x00, 0x00, "" }, // 12 SmartMX
};
uint8_t
@ -190,16 +204,16 @@ print_nfc_iso14443a_info (const nfc_iso14443a_info nai, bool verbose)
switch ((nai.abtAtqa[1] & 0xc0)>>6) {
case 0:
printf("single\n");
break;
break;
case 1:
printf("double\n");
break;
break;
case 2:
printf("triple\n");
break;
break;
case 3:
printf("RFU\n");
break;
break;
}
printf("* bit frame anticollision ");
switch (nai.abtAtqa[1] & 0x1f) {
@ -209,10 +223,10 @@ print_nfc_iso14443a_info (const nfc_iso14443a_info nai, bool verbose)
case 0x08:
case 0x10:
printf("supported\n");
break;
break;
default:
printf("not supported\n");
break;
break;
}
}
printf (" UID (NFCID%c): ", (nai.abtUid[0] == 0x08 ? '3' : '1'));
@ -327,40 +341,40 @@ print_nfc_iso14443a_info (const nfc_iso14443a_info nai, bool verbose)
switch (CTC & 0xf0) {
case 0x00:
printf("(Multiple) Virtual Cards\n");
break;
break;
case 0x10:
printf("Mifare DESFire\n");
break;
break;
case 0x20:
printf("Mifare Plus\n");
break;
break;
default:
printf("RFU\n");
break;
break;
}
printf(" * Memory size: ");
switch (CTC & 0x0f) {
case 0x00:
printf("<1 kbyte\n");
break;
break;
case 0x01:
printf("1 kbyte\n");
break;
break;
case 0x02:
printf("2 kbyte\n");
break;
break;
case 0x03:
printf("4 kbyte\n");
break;
break;
case 0x04:
printf("8 kbyte\n");
break;
break;
case 0x0f:
printf("Unspecified\n");
break;
break;
default:
printf("RFU\n");
break;
break;
}
}
if ((nai.szAtsLen - offset) > 0) { // Omit 2 CRC bytes
@ -370,31 +384,31 @@ print_nfc_iso14443a_info (const nfc_iso14443a_info nai, bool verbose)
switch (CVC & 0xf0) {
case 0x00:
printf("Engineering sample\n");
break;
break;
case 0x20:
printf("Released\n");
break;
break;
default:
printf("RFU\n");
break;
break;
}
printf(" * Chip Generation: ");
switch (CVC & 0x0f) {
case 0x00:
printf("Generation 1\n");
break;
break;
case 0x01:
printf("Generation 2\n");
break;
break;
case 0x02:
printf("Generation 3\n");
break;
break;
case 0x0f:
printf("Unspecified\n");
break;
break;
default:
printf("RFU\n");
break;
break;
}
}
if ((nai.szAtsLen - offset) > 0) { // Omit 2 CRC bytes
@ -474,40 +488,40 @@ print_nfc_iso14443a_info (const nfc_iso14443a_info nai, bool verbose)
case 0x000488:
printf("* Mifare Classic 1K Infineon\n");
found_possible_match = true;
break;
break;
case 0x000298:
printf("* Gemplus MPCOS\n");
found_possible_match = true;
break;
break;
case 0x030428:
printf("* JCOP31\n");
found_possible_match = true;
break;
break;
case 0x004820:
printf("* JCOP31 v2.4.1\n");
printf("* JCOP31 v2.2\n");
found_possible_match = true;
break;
break;
case 0x000428:
printf("* JCOP31 v2.3.1\n");
found_possible_match = true;
break;
break;
case 0x000453:
printf("* Fudan FM1208SH01\n");
found_possible_match = true;
break;
break;
case 0x000820:
printf("* Fudan FM1208\n");
found_possible_match = true;
break;
break;
case 0x000238:
printf("* MFC 4K emulated by Nokia 6212 Classic\n");
found_possible_match = true;
break;
break;
case 0x000838:
printf("* MFC 4K emulated by Nokia 6131 NFC\n");
found_possible_match = true;
break;
break;
}
if (! found_possible_match) {
printf("* Unknown card, sorry\n");
@ -609,7 +623,7 @@ print_nfc_iso14443bi_info (const nfc_iso14443bi_info nii, bool verbose)
printf ("%i\n", version);
}
if ((nii.btVerLog & 0x80) && (nii.btConfig & 0x80)){
if ((nii.btVerLog & 0x80) && (nii.btConfig & 0x80)) {
printf (" Wait Enable: yes");
}
}
@ -663,28 +677,28 @@ print_nfc_target (const nfc_target nt, bool verbose)
switch(nt.nm.nmt) {
case NMT_ISO14443A:
print_nfc_iso14443a_info (nt.nti.nai, verbose);
break;
break;
case NMT_JEWEL:
print_nfc_jewel_info (nt.nti.nji, verbose);
break;
break;
case NMT_FELICA:
print_nfc_felica_info (nt.nti.nfi, verbose);
break;
break;
case NMT_ISO14443B:
print_nfc_iso14443b_info (nt.nti.nbi, verbose);
break;
break;
case NMT_ISO14443BI:
print_nfc_iso14443bi_info (nt.nti.nii, verbose);
break;
break;
case NMT_ISO14443B2SR:
print_nfc_iso14443b2sr_info (nt.nti.nsi, verbose);
break;
break;
case NMT_ISO14443B2CT:
print_nfc_iso14443b2ct_info (nt.nti.nci, verbose);
break;
break;
case NMT_DEP:
print_nfc_dep_info (nt.nti.ndi, verbose);
break;
break;
}
}