#include <stdint.h>\r
\r
#include "proxmark3.h"\r
-#include "cmd.h"\r
+#include "usb_cdc.h"\r
#include "crapto1/crapto1.h"\r
#include "iso14443a.h"\r
#include "BigBuf.h"\r
\r
if (MF_DBGLEVEL >= 2) DbpString("READ BLOCK FINISHED");\r
\r
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+\r
LED_B_ON();\r
cmd_send(CMD_ACK,isOK,0,0,dataoutbuf,16);\r
LED_B_OFF();\r
\r
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
LEDsoff();\r
}\r
\r
return;\r
}\r
\r
- cmd_send(CMD_ACK,1,0,0,dataout,16);\r
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
LED_D_OFF();\r
+\r
+ cmd_send(CMD_ACK,1,0,0,dataout,16);\r
LED_A_OFF();\r
}\r
\r
\r
if (MF_DBGLEVEL >= 2) DbpString("READ SECTOR FINISHED");\r
\r
+ // Thats it...\r
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+\r
LED_B_ON();\r
cmd_send(CMD_ACK,isOK,0,0,dataoutbuf,16*NumBlocksPerSector(sectorNo));\r
LED_B_OFF();\r
\r
- // Thats it...\r
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
LEDsoff();\r
}\r
\r
\r
if (MF_DBGLEVEL >= MF_DBG_DEBUG) Dbprintf("Blocks read %d", countblocks);\r
\r
- cmd_send(CMD_ACK, 1, countblocks*4, BigBuf_max_traceLen(), 0, 0);\r
-\r
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
LED_D_OFF();\r
+\r
+ cmd_send(CMD_ACK, 1, countblocks*4, BigBuf_max_traceLen(), 0, 0);\r
+\r
BigBuf_free();\r
LED_A_OFF();\r
}\r
\r
if (MF_DBGLEVEL >= 2) DbpString("WRITE BLOCK FINISHED");\r
\r
+ // Thats it...\r
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+\r
LED_B_ON();\r
cmd_send(CMD_ACK,isOK,0,0,0,0);\r
LED_B_OFF();\r
\r
\r
- // Thats it...\r
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
LEDsoff();\r
}\r
\r
\r
if (MF_DBGLEVEL >= 2) DbpString("WRITE BLOCK FINISHED");\r
\r
- cmd_send(CMD_ACK,1,0,0,0,0);\r
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+\r
+ cmd_send(CMD_ACK,1,0,0,0,0);\r
LEDsoff();\r
}\r
*/\r
\r
if (MF_DBGLEVEL >= 2) DbpString("WRITE BLOCK FINISHED");\r
\r
- cmd_send(CMD_ACK,1,0,0,0,0);\r
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+\r
+ cmd_send(CMD_ACK,1,0,0,0,0);\r
LEDsoff();\r
}\r
\r
return;\r
};\r
\r
- cmd_send(CMD_ACK,1,0,0,0,0);\r
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+\r
+ cmd_send(CMD_ACK,1,0,0,0,0);\r
LEDsoff();\r
}\r
\r
\r
crypto1_destroy(pcs);\r
\r
+ if (field_off) {\r
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+ LEDsoff();\r
+ }\r
+\r
LED_B_ON();\r
cmd_send(CMD_ACK, isOK, cuid, num_nonces, buf, sizeof(buf));\r
LED_B_OFF();\r
\r
if (MF_DBGLEVEL >= 3) DbpString("AcquireEncryptedNonces finished");\r
\r
- if (field_off) {\r
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
- LEDsoff();\r
- }\r
}\r
\r
\r
memcpy(buf+16, &target_ks[1], 4);\r
memcpy(buf+20, &authentication_timeout, 4);\r
\r
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+\r
+ if (MF_DBGLEVEL >= 3) DbpString("NESTED FINISHED");\r
+\r
LED_B_ON();\r
cmd_send(CMD_ACK, isOK, 0, targetBlockNo + (targetKeyType * 0x100), buf, sizeof(buf));\r
LED_B_OFF();\r
\r
- if (MF_DBGLEVEL >= 3) DbpString("NESTED FINISHED");\r
-\r
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
LEDsoff();\r
}\r
\r
break;\r
}\r
\r
+ // reset fpga\r
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+\r
// send USB response\r
LED_B_ON();\r
cmd_send(CMD_ACK,isOK,0,0,NULL,0);\r
LED_B_OFF();\r
\r
- // reset fpga\r
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
LEDsoff();\r
\r
return;\r
break;\r
}\r
\r
+ if ((workFlags & 0x10) || (!isOK)) {\r
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+ }\r
+\r
LED_B_ON();\r
cmd_send(CMD_ACK,isOK,0,0,uid,4);\r
LED_B_OFF();\r
\r
- if ((workFlags & 0x10) || (!isOK)) {\r
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
- LEDsoff();\r
- }\r
+ LEDsoff();\r
}\r
\r
\r
break;\r
}\r
\r
+ if ((workFlags & 0x10) || (!isOK)) {\r
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+ }\r
+\r
LED_B_ON();\r
if (workFlags & 0x20) {\r
if (isOK)\r
cmd_send(CMD_ACK,isOK,0,0,data,18);\r
LED_B_OFF();\r
\r
- if ((workFlags & 0x10) || (!isOK)) {\r
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
- LEDsoff();\r
- }\r
+ LEDsoff();\r
}\r
\r
void MifareCIdent(){\r
// From iceman1001: removed the if, since some magic tags misbehavies and send an answer to it.\r
mifare_classic_halt(NULL, 0);\r
\r
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+\r
LED_B_ON();\r
cmd_send(CMD_ACK,isOK,0,0,0,0);\r
LED_B_OFF();\r
\r
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
LEDsoff();\r
}\r
\r
}\r
\r
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) DbpString("AUTH 1 FINISHED");\r
- cmd_send(CMD_ACK,1,cuid,0,dataout, sizeof(dataout));\r
+\r
+ cmd_send(CMD_ACK, 1, cuid, 0, dataout, sizeof(dataout));\r
}\r
\r
void Mifare_DES_Auth2(uint32_t arg0, uint8_t *datain){\r
\r
isOK = mifare_desfire_des_auth2(cuid, key, dataout);\r
\r
- if( isOK) {\r
+ if (isOK) {\r
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("Authentication part2: Failed");\r
OnError(4);\r
return;\r
}\r
\r
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+\r
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) DbpString("AUTH 2 FINISHED");\r
\r
cmd_send(CMD_ACK, isOK, 0, 0, dataout, sizeof(dataout));\r
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
LEDsoff();\r
}\r
\r