\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
 
 #include "util.h"\r
 #include "nonce2key/nonce2key.h"\r
 #include "nonce2key/crapto1.h"\r
+#include "iso14443crc.h"\r
 \r
 #define MEM_CHUNK               1000000\r
 #define NESTED_SECTOR_RETRY     10\r