]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/mifarecmd.c
ADD: marshmellows new lf command and DetectClock. (works great!)
[proxmark3-svn] / armsrc / mifarecmd.c
index 519ea2b052e0b709889f3623edb5014033e7d5f5..1352215e2314df9488cfb8e64eecb1f62b7bbeaf 100644 (file)
@@ -20,7 +20,7 @@
 #include "../common/crc.h"\r
 \r
 //-----------------------------------------------------------------------------\r
-// Select, Authenticaate, Read an MIFARE tag. \r
+// Select, Authenticate, Read a MIFARE tag. \r
 // read block\r
 //-----------------------------------------------------------------------------\r
 void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)\r
@@ -267,25 +267,25 @@ void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
 \r
 void MifareUReadCard(uint8_t arg0, int arg1, uint8_t *datain)\r
 {\r
-  // params\r
-        uint8_t sectorNo = arg0;\r
-        int Pages=arg1;\r
+       // params\r
+       uint8_t sectorNo = arg0;\r
+       int Pages=arg1;\r
        int count_Pages=0;\r
-        // variables\r
-        byte_t isOK = 0;\r
-        byte_t dataoutbuf[44 * 4];\r
-        uint8_t uid[10];\r
-        uint32_t cuid;\r
+       // variables\r
+       byte_t isOK = 0;\r
+       byte_t dataoutbuf[176];\r
+       uint8_t uid[10];\r
+       uint32_t cuid;\r
 \r
-        // clear trace\r
-        iso14a_clear_trace();\r
+       // clear trace\r
+       iso14a_clear_trace();\r
 \r
-               iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);\r
+       iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);\r
 \r
-        LED_A_ON();\r
-        LED_B_OFF();\r
-        LED_C_OFF();\r
-        Dbprintf("Pages %d",Pages);\r
+       LED_A_ON();\r
+       LED_B_OFF();\r
+       LED_C_OFF();\r
+       Dbprintf("Pages %d",Pages);\r
         while (true) {\r
                 if(!iso14443a_select_card(uid, NULL, &cuid)) {\r
                 if (MF_DBGLEVEL >= 1)   Dbprintf("Can't select card");\r
@@ -307,8 +307,8 @@ void MifareUReadCard(uint8_t arg0, int arg1, uint8_t *datain)
                 isOK = 1;\r
                 break;\r
         }\r
-        Dbprintf("Pages read %d",count_Pages);\r
-        if (MF_DBGLEVEL >= 2) DbpString("READ CARD FINISHED");\r
+       Dbprintf("Pages read %d",count_Pages);\r
+       if (MF_DBGLEVEL >= 2) DbpString("READ CARD FINISHED");\r
 \r
         LED_B_ON();\r
        if (Pages==16) cmd_send(CMD_ACK,isOK,0,0,dataoutbuf,64);\r
@@ -316,9 +316,9 @@ void MifareUReadCard(uint8_t arg0, int arg1, uint8_t *datain)
        if (Pages==44 && count_Pages>16) cmd_send(CMD_ACK,isOK,0,0,dataoutbuf,176);\r
         LED_B_OFF();\r
 \r
-        // Thats it...\r
-        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
-        LEDsoff();\r
+       // Thats it...\r
+       FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+       LEDsoff();\r
 \r
 }\r
 \r
@@ -601,7 +601,7 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t calibrate, uint8_t *dat
                        nttmp = prng_successor(nt1, 100);                               //NXP Mifare is typical around 840,but for some unlicensed/compatible mifare card this can be 160\r
                        for (i = 141; i < 1200; i++) {\r
                                nttmp = prng_successor(nttmp, 1);\r
-                               if (nttmp == nt2) {break;}\r
+                               if (nttmp == nt2) break;\r
                        }\r
 \r
                        if (i != 1200) {\r
@@ -792,7 +792,6 @@ void MifareChkKeys(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
     cmd_send(CMD_ACK,isOK,0,0,datain + i * 6,6);\r
        LED_B_OFF();\r
 \r
-  // Thats it...\r
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
        LEDsoff();\r
 \r
@@ -946,8 +945,8 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
        uint8_t* receivedAnswer = get_bigbufptr_recvrespbuf();\r
        uint8_t *receivedAnswerPar = receivedAnswer + MAX_FRAME_SIZE;\r
        \r
+       // reset FPGA and LED\r
        if (workFlags & 0x08) {\r
-               // clear trace\r
                iso14a_clear_trace();\r
                iso14a_set_tracing(TRUE);\r
 \r
@@ -957,16 +956,18 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
                LED_B_OFF();\r
                LED_C_OFF();\r
        \r
-               SpinDelay(300);\r
-               FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
-               SpinDelay(100);\r
-               FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_READER_MOD);\r
+               //SpinDelay(300);\r
+               //FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+               //SpinDelay(100);\r
+               //FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_READER_MOD);\r
        }\r
 \r
        while (true) {\r
+\r
                // get UID from chip\r
                if (workFlags & 0x01) {\r
                        if(!iso14443a_select_card(uid, NULL, &cuid)) {\r
+                               Dbprintf("ICE");\r
                                if (MF_DBGLEVEL >= 1)   Dbprintf("Can't select card");\r
                                break;\r
                        };\r
@@ -1042,7 +1043,6 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
        LED_B_OFF();\r
 \r
        if ((workFlags & 0x10) || (!isOK)) {\r
-               // Thats it...\r
                FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
                LEDsoff();\r
        }\r
@@ -1083,10 +1083,10 @@ void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
                LED_B_OFF();\r
                LED_C_OFF();\r
        \r
-               SpinDelay(300);\r
-               FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
-               SpinDelay(100);\r
-               FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_READER_MOD);\r
+               // SpinDelay(300);\r
+               // FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+               // SpinDelay(100);\r
+               // FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_READER_MOD);\r
        }\r
 \r
        while (true) {\r
@@ -1127,7 +1127,6 @@ void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
        LED_B_OFF();\r
 \r
        if ((workFlags & 0x10) || (!isOK)) {\r
-               // Thats it...\r
                FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
                LEDsoff();\r
        }\r
Impressum, Datenschutz