static void frame_append_bit(struct legic_frame * const f, int bit)
{
- if(f->bits >= 31)
+ if (f->bits >= 31)
return; /* Overflow, won't happen */
- f->data |= (bit<<f->bits);
+ f->data |= (bit << f->bits);
f->bits++;
}
frame_receive_rwd(¤t_frame, 12, 1);
byte = current_frame.data & 0xff;
+
if( LegicCRC(byte_index, byte, cmd_sz) != (current_frame.data >> 8) ) {
Dbprintf("!!! crc mismatch: expected %x but got %x !!!",
- LegicCRC(byte_index, current_frame.data & 0xff, cmd_sz), current_frame.data >> 8);
+ LegicCRC(byte_index, current_frame.data & 0xff, cmd_sz),
+ current_frame.data >> 8);
return -1;
}
*/
int legic_write_byte(int byte, int addr, int addr_sz) {
//do not write UID, CRC, DCF
- if(addr <= 0x06) {
+ if(addr <= 0x06)
return 0;
- }
//== send write command ==============================
crc_clear(&legic_crc);
\r
set_tracing(TRUE);\r
\r
- for (i = 0; i < keyCount; i++) {\r
- if(mifare_classic_halt(pcs, cuid)) {\r
+ for (i = 0; i < keyCount; ++i) {\r
+ if (mifare_classic_halt(pcs, cuid))\r
if (MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Halt error");\r
- }\r
\r
- if(!iso14443a_select_card(uid, NULL, &cuid, true, 0)) {\r
+ if (!iso14443a_select_card(uid, NULL, &cuid, true, 0)) {\r
if (OLD_MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Can't select card");\r
break;\r
- };\r
+ }\r
\r
ui64Key = bytes_to_num(datain + i * 6, 6);\r
- if(mifare_classic_auth(pcs, cuid, blockNo, keyType, ui64Key, AUTH_FIRST)) {\r
+ if (mifare_classic_auth(pcs, cuid, blockNo, keyType, ui64Key, AUTH_FIRST))\r
continue;\r
- };\r
\r
isOK = 1;\r
break;\r
}\r
- \r
- // ----------------------------- crypto1 destroy\r
crypto1_destroy(pcs);\r
\r
LED_B_ON();\r
cmd_send(CMD_ACK,isOK,0,0,datain + i * 6,6);\r
- LED_B_OFF();\r
-\r
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
LEDsoff();\r
set_tracing(FALSE);\r
\r
static int sniffState = SNF_INIT;\r
static uint8_t sniffUIDType;\r
-static uint8_t sniffUID[8] = {0x00};\r
-static uint8_t sniffATQA[2] = {0x00};\r
+static uint8_t sniffUID[8];\r
+static uint8_t sniffATQA[2];\r
static uint8_t sniffSAK;\r
-static uint8_t sniffBuf[16] = {0x00};\r
-static uint32_t timerData = 0;\r
+static uint8_t sniffBuf[16];\r
+static uint32_t timerData;\r
\r
\r
bool MfSniffInit(void){\r