From ffa3e2a0f8dfea6a3a6a5606ef50d53fae3ab2e3 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 13 Sep 2019 16:25:33 +0200 Subject: [PATCH] style --- armsrc/Standalone/lf_samyrun.c | 28 ++++++++++---------- armsrc/iclass.c | 44 +++++++++++++++---------------- armsrc/mifarecmd.c | 22 ++++++++-------- armsrc/pcf7931.c | 48 +++++++++++++++++----------------- armsrc/ticks.c | 2 +- 5 files changed, 72 insertions(+), 72 deletions(-) diff --git a/armsrc/Standalone/lf_samyrun.c b/armsrc/Standalone/lf_samyrun.c index 58c5dfd5e..d56f48e24 100644 --- a/armsrc/Standalone/lf_samyrun.c +++ b/armsrc/Standalone/lf_samyrun.c @@ -54,15 +54,15 @@ void RunMod() { // Was our button held down or pressed? int button_pressed = BUTTON_HELD(280); - if ( button_pressed != BUTTON_HOLD ) + if (button_pressed != BUTTON_HOLD) continue; -/* -#define BUTTON_NO_CLICK 0 -#define BUTTON_SINGLE_CLICK -1 -#define BUTTON_DOUBLE_CLICK -2 -*/ + /* + #define BUTTON_NO_CLICK 0 + #define BUTTON_SINGLE_CLICK -1 + #define BUTTON_DOUBLE_CLICK -2 + */ - if ( state == STATE_READ ) { + if (state == STATE_READ) { if (selected == 0) { LED_A_ON(); @@ -89,17 +89,17 @@ void RunMod() { Dbprintf("[=] recorded %x | %x%08x", selected, high[selected], low[selected]); // got nothing. blink and loop. - if ( hi == 0 && lo == 0 ) { - SpinErr( (selected == 0) ? LED_A : LED_B, 100, 12); + if (hi == 0 && lo == 0) { + SpinErr((selected == 0) ? LED_A : LED_B, 100, 12); DbpString("[=] only got zeros, retry recording after click"); continue; } - SpinErr( (selected == 0) ? LED_A : LED_B, 250, 2); + SpinErr((selected == 0) ? LED_A : LED_B, 250, 2); state = STATE_SIM; continue; - } else if ( state == STATE_SIM ) { + } else if (state == STATE_SIM) { LED_C_ON(); // Simulate LED_D_OFF(); @@ -113,11 +113,11 @@ void RunMod() { DbpString("[=] simulating done"); uint8_t leds = ((selected == 0) ? LED_A : LED_B) | LED_C; - SpinErr( leds , 250, 2); + SpinErr(leds, 250, 2); state = STATE_CLONE; continue; - } else if ( state == STATE_CLONE ) { + } else if (state == STATE_CLONE) { LED_C_OFF(); LED_D_ON(); // clone @@ -138,7 +138,7 @@ void RunMod() { } } - SpinErr( (LED_A | LED_B | LED_C | LED_D), 250, 5); + SpinErr((LED_A | LED_B | LED_C | LED_D), 250, 5); DbpString("[=] You can take shell back :) ..."); LEDsoff(); } diff --git a/armsrc/iclass.c b/armsrc/iclass.c index 5bbcc1b4b..fd5d663fd 100644 --- a/armsrc/iclass.c +++ b/armsrc/iclass.c @@ -895,7 +895,7 @@ void RAMFUNC SniffIClass(void) { // time ZERO, the point from which it all is calculated. time_0 = GetCountSspClk(); - + // loop and listen // every sample (1byte in data), // contains HIGH nibble = reader data @@ -962,7 +962,7 @@ void RAMFUNC SniffIClass(void) { */ - uint8_t tag_byte = ((previous_data & 0xF) << 4 ) | (*data & 0xF); + uint8_t tag_byte = ((previous_data & 0xF) << 4) | (*data & 0xF); if (ManchesterDecoding_iclass(tag_byte)) { time_stop = GetCountSspClk() - time_0; LogTrace(Demod.output, Demod.len, time_start, time_stop, NULL, false); @@ -976,12 +976,12 @@ void RAMFUNC SniffIClass(void) { } } // end main loop -/* - if (DBGLEVEL >= 1) { - DbpString("[+] Sniff statistics:"); - Dbhexdump(ICLASS_DMA_BUFFER_SIZE, data, false); - } -*/ + /* + if (DBGLEVEL >= 1) { + DbpString("[+] Sniff statistics:"); + Dbhexdump(ICLASS_DMA_BUFFER_SIZE, data, false); + } + */ switch_off(); } @@ -1522,7 +1522,7 @@ int doIClassSimulation(int simulationMode, uint8_t *reader_mac_buf) { trace_data = csn_data; trace_data_size = sizeof(csn_data); goto send; - } else if (cmd == ICLASS_CMD_READCHECK ) { // 0x88 + } else if (cmd == ICLASS_CMD_READCHECK) { // 0x88 // Read e-purse KD (88 02) KC (18 02) modulated_response = resp_cc; modulated_response_size = resp_cc_len; //order = 4; @@ -1898,7 +1898,7 @@ bool sendCmdGetResponseWithRetries(uint8_t *command, size_t cmdsize, uint8_t *re // update/write command takes 4ms to 15ms before responding int old_wait = g_wait; - if ( (command[0] & 0xF) == ICLASS_CMD_UPDATE) + if ((command[0] & 0xF) == ICLASS_CMD_UPDATE) g_wait = 3900; uint8_t got_n = ReaderReceiveIClass(resp); @@ -1934,8 +1934,8 @@ uint8_t handshakeIclassTag_ext(uint8_t *card_data, bool use_credit_key) { uint8_t readcheck_cc[] = { 0x80 | ICLASS_CMD_READCHECK, 0x02 }; // Bit 4: K.If this bit equals to one, the READCHECK will use the Credit Key (Kc); if equals to zero, Debit Key (Kd) willbe used - // bit 7: parity. - + // bit 7: parity. + if (use_credit_key) readcheck_cc[0] = 0x10 | ICLASS_CMD_READCHECK; @@ -1945,14 +1945,14 @@ uint8_t handshakeIclassTag_ext(uint8_t *card_data, bool use_credit_key) { ReaderTransmitIClass_ext(act_all, 1, 330 + 180); // Card present? - if (ReaderReceiveIClass(resp) == 0) + if (ReaderReceiveIClass(resp) == 0) return 0; //Send Identify ReaderTransmitIClass(identify, 1); //We expect a 10-byte response here, 8 byte anticollision-CSN and 2 byte CRC - if ( ReaderReceiveIClass(resp) != 10 ) + if (ReaderReceiveIClass(resp) != 10) return 0; //Copy the Anti-collision CSN to our select-packet @@ -1962,28 +1962,28 @@ uint8_t handshakeIclassTag_ext(uint8_t *card_data, bool use_credit_key) { ReaderTransmitIClass(select, sizeof(select)); //We expect a 10-byte response here, 8 byte CSN and 2 byte CRC - if ( ReaderReceiveIClass(resp) != 10) + if (ReaderReceiveIClass(resp) != 10) return 0; - // Card selected, now read e-purse (cc) (block2) (only 8 bytes no CRC) + // Card selected, now read e-purse (cc) (block2) (only 8 bytes no CRC) // ReaderTransmitIClass(readcheck_cc, sizeof(readcheck_cc)); // if (ReaderReceiveIClass(resp) == 8) { // //Save CC (e-purse) in response data // memcpy(card_data+8, resp, 8); // read_status++; // } - + //Success - level 1, we got CSN //Save CSN in response data memcpy(card_data, resp, 8); - + bool isBlk_2 = sendCmdGetResponseWithRetries(readcheck_cc, sizeof(readcheck_cc), resp, 8, 3); //Flag that we got to at least stage 1, read CSN - if ( isBlk_2 == false) { + if (isBlk_2 == false) { return 1; } - + //Save CC (e-purse) in response data memcpy(card_data + 8, resp, 8); @@ -2283,7 +2283,7 @@ void iClass_Authentication(uint8_t *mac) { // 6 retries uint8_t isOK = sendCmdGetResponseWithRetries(check, sizeof(check), resp, 4, 6); - reply_ng(CMD_HF_ICLASS_AUTH, PM3_SUCCESS, (uint8_t*)&isOK ,sizeof(uint8_t)); + reply_ng(CMD_HF_ICLASS_AUTH, PM3_SUCCESS, (uint8_t *)&isOK, sizeof(uint8_t)); } typedef struct iclass_premac { @@ -2460,7 +2460,7 @@ bool iClass_WriteBlock_ext(uint8_t blockno, uint8_t *data) { void iClass_WriteBlock(uint8_t blockno, uint8_t *data) { uint8_t isOK = iClass_WriteBlock_ext(blockno, data); switch_off(); - reply_ng(CMD_HF_ICLASS_WRITEBL, PM3_SUCCESS, (uint8_t*)&isOK, sizeof(uint8_t)); + reply_ng(CMD_HF_ICLASS_WRITEBL, PM3_SUCCESS, (uint8_t *)&isOK, sizeof(uint8_t)); } // turn off afterwards diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index e8cce812f..1ca809a8a 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -1997,18 +1997,18 @@ void MifareCIdent() { // Generation 1 test ReaderTransmitBitsPar(wupC1, 7, NULL, NULL); - + if (ReaderReceive(rec, recpar) || (rec[0] != 0x0a)) { - ReaderTransmit(wupC2, sizeof(wupC2), NULL); - - if (!ReaderReceive(rec, recpar) || (rec[0] != 0x0a)) { - isGen = GEN_1B; - goto OUT; - }; - isGen = GEN_1A; - goto OUT; - } + ReaderTransmit(wupC2, sizeof(wupC2), NULL); + + if (!ReaderReceive(rec, recpar) || (rec[0] != 0x0a)) { + isGen = GEN_1B; + goto OUT; + }; + isGen = GEN_1A; + goto OUT; + } // reset card FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); @@ -2017,7 +2017,7 @@ void MifareCIdent() { int res = iso14443a_select_card(uid, NULL, &cuid, true, 0, true); if (res == 2) { - Dbprintf("cident AA55C396 == %08X", cuid); + Dbprintf("cident AA55C396 == %08X", cuid); if (cuid == 0xAA55C396) { isGen = GEN_UNFUSED; goto OUT; diff --git a/armsrc/pcf7931.c b/armsrc/pcf7931.c index 1690c6ad3..2bc101a48 100644 --- a/armsrc/pcf7931.c +++ b/armsrc/pcf7931.c @@ -94,10 +94,10 @@ size_t DemodPCF7931(uint8_t **outBlocks) { } else { // Error if (++warnings > 10) { - - if ( DBGLEVEL >= DBG_EXTENDED ) + + if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("Error: too many detection errors, aborting."); - + return 0; } } @@ -138,10 +138,10 @@ bool IsBlock0PCF7931(uint8_t *block) { // assuming all RFU bits are set to 0 // if PAC is enabled password is set to 0 if (block[7] == 0x01) { - if (!memcmp(block, "\x00\x00\x00\x00\x00\x00\x00", 7) - && !memcmp(block + 9, "\x00\x00\x00\x00\x00\x00\x00", 7)) { + if (!memcmp(block, "\x00\x00\x00\x00\x00\x00\x00", 7) + && !memcmp(block + 9, "\x00\x00\x00\x00\x00\x00\x00", 7)) { return true; - } + } } else if (block[7] == 0x00) { if (!memcmp(block + 9, "\x00\x00\x00\x00\x00\x00\x00", 7)) { return true; @@ -158,14 +158,14 @@ bool IsBlock1PCF7931(uint8_t *block) { uint8_t rlb = block[15]; if (block[10] == 0 - && block[11] == 0 - && block[12] == 0 - && block[13] == 0) { + && block[11] == 0 + && block[12] == 0 + && block[13] == 0) { // block 1 is sent only if (RLB >= 1 && RFB <= 1) or RB1 enabled if (rfb <= rlb - && rfb <= 9 - && rlb <= 9 - && ((rfb <= 1 && rlb >= 1) || rb1)) { + && rfb <= 9 + && rlb <= 9 + && ((rfb <= 1 && rlb >= 1) || rb1)) { return true; } } @@ -203,17 +203,17 @@ void ReadPCF7931() { // exit if no block is received if (errors >= 10 && found_blocks == 0 && single_blocks_cnt == 0) { - if ( DBGLEVEL >= DBG_INFO ) + if (DBGLEVEL >= DBG_INFO) Dbprintf("[!!] Error, no tag or bad tag"); - + return; } // exit if too many errors during reading if (tries > 50 && (2 * errors > tries)) { - - if ( DBGLEVEL >= DBG_INFO ) + + if (DBGLEVEL >= DBG_INFO) Dbprintf("[!!] Error reading the tag, only partial content"); - + goto end; } @@ -242,9 +242,9 @@ void ReadPCF7931() { continue; } - if ( DBGLEVEL >= DBG_EXTENDED ) + if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("(dbg) got %d blocks (%d/%d found) (%d tries, %d errors)", n, found_blocks, (max_blocks == 0 ? found_blocks : max_blocks), tries, errors); - + for (i = 0; i < n; ++i) { print_result("got consecutive blocks", tmp_blocks[i], 16); } @@ -306,9 +306,9 @@ void ReadPCF7931() { } ++tries; if (BUTTON_PRESS()) { - if ( DBGLEVEL >= DBG_EXTENDED) + if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("Button pressed, stopping."); - + goto end; } } while (found_blocks < max_blocks); @@ -421,7 +421,7 @@ static void RealWritePCF7931(uint8_t *pass, uint16_t init_delay, int32_t l, int3 */ void WritePCF7931(uint8_t pass1, uint8_t pass2, uint8_t pass3, uint8_t pass4, uint8_t pass5, uint8_t pass6, uint8_t pass7, uint16_t init_delay, int32_t l, int32_t p, uint8_t address, uint8_t byte, uint8_t data) { - if ( DBGLEVEL >= DBG_INFO ) { + if (DBGLEVEL >= DBG_INFO) { Dbprintf("Initialization delay : %d us", init_delay); Dbprintf("Offsets : %d us on the low pulses width, %d us on the low pulses positions", l, p); } @@ -444,10 +444,10 @@ void WritePCF7931(uint8_t pass1, uint8_t pass2, uint8_t pass3, uint8_t pass4, ui void SendCmdPCF7931(uint32_t *tab) { uint16_t u = 0, tempo = 0; - if ( DBGLEVEL >= DBG_INFO ) { + if (DBGLEVEL >= DBG_INFO) { Dbprintf("Sending data frame..."); } - + FpgaDownloadAndGo(FPGA_BITSTREAM_LF); FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125kHz FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_PASSTHRU); diff --git a/armsrc/ticks.c b/armsrc/ticks.c index 1510de490..7b66d17e6 100644 --- a/armsrc/ticks.c +++ b/armsrc/ticks.c @@ -187,7 +187,7 @@ uint32_t RAMFUNC GetCountSspClk(void) { uint32_t RAMFUNC GetCountSspClkDelta(uint32_t start) { uint32_t stop = GetCountSspClk(); - if ( stop >= start ) + if (stop >= start) return stop - start; return (UINT32_MAX - start) + stop; }