Skip to content

Commit af9567a

Browse files
committed
style
1 parent c92914d commit af9567a

File tree

7 files changed

+36
-31
lines changed

7 files changed

+36
-31
lines changed

armsrc/Standalone/hf_bog.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static void RAMFUNC SniffAndStore(uint8_t param) {
9090

9191
// Setup and start DMA.
9292
if (!FpgaSetupSscDma((uint8_t *)dmaBuf, DMA_BUFFER_SIZE)) {
93-
if (g_dbglevel > 1) {
93+
if (g_dbglevel > DBG_ERROR) {
9494
Dbprintf("FpgaSetupSscDma failed. Exiting");
9595
}
9696
return;
@@ -161,7 +161,7 @@ static void RAMFUNC SniffAndStore(uint8_t param) {
161161
if (triggered) {
162162
if ((receivedCmd) &&
163163
((receivedCmd[0] == MIFARE_ULEV1_AUTH) || (receivedCmd[0] == MIFARE_ULC_AUTH_1))) {
164-
if (g_dbglevel > 1)
164+
if (g_dbglevel > DBG_ERROR)
165165
Dbprintf("PWD-AUTH KEY: 0x%02x%02x%02x%02x", receivedCmd[1], receivedCmd[2],
166166
receivedCmd[3], receivedCmd[4]);
167167

@@ -225,7 +225,7 @@ static void RAMFUNC SniffAndStore(uint8_t param) {
225225

226226
// Write stuff to spiffs logfile
227227
if (auth_attempts > 0) {
228-
if (g_dbglevel > 1)
228+
if (g_dbglevel > DBG_ERROR)
229229
Dbprintf("[!] Authentication attempts = %u", auth_attempts);
230230

231231
if (!exists_in_spiffs((char *)HF_BOG_LOGFILE)) {
@@ -235,7 +235,7 @@ static void RAMFUNC SniffAndStore(uint8_t param) {
235235
}
236236
}
237237

238-
if (g_dbglevel > 1)
238+
if (g_dbglevel > DBG_ERROR)
239239
Dbprintf("[!] Wrote %u Authentication attempts into logfile", auth_attempts);
240240

241241
SpinErr(LED_A, 200, 5);

armsrc/fpgaloader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ int FpgaGetCurrent(void) {
635635
// if HF, Disable SSC DMA
636636
// turn off trace and leds off.
637637
void switch_off(void) {
638-
if (g_dbglevel > 3) {
638+
if (g_dbglevel > DBG_DEBUG) {
639639
Dbprintf("switch_off");
640640
}
641641

armsrc/i2c.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ bool I2C_WriteCmd(uint8_t device_cmd, uint8_t device_address) {
401401

402402
if (_break) {
403403

404-
if (g_dbglevel > 3) DbpString(I2C_ERROR);
404+
if (g_dbglevel > DBG_DEBUG) DbpString(I2C_ERROR);
405405

406406
return false;
407407
}
@@ -436,7 +436,7 @@ bool I2C_WriteByte(uint8_t data, uint8_t device_cmd, uint8_t device_address) {
436436

437437
I2C_Stop();
438438
if (_break) {
439-
if (g_dbglevel > 3) DbpString(I2C_ERROR);
439+
if (g_dbglevel > DBG_DEBUG) DbpString(I2C_ERROR);
440440
return false;
441441
}
442442
return true;
@@ -479,7 +479,7 @@ bool I2C_BufferWrite(const uint8_t *data, uint16_t len, uint8_t device_cmd, uint
479479

480480
I2C_Stop();
481481
if (_break) {
482-
if (g_dbglevel > 3) DbpString(I2C_ERROR);
482+
if (g_dbglevel > DBG_DEBUG) DbpString(I2C_ERROR);
483483
return false;
484484
}
485485
return true;
@@ -530,7 +530,7 @@ int16_t I2C_BufferRead(uint8_t *data, uint16_t len, uint8_t device_cmd, uint8_t
530530

531531
if (_break) {
532532
I2C_Stop();
533-
if (g_dbglevel > 3) DbpString(I2C_ERROR);
533+
if (g_dbglevel > DBG_DEBUG) DbpString(I2C_ERROR);
534534
return 0;
535535
}
536536

@@ -641,7 +641,7 @@ int16_t I2C_ReadFW(uint8_t *data, uint8_t len, uint8_t msb, uint8_t lsb, uint8_t
641641

642642
if (_break) {
643643
I2C_Stop();
644-
if (g_dbglevel > 3) DbpString(I2C_ERROR);
644+
if (g_dbglevel > DBG_DEBUG) DbpString(I2C_ERROR);
645645
return 0;
646646
}
647647

@@ -713,7 +713,7 @@ bool I2C_WriteFW(const uint8_t *data, uint8_t len, uint8_t msb, uint8_t lsb, uin
713713
I2C_Stop();
714714

715715
if (_break) {
716-
if (g_dbglevel > 3) DbpString(I2C_ERROR);
716+
if (g_dbglevel > DBG_DEBUG) DbpString(I2C_ERROR);
717717
return false;
718718
}
719719
return true;
@@ -825,7 +825,7 @@ bool GetATR(smart_card_atr_t *card_ptr, bool verbose) {
825825
chksum ^= card_ptr->atr[i];
826826

827827
if (chksum) {
828-
if (g_dbglevel > 2) DbpString("Wrong ATR checksum");
828+
if (g_dbglevel > DBG_INFO) DbpString("Wrong ATR checksum");
829829
}
830830
}
831831
}

armsrc/lfops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ void loadT55xxConfig(void) {
374374
memcpy((uint8_t *)&T55xx_Timing, buf, T55XX_CONFIG_LEN);
375375

376376
if (size == T55XX_CONFIG_LEN) {
377-
if (g_dbglevel > 1) DbpString("T55XX Config load success");
377+
if (g_dbglevel > DBG_ERROR) DbpString("T55XX Config load success");
378378
}
379379

380380
BigBuf_free();
@@ -1889,7 +1889,7 @@ void T55xxDangerousRawTest(const uint8_t *data, bool ledcontrol) {
18891889
for (uint8_t i = 0; i < c->bitlen; i++)
18901890
len = T55xx_SetBits(bs, len, c->data[i], 1, sizeof(bs));
18911891

1892-
if (g_dbglevel > 1) {
1892+
if (g_dbglevel > DBG_ERROR) {
18931893
Dbprintf("LEN %i, TIMING %i", len, c->time);
18941894
for (uint8_t i = 0; i < len; i++) {
18951895
uint8_t sendbits = (bs[BITSTREAM_BYTE(i)] >> BITSTREAM_BIT(i));

armsrc/mifaresim.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *uid, uint16_t
513513
struct Crypto1State *pcs;
514514
pcs = &mpcs;
515515

516-
uint32_t numReads = 0; //Counts numer of times reader reads a block
516+
uint32_t numReads = 0; // Counts numer of times reader reads a block
517517
uint8_t receivedCmd[MAX_MIFARE_FRAME_SIZE] = {0x00};
518518
uint8_t receivedCmd_dec[MAX_MIFARE_FRAME_SIZE] = {0x00};
519519
uint8_t receivedCmd_par[MAX_MIFARE_PARITY_SIZE] = {0x00};
@@ -526,10 +526,10 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *uid, uint16_t
526526
uint8_t rats_len = 0;
527527

528528

529-
//Here, we collect UID,sector,keytype,NT,AR,NR,NT2,AR2,NR2
529+
// Here, we collect UID,sector,keytype,NT,AR,NR,NT2,AR2,NR2
530530
// This will be used in the reader-only attack.
531531

532-
//allow collecting up to 16 sets of nonces to allow recovery of up to 16 keys
532+
// allow collecting up to 16 sets of nonces to allow recovery of up to 16 keys
533533
#define ATTACK_KEY_COUNT 16
534534
nonces_t ar_nr_resp[ATTACK_KEY_COUNT]; // for moebius attack type
535535
memset(ar_nr_resp, 0x00, sizeof(ar_nr_resp));
@@ -580,25 +580,29 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *uid, uint16_t
580580
}
581581

582582
FpgaEnableTracing();
583-
//Now, get data
583+
// Now, get data
584584
int res = EmGetCmd(receivedCmd, sizeof(receivedCmd), &receivedCmd_len, receivedCmd_par);
585585

586-
if (res == 2) { //Field is off!
587-
//FpgaDisableTracing();
586+
if (res == 2) { // Field is off!
587+
// FpgaDisableTracing();
588588
if ((flags & FLAG_CVE21_0430) == FLAG_CVE21_0430) {
589589
p_em[1] = 0x21;
590590
cve_flipper = 0;
591591
}
592592
LEDsoff();
593593
cardSTATE = MFEMUL_NOFIELD;
594-
if (g_dbglevel >= DBG_EXTENDED)
594+
595+
if (g_dbglevel >= DBG_EXTENDED) {
595596
Dbprintf("cardSTATE = MFEMUL_NOFIELD");
597+
}
596598
continue;
599+
597600
} else if (res == 1) { // button pressed
598601
FpgaDisableTracing();
599602
button_pushed = true;
600-
if (g_dbglevel >= DBG_EXTENDED)
603+
if (g_dbglevel >= DBG_EXTENDED) {
601604
Dbprintf("Button pressed");
605+
}
602606
break;
603607
}
604608

@@ -1438,12 +1442,13 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *uid, uint16_t
14381442
}
14391443
}
14401444
}
1445+
14411446
if (g_dbglevel >= DBG_ERROR) {
14421447
Dbprintf("Emulator stopped. Tracing: %d trace length: %d ", get_tracing(), BigBuf_get_traceLen());
14431448
}
14441449

14451450
if ((flags & FLAG_INTERACTIVE) == FLAG_INTERACTIVE) { // Interactive mode flag, means we need to send ACK
1446-
//Send the collected ar_nr in the response
1451+
// Send the collected ar_nr in the response
14471452
reply_ng(CMD_HF_MIFARE_SIMULATE, button_pushed ? PM3_EOPABORTED : PM3_SUCCESS, (uint8_t *)&ar_nr_resp[index], sizeof(nonces_t));
14481453
}
14491454

armsrc/mifaresniff_disabled.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void RAMFUNC SniffMifare(uint8_t param) {
8484
// Setup and start DMA.
8585
// set transfer address and number of bytes. Start transfer.
8686
if (!FpgaSetupSscDma(dmaBuf, DMA_BUFFER_SIZE)) {
87-
if (g_dbglevel > 1) Dbprintf("[!] FpgaSetupSscDma failed. Exiting");
87+
if (g_dbglevel > DBG_ERROR) Dbprintf("[!] FpgaSetupSscDma failed. Exiting");
8888
return;
8989
}
9090

client/src/wiegand_formats.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ static bool Pack_S12906b(int format_idx, wiegand_card_t *card, wiegand_message_t
732732
packed->Length = 36; // Set number of bits
733733
set_linear_field(packed, card->FacilityCode, 1, 8);
734734
set_linear_field(packed, card->CardNumber, 11, 24);
735-
set_bit_by_position(packed, oddparity32 (get_nonlinear_field(packed, S12906b_BITS_USED_BY_PARITY, S12906b_odd_parity_bit_0)), 0);
735+
set_bit_by_position(packed, oddparity32(get_nonlinear_field(packed, S12906b_BITS_USED_BY_PARITY, S12906b_odd_parity_bit_0)), 0);
736736
set_bit_by_position(packed, evenparity32(get_nonlinear_field(packed, S12906b_BITS_USED_BY_PARITY, S12906b_even_parity_bit_9)), 9);
737737
set_bit_by_position(packed, evenparity32(get_nonlinear_field(packed, S12906b_BITS_USED_BY_PARITY, S12906b_even_parity_bit_10)), 10);
738738
if (preamble) {
@@ -748,7 +748,7 @@ static bool Unpack_S12906b(wiegand_message_t *packed, wiegand_card_t *card) {
748748
card->FacilityCode = get_linear_field(packed, 1, 8);
749749
card->CardNumber = get_linear_field(packed, 11, 24);
750750
if (card->FacilityCode != S12906b_FACILITY_CODE) return false;
751-
bool odd_1 = get_bit_by_position(packed, 0) == oddparity32( get_nonlinear_field(packed, S12906b_BITS_USED_BY_PARITY, S12906b_odd_parity_bit_0));
751+
bool odd_1 = get_bit_by_position(packed, 0) == oddparity32(get_nonlinear_field(packed, S12906b_BITS_USED_BY_PARITY, S12906b_odd_parity_bit_0));
752752
bool even1 = get_bit_by_position(packed, 9) == evenparity32(get_nonlinear_field(packed, S12906b_BITS_USED_BY_PARITY, S12906b_even_parity_bit_9));
753753
bool even2 = get_bit_by_position(packed, 10) == evenparity32(get_nonlinear_field(packed, S12906b_BITS_USED_BY_PARITY, S12906b_even_parity_bit_10));
754754
card->ParityValid = odd_1 && even1 && even2;
@@ -1548,8 +1548,8 @@ static const cardformat_t FormatTable[] = {
15481548
{"C1k48s", Pack_C1k48s, Unpack_C1k48s, "HID Corporate 1000 48-bit std", 48, {1, 1, 0, 0, 1, 0x003FFFFFu, 0x00000000007FFFFFu, 0x00000000u, 0x00000000u}}, // imported from old pack/unpack
15491549
{"Avig56", Pack_Avig56, Unpack_Avig56, "Avigilon 56-bit", 56, {1, 1, 0, 0, 1, 0x000FFFFFu, 0x00000003FFFFFFFFu, 0x00000000u, 0x00000000u}},
15501550
{"IR56", Pack_IR56, Unpack_IR56, "Inner Range 56-bit", 56, {1, 1, 0, 0, 0, 0x00FFFFFFu, 0x00000000FFFFFFFFu, 0x00000000u, 0x00000000u}},
1551-
{NULL, NULL, NULL, NULL, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0}} // Must null terminate array
1552-
};
1551+
{NULL, NULL, NULL, NULL, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0}} // Must null terminate array
1552+
};
15531553

15541554
void HIDListFormats(void) {
15551555
if (FormatTable[0].Name == NULL)
@@ -1610,16 +1610,16 @@ bool validate_card_limit(int format_idx, wiegand_card_t *card) {
16101610
cardformatdescriptor_t card_descriptor = FormatTable[format_idx].Fields;
16111611

16121612
// If a field is not supported, it's implicitly required to be zero
1613-
if ((!card_descriptor.hasCardNumber ) && (card->CardNumber != 0u)) {
1613+
if ((!card_descriptor.hasCardNumber) && (card->CardNumber != 0u)) {
16141614
return false; // Format does not support card number, but non-zero card number provided
16151615
}
16161616
if ((!card_descriptor.hasFacilityCode) && (card->FacilityCode != 0u)) {
16171617
return false; // Format does not support facility code, but non-zero facility code provided
16181618
}
1619-
if ((!card_descriptor.hasIssueLevel ) && (card->IssueLevel != 0u)) {
1619+
if ((!card_descriptor.hasIssueLevel) && (card->IssueLevel != 0u)) {
16201620
return false; // Format does not support issue levels, but non-zero issue level provided
16211621
}
1622-
if ((!card_descriptor.hasOEMCode ) && (card->OEM != 0u)) {
1622+
if ((!card_descriptor.hasOEMCode) && (card->OEM != 0u)) {
16231623
return false; // Format does not support OEM codes, but non-zero OEM code provided
16241624
}
16251625
return !((card->FacilityCode > card_descriptor.MaxFC) ||

0 commit comments

Comments
 (0)