From b819315caa7c9a1da1a4ad129ec457d70c4965b8 Mon Sep 17 00:00:00 2001 From: Pi3rrot Date: Tue, 22 Nov 2016 21:27:30 +0100 Subject: [PATCH 1/3] Add support for Mifare Mini 0.3k --- libfreefare/freefare.c | 4 ++++ libfreefare/freefare.h | 2 +- libfreefare/mifare_classic.c | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/libfreefare/freefare.c b/libfreefare/freefare.c index b7c2fb5..40fe1e5 100644 --- a/libfreefare/freefare.c +++ b/libfreefare/freefare.c @@ -38,6 +38,8 @@ freefare_tag_new (nfc_device *device, nfc_target target) if (felica_taste (device, target)) { tag = felica_tag_new (device, target); + } else if (mifare_mini_taste (device, target)) { + tag = mifare_mini_tag_new (device, target); } else if (mifare_classic1k_taste (device, target)) { tag = mifare_classic1k_tag_new (device, target); } else if (mifare_classic4k_taste (device, target)) { @@ -155,6 +157,8 @@ freefare_get_tag_friendly_name (FreefareTag tag) switch (tag->type) { case FELICA: return "FeliCA"; + case MIFARE_MINI: + return "Mifare Mini 0.3k"; case MIFARE_CLASSIC_1K: return "Mifare Classic 1k"; case MIFARE_CLASSIC_4K: diff --git a/libfreefare/freefare.h b/libfreefare/freefare.h index 8d02e41..d7b5c98 100644 --- a/libfreefare/freefare.h +++ b/libfreefare/freefare.h @@ -30,7 +30,7 @@ enum freefare_tag_type { FELICA, -// MIFARE_MINI, + MIFARE_MINI, MIFARE_CLASSIC_1K, MIFARE_CLASSIC_4K, MIFARE_DESFIRE, diff --git a/libfreefare/mifare_classic.c b/libfreefare/mifare_classic.c index 7789ff9..18014a5 100644 --- a/libfreefare/mifare_classic.c +++ b/libfreefare/mifare_classic.c @@ -193,6 +193,16 @@ int get_block_access_bits (FreefareTag tag, const MifareClassicBlockNumber blo * Memory management functions. */ +bool +mifare_mini_taste (nfc_device *device, nfc_target target) +{ + (void) device; + return target.nm.nmt == NMT_ISO14443A && + ( + target.nti.nai.btSak == 0x09 + ); +} + bool mifare_classic1k_taste (nfc_device *device, nfc_target target) { @@ -237,6 +247,13 @@ _mifare_classic_tag_new (nfc_device *device, nfc_target target, int tag_type) return tag; } + +FreefareTag +mifare_mini_tag_new (nfc_device *device, nfc_target target) +{ + return _mifare_classic_tag_new (device, target, MIFARE_MINI); +} + FreefareTag mifare_classic1k_tag_new (nfc_device *device, nfc_target target) { From df3165284d6bfb2e4dcbd27992078661a56ad847 Mon Sep 17 00:00:00 2001 From: Pi3rrot Date: Tue, 22 Nov 2016 21:28:44 +0100 Subject: [PATCH 2/3] Change README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d5e61eb..0d9b05d 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you are new to _libfreefare_ or the _nfc-tools_, you should collect useful in | MIFARE DESFire 4k | Supported | | MIFARE DESFire 8k | Supported | | MIFARE DESFire EV1 | Supported | -| MIFARE Mini | Not supported | +| MIFARE Mini | Supported | | MIFARE Plus S 2k | Not supported | | MIFARE Plus S 4k | Not supported | | MIFARE Plus X 2k | Not supported | From 644c9bd2143cc20572bb260328c8f704a0e12492 Mon Sep 17 00:00:00 2001 From: pierre Date: Tue, 22 Nov 2016 23:30:38 +0100 Subject: [PATCH 3/3] Add function declaration + man entry --- libfreefare/freefare.3 | 1 + libfreefare/freefare.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/libfreefare/freefare.3 b/libfreefare/freefare.3 index a504a81..7cc8385 100644 --- a/libfreefare/freefare.3 +++ b/libfreefare/freefare.3 @@ -51,6 +51,7 @@ Mifare card manipulation library (libfreefare, \-lfreefare) .Bd -literal enum freefare_tag_type { FELICA, + MIFARE_MINI MIFARE_CLASSIC_1K, MIFARE_CLASSIC_4K, MIFARE_DESFIRE, diff --git a/libfreefare/freefare.h b/libfreefare/freefare.h index d7b5c98..58acecf 100644 --- a/libfreefare/freefare.h +++ b/libfreefare/freefare.h @@ -104,8 +104,10 @@ bool is_mifare_ultralightc_on_reader (nfc_device *device, nfc_iso14443a_info n +bool mifare_mini_taste (nfc_device *device, nfc_target target); bool mifare_classic1k_taste (nfc_device *device, nfc_target target); bool mifare_classic4k_taste (nfc_device *device, nfc_target target); +FreefareTag mifare_mini_tag_new (nfc_device *device, nfc_target target); FreefareTag mifare_classic1k_tag_new (nfc_device *device, nfc_target target); FreefareTag mifare_classic4k_tag_new (nfc_device *device, nfc_target target); void mifare_classic_tag_free (FreefareTag tag);