From 11dcc4787d1dd0c9f7dce64cce92503c791283a4 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sat, 21 Sep 2019 23:50:32 +0200 Subject: [PATCH] mfc magic: add some defines --- armsrc/mifarecmd.c | 16 +++++----------- client/mifare/mifarehost.c | 8 ++++---- include/protocols.h | 5 +++++ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index e07b59795..4a469e6e1 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -1977,11 +1977,6 @@ void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain) { } void MifareCIdent() { -#define GEN_1A 1 -#define GEN_1B 2 -#define GEN_2 4 -#define GEN_UNFUSED 5 - // variables uint8_t isGen = 0; uint8_t rec[1] = {0x00}; @@ -2000,10 +1995,10 @@ void MifareCIdent() { if (ReaderReceive(rec, recpar) && (rec[0] == 0x0a)) { ReaderTransmit(wupC2, sizeof(wupC2), NULL); if (!ReaderReceive(rec, recpar) || (rec[0] != 0x0a)) { - isGen = GEN_1B; + isGen = MAGIC_GEN_1B; goto OUT; }; - isGen = GEN_1A; + isGen = MAGIC_GEN_1A; goto OUT; } @@ -2014,20 +2009,19 @@ void MifareCIdent() { int res = iso14443a_select_card(uid, NULL, &cuid, true, 0, true); if (res == 2) { -// Dbprintf("cident AA55C396 == %08X", cuid); if (cuid == 0xAA55C396) { - isGen = GEN_UNFUSED; + isGen = MAGIC_GEN_UNFUSED; goto OUT; } ReaderTransmit(rats, sizeof(rats), NULL); res = ReaderReceive(buf, par); if (memcmp(buf, "\x09\x78\x00\x91\x02\xDA\xBC\x19\x10\xF0\x05", 11) == 0) { - isGen = GEN_2; + isGen = MAGIC_GEN_2; goto OUT; } if (memcmp(buf, "\x0D\x78\x00\x71\x02\x88\x49\xA1\x30\x20\x15\x06\x08\x56\x3D", 15) == 0) { - isGen = GEN_2; + isGen = MAGIC_GEN_2; } }; diff --git a/client/mifare/mifarehost.c b/client/mifare/mifarehost.c index 429605a4e..e4cec00c0 100644 --- a/client/mifare/mifarehost.c +++ b/client/mifare/mifarehost.c @@ -1033,16 +1033,16 @@ void detect_classic_magic(void) { } switch (isGeneration) { - case 1: + case MAGIC_GEN_1A: PrintAndLogEx(SUCCESS, "Answers to magic commands (GEN 1a): " _GREEN_("YES")); break; - case 2: + case MAGIC_GEN_1B: PrintAndLogEx(SUCCESS, "Answers to magic commands (GEN 1b): " _GREEN_("YES")); break; - case 4: + case MAGIC_GEN_2: PrintAndLogEx(SUCCESS, "Answers to magic commands (GEN 2 / CUID): " _GREEN_("YES")); break; - case 5: + case MAGIC_GEN_UNFUSED: PrintAndLogEx(SUCCESS, "Answers to magic commands (Write Once / FUID): " _GREEN_("YES")); break; default: diff --git a/include/protocols.h b/include/protocols.h index 9b47266c3..747e4e346 100644 --- a/include/protocols.h +++ b/include/protocols.h @@ -205,6 +205,11 @@ ISO 7816-4 Basic interindustry commands. For command APDU's. #define MAGIC_WIPE 0x40 #define MAGIC_SINGLE (MAGIC_WUPC | MAGIC_HALT | MAGIC_INIT | MAGIC_OFF) //0x1E +// by CMD_HF_MIFARE_CIDENT +#define MAGIC_GEN_1A 1 +#define MAGIC_GEN_1B 2 +#define MAGIC_GEN_2 4 +#define MAGIC_GEN_UNFUSED 5 /** 06 00 = INITIATE 0E xx = SELECT ID (xx = Chip-ID)