\r
uint32_t uid; // serial number\r
uint32_t nt; // tag challenge\r
+uint32_t nt_par; \r
uint32_t nr_enc; // encrypted reader challenge\r
uint32_t ar_enc; // encrypted reader response\r
+uint32_t nr_ar_par; \r
uint32_t at_enc; // encrypted tag response\r
+uint32_t at_par; \r
\r
int isTraceCardEmpty(void) {\r
return ((traceCard[0] == 0) && (traceCard[1] == 0) && (traceCard[2] == 0) && (traceCard[3] == 0));\r
}\r
\r
\r
-int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {\r
+int mfTraceDecode(uint8_t *data_src, int len, uint32_t parity, bool wantSaveToEmlFile) {\r
uint8_t data[64];\r
\r
if (traceState == TRACE_ERROR) return 1;\r
\r
switch (traceState) {\r
case TRACE_IDLE: \r
- // TODO: check packet crc16!\r
+ // check packet crc16!\r
+ if ((len >= 4) && (!CheckCrc14443(CRC_14443_A, data, len))) {\r
+ PrintAndLog("dec> CRC ERROR!!!");\r
+ AddLogLine(logHexFileName, "dec> ", "CRC ERROR!!!"); \r
+ traceState = TRACE_ERROR; // do not decrypt the next commands\r
+ return 1;\r
+ }\r
\r
// AUTHENTICATION\r
if ((len ==4) && ((data[0] == 0x60) || (data[0] == 0x61))) {\r
traceState = TRACE_AUTH2;\r
\r
nt = bytes_to_num(data, 4);\r
+ nt_par = parity;\r
return 0;\r
} else {\r
traceState = TRACE_ERROR;\r
\r
nr_enc = bytes_to_num(data, 4);\r
ar_enc = bytes_to_num(data + 4, 4);\r
+ nr_ar_par = parity;\r
return 0;\r
} else {\r
traceState = TRACE_ERROR;\r
traceState = TRACE_IDLE;\r
\r
at_enc = bytes_to_num(data, 4);\r
+ at_par = parity;\r
\r
// decode key here)\r
if (!traceCrypto1) {\r