if(MillerDecoding((data[0] & 0xF0) >> 4)) {
LED_C_INV();
// check - if there is a short 7bit request from reader
- if (MfSniffLogic(receivedCmd, Uart.byteCnt, Uart.bitCnt, TRUE)) break;
+ if (MfSniffLogic(receivedCmd, Uart.byteCnt, Uart.parityBits, Uart.bitCnt, TRUE)) break;
/* And ready to receive another command. */
Uart.state = STATE_UNSYNCD;
if(ManchesterDecoding(data[0] & 0x0F)) {
LED_C_INV();
- if (MfSniffLogic(receivedResponse, Demod.len, Uart.bitCnt, FALSE)) break;
+ if (MfSniffLogic(receivedResponse, Demod.len, Demod.parityBits, Demod.bitCount, FALSE)) break;
// And ready to receive another response.
memset(&Demod, 0, sizeof(Demod));
return 0;\r
}\r
\r
-int RAMFUNC MfSniffLogic(const uint8_t * data, int len, int bitCnt, int reader) {\r
+int RAMFUNC MfSniffLogic(const uint8_t * data, int len, uint32_t parity, int bitCnt, int reader) {\r
\r
if ((len == 1) && (bitCnt = 9) && (data[0] > 0x0F)) { \r
sniffState = SNF_INIT;\r
sniffBuf[11] = sniffSAK;\r
sniffBuf[12] = 0xFF;\r
sniffBuf[13] = 0xFF;\r
- LogTrace(sniffBuf, 14, 0, 0, true);\r
+ LogTrace(sniffBuf, 14, 0, parity, true);\r
timerData = GetTickCount();\r
}\r
case SNF_CARD_CMD:{\r
- LogTrace(data, len, 0, 0, true);\r
+ LogTrace(data, len, 0, parity, true);\r
\r
sniffState = SNF_CARD_RESP;\r
timerData = GetTickCount();\r
break;\r
}\r
case SNF_CARD_RESP:{\r
- LogTrace(data, len, 0, 0, false);\r
+ LogTrace(data, len, 0, parity, false);\r
\r
sniffState = SNF_CARD_CMD;\r
timerData = GetTickCount();\r
#define SNF_UID_7 0\r
\r
int MfSniffInit(void);\r
-int RAMFUNC MfSniffLogic(const uint8_t * data, int len, int bitCnt, int reader);\r
+int RAMFUNC MfSniffLogic(const uint8_t * data, int len, uint32_t parity, int bitCnt, int reader);\r
int RAMFUNC MfSniffSend(int maxTimeoutMs);\r
int intMfSniffSend();\r
int MfSniffEnd(void);\r
uint8_t atqa[2];\r
uint8_t sak;\r
bool isTag;\r
+ uint32_t parity;\r
uint8_t buf[3000];\r
uint8_t * bufPtr = buf;\r
memset(buf, 0x00, 3000);\r
num = 0;\r
while (bufPtr - buf + 9 < blockLen) {\r
isTag = bufPtr[3] & 0x80 ? true:false;\r
- bufPtr += 8;\r
+ bufPtr += 4;\r
+ parity = *((uint32_t *)(bufPtr));\r
+ bufPtr += 4;\r
len = bufPtr[0];\r
bufPtr++;\r
if ((len == 14) && (bufPtr[0] = 0xff) && (bufPtr[1] = 0xff)) {\r
} else {\r
PrintAndLog("%s(%d):%s", isTag ? "TAG":"RDR", num, sprint_hex(bufPtr, len));\r
if (wantLogToFile) AddLogHex(logHexFileName, isTag ? "TAG: ":"RDR: ", bufPtr, len);\r
- if (wantDecrypt) mfTraceDecode(bufPtr, len, wantSaveToEmlFile);\r
+ if (wantDecrypt) mfTraceDecode(bufPtr, len, parity, wantSaveToEmlFile);\r
}\r
bufPtr += len;\r
num++;\r
\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
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
int mfCGetBlock(uint8_t blockNo, uint8_t *data, uint8_t params);\r
\r
int mfTraceInit(uint8_t *tuid, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile);\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
\r
int isTraceCardEmpty(void);\r
int isBlockEmpty(int blockN);\r