From 8b6a93df9152de16e16fd4158775954228245613 Mon Sep 17 00:00:00 2001 From: "Merlokbr@gmail.com" Date: Tue, 17 Jul 2012 11:41:56 +0000 Subject: [PATCH] `hf mf sniff` added CRC_14443_A check --- client/mifarehost.c | 8 +++++++- client/mifarehost.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/client/mifarehost.c b/client/mifarehost.c index fc29e10e..70d2413a 100644 --- a/client/mifarehost.c +++ b/client/mifarehost.c @@ -419,7 +419,13 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) { switch (traceState) { case TRACE_IDLE: - // TODO: check packet crc16! + // check packet crc16! + if ((len >= 4) && (!CheckCrc14443(CRC_14443_A, data, len))) { + PrintAndLog("dec> CRC ERROR!!!"); + AddLogLine(logHexFileName, "dec> ", "CRC ERROR!!!"); + traceState = TRACE_ERROR; // do not decrypt the next commands + return 1; + } // AUTHENTICATION if ((len ==4) && ((data[0] == 0x60) || (data[0] == 0x61))) { diff --git a/client/mifarehost.h b/client/mifarehost.h index 64fc9339..d74f3f0e 100644 --- a/client/mifarehost.h +++ b/client/mifarehost.h @@ -19,6 +19,7 @@ #include "util.h" #include "nonce2key/nonce2key.h" #include "nonce2key/crapto1.h" +#include "iso14443crc.h" #define MEM_CHUNK 1000000 #define NESTED_SECTOR_RETRY 10 -- 2.39.2