-
-}
-
-void MifareUWriteBlock(uint8_t arg0, uint8_t *datain)
-{
- // params
- uint8_t blockNo = arg0;
- byte_t blockdata[16];
-
- memset(blockdata,'\0',16);
- memcpy(blockdata, datain,16);
-
- // variables
- byte_t isOK = 0;
- uint8_t uid[10];
- uint32_t cuid;
-
- // clear trace
- iso14a_clear_trace();
- // iso14a_set_tracing(false);
-
- iso14443a_setup();
-
- LED_A_ON();
- LED_B_OFF();
- LED_C_OFF();
-
- while (true) {
- if(!iso14443a_select_card(uid, NULL, &cuid)) {
- if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");
- break;
- };
-
- if(mifare_ultra_writeblock(cuid, blockNo, blockdata)) {
- if (MF_DBGLEVEL >= 1) Dbprintf("Write block error");
- break;
- };
-
- if(mifare_ultra_halt(cuid)) {
- if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
- break;
- };
-
- isOK = 1;
- break;
- }
-
- if (MF_DBGLEVEL >= 2) DbpString("WRITE BLOCK FINISHED");
-
- // add trace trailer
- memset(uid, 0x44, 4);
- LogTrace(uid, 4, 0, 0, TRUE);
-
- LED_B_ON();
- cmd_send(CMD_ACK,isOK,0,0,0,0);
-// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
- LED_B_OFF();
-
-
- // Thats it...
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
- LEDsoff();
-// iso14a_set_tracing(TRUE);
-
-}
-
-void MifareUWriteBlock_Special(uint8_t arg0, uint8_t *datain)
-{
- // params
- uint8_t blockNo = arg0;
- byte_t blockdata[4];
-
- memcpy(blockdata, datain,4);
-
- // variables
- byte_t isOK = 0;
- uint8_t uid[10];
- uint32_t cuid;
-
- // clear trace
- iso14a_clear_trace();
- // iso14a_set_tracing(false);
-
- iso14443a_setup();
-
- LED_A_ON();
- LED_B_OFF();
- LED_C_OFF();
-
- while (true) {
- if(!iso14443a_select_card(uid, NULL, &cuid)) {
- if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");
- break;
- };
-
- if(mifare_ultra_special_writeblock(cuid, blockNo, blockdata)) {
- if (MF_DBGLEVEL >= 1) Dbprintf("Write block error");
- break;
- };
-
- if(mifare_ultra_halt(cuid)) {
- if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
- break;
- };
-
- isOK = 1;
- break;
- }
-
- if (MF_DBGLEVEL >= 2) DbpString("WRITE BLOCK FINISHED");
-
- // add trace trailer
- memset(uid, 0x44, 4);
- LogTrace(uid, 4, 0, 0, TRUE);
-
- LED_B_ON();
- cmd_send(CMD_ACK,isOK,0,0,0,0);
-// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
- LED_B_OFF();
-
-
- // Thats it...
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
- LEDsoff();
-// iso14a_set_tracing(TRUE);
-
-}
-
-// Return 1 if the nonce is invalid else return 0
-int valid_nonce(uint32_t Nt, uint32_t NtEnc, uint32_t Ks1, byte_t * parity) {
- return ((oddparity((Nt >> 24) & 0xFF) == ((parity[0]) ^ oddparity((NtEnc >> 24) & 0xFF) ^ BIT(Ks1,16))) & \
+\r
+}\r
+\r
+void MifareUWriteBlock(uint8_t arg0, uint8_t *datain)\r
+{\r
+ // params\r
+ uint8_t blockNo = arg0;\r
+ byte_t blockdata[16];\r
+\r
+ memset(blockdata,'\0',16);\r
+ memcpy(blockdata, datain,16);\r
+ \r
+ // variables\r
+ byte_t isOK = 0;\r
+ uint8_t uid[10];\r
+ uint32_t cuid;\r
+\r
+ // clear trace\r
+ iso14a_clear_trace();\r
+ // iso14a_set_tracing(false);\r
+\r
+ iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);\r
+\r
+ LED_A_ON();\r
+ LED_B_OFF();\r
+ LED_C_OFF();\r
+\r
+ while (true) {\r
+ if(!iso14443a_select_card(uid, NULL, &cuid)) {\r
+ if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");\r
+ break;\r
+ };\r
+\r
+ if(mifare_ultra_writeblock(cuid, blockNo, blockdata)) {\r
+ if (MF_DBGLEVEL >= 1) Dbprintf("Write block error");\r
+ break;\r
+ };\r
+\r
+ if(mifare_ultra_halt(cuid)) {\r
+ if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");\r
+ break;\r
+ };\r
+ \r
+ isOK = 1;\r
+ break;\r
+ }\r
+ \r
+ if (MF_DBGLEVEL >= 2) DbpString("WRITE BLOCK FINISHED");\r
+\r
+ // add trace trailer\r
+ memset(uid, 0x44, 4);\r
+ LogTrace(uid, 4, 0, 0, TRUE);\r
+\r
+ LED_B_ON();\r
+ cmd_send(CMD_ACK,isOK,0,0,0,0);\r
+// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));\r
+ LED_B_OFF();\r
+\r
+\r
+ // Thats it...\r
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+ LEDsoff();\r
+// iso14a_set_tracing(TRUE);\r
+\r
+}\r
+\r
+void MifareUWriteBlock_Special(uint8_t arg0, uint8_t *datain)\r
+{\r
+ // params\r
+ uint8_t blockNo = arg0;\r
+ byte_t blockdata[4];\r
+ \r
+ memcpy(blockdata, datain,4);\r
+\r
+ // variables\r
+ byte_t isOK = 0;\r
+ uint8_t uid[10];\r
+ uint32_t cuid;\r
+\r
+ // clear trace\r
+ iso14a_clear_trace();\r
+ // iso14a_set_tracing(false);\r
+\r
+ iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);\r
+\r
+ LED_A_ON();\r
+ LED_B_OFF();\r
+ LED_C_OFF();\r
+\r
+ while (true) {\r
+ if(!iso14443a_select_card(uid, NULL, &cuid)) {\r
+ if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");\r
+ break;\r
+ };\r
+\r
+ if(mifare_ultra_special_writeblock(cuid, blockNo, blockdata)) {\r
+ if (MF_DBGLEVEL >= 1) Dbprintf("Write block error");\r
+ break;\r
+ };\r
+\r
+ if(mifare_ultra_halt(cuid)) {\r
+ if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");\r
+ break;\r
+ };\r
+\r
+ isOK = 1;\r
+ break;\r
+ }\r
+\r
+ if (MF_DBGLEVEL >= 2) DbpString("WRITE BLOCK FINISHED");\r
+\r
+ // add trace trailer\r
+ memset(uid, 0x44, 4);\r
+ LogTrace(uid, 4, 0, 0, TRUE);\r
+\r
+ LED_B_ON();\r
+ cmd_send(CMD_ACK,isOK,0,0,0,0);\r
+// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));\r
+ LED_B_OFF();\r
+\r
+\r
+ // Thats it...\r
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+ LEDsoff();\r
+// iso14a_set_tracing(TRUE);\r
+\r
+}\r
+\r
+// Return 1 if the nonce is invalid else return 0\r
+int valid_nonce(uint32_t Nt, uint32_t NtEnc, uint32_t Ks1, byte_t * parity) {\r
+ return ((oddparity((Nt >> 24) & 0xFF) == ((parity[0]) ^ oddparity((NtEnc >> 24) & 0xFF) ^ BIT(Ks1,16))) & \\r