]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - client/mifarehost.c
fixed cmd malloc strlen()+1 bug
[proxmark3-svn] / client / mifarehost.c
index fc29e10e9f1e3d3f5db3e0886a83187070190354..f34759df80b6343cd1be1de0cf7dc111a20cdcd4 100644 (file)
@@ -295,9 +295,12 @@ uint32_t ks3;
 \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
@@ -401,7 +404,7 @@ void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *data, int len, bool i
 }\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
@@ -419,7 +422,13 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
        \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
@@ -498,6 +507,7 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
                        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
@@ -511,6 +521,7 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
 \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
@@ -523,6 +534,7 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
                        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
Impressum, Datenschutz