Enforce target type identification with ATS comparison.

This commit is contained in:
Romain Tartiere 2010-08-04 16:11:09 +00:00
parent f0e03b99fb
commit 03da46df65
2 changed files with 12 additions and 7 deletions

View file

@ -18,17 +18,18 @@
*/
#include <stdlib.h>
#include <string.h>
#include <freefare.h>
#include "freefare_internal.h"
struct supported_tag supported_tags[] = {
{ 0x08, CLASSIC_1K, "Mifare Classic 1k" },
{ 0x18, CLASSIC_4K, "Mifare Classic 4k" },
{ 0x38, CLASSIC_4K, "Mifare Classic 4k (Emulated)" },
{ 0x20, DESFIRE, "Mifare DESFire 4k" },
{ 0x00, ULTRALIGHT, "Mifare UltraLight" },
{ 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 4k", 0x20, 5, { 0x75, 0x77, 0x81, 0x02, 0x80 }},
{ ULTRALIGHT, "Mifare UltraLight", 0x00, 0, { 0x00 } },
};
@ -79,7 +80,9 @@ freefare_get_tags (nfc_device_t *device)
struct supported_tag *tag_info;
for (size_t i = 0; i < sizeof (supported_tags) / sizeof (struct supported_tag); i++) {
if (target_info.nai.btSak == supported_tags[i].SAK) {
if ((target_info.nai.btSak == supported_tags[i].SAK) &&
(target_info.nai.szAtsLen == supported_tags[i].ATS_length) &&
(0 == memcmp (target_info.nai.abtAts, supported_tags[i].ATS, supported_tags[i].ATS_length))) {
tag_info = &(supported_tags[i]);
found = true;

View file

@ -99,9 +99,11 @@ void *assert_crypto_buffer_size (MifareTag tag, size_t nbytes);
#define MIFARE_ULTRALIGHT_PAGE_COUNT 16
struct supported_tag {
uint8_t SAK;
enum mifare_tag_type type;
const char *friendly_name;
uint8_t SAK;
uint8_t ATS_length;
uint8_t ATS[5];
};
/*