Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
iceman1001 committed Apr 7, 2024
1 parent 9ba8937 commit 4e54005
Show file tree
Hide file tree
Showing 28 changed files with 2,041 additions and 2,100 deletions.
2 changes: 1 addition & 1 deletion armsrc/BigBuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ bool LogTrace_ISO15693(const uint8_t *bytes, uint16_t len, uint32_t ts_start, ui
// specific LogTrace function for bitstreams: the partial byte size is stored in first parity byte. E.g. bitstream "1100 00100010" -> partial byte: 4 bits
bool RAMFUNC LogTraceBits(const uint8_t *btBytes, uint16_t bitLen, uint32_t timestamp_start, uint32_t timestamp_end, bool reader2tag) {

if ( bitLen == 0 ) {
if (bitLen == 0) {
return false;
}

Expand Down
32 changes: 16 additions & 16 deletions armsrc/hitag2.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,9 @@ static bool hitag2_write_page(uint8_t *rx, const size_t rxlen, uint8_t *tx, size
writestate = WRITE_STATE_PROG;
} else {
Dbprintf("hitag2_write_page: Page number was not received correctly: rxlen %d rx %02x%02x%02x%02x"
, rxlen
, rx[0], rx[1], rx[2], rx[3]
);
, rxlen
, rx[0], rx[1], rx[2], rx[3]
);
bSuccessful = false;
return false;
}
Expand All @@ -651,7 +651,7 @@ static bool hitag2_write_page(uint8_t *rx, const size_t rxlen, uint8_t *tx, size
Dbprintf("hitag2_write_page: Unknown state " _RED_("%d"), writestate);
bSuccessful = false;
return false;
}
}
}
return true;
}
Expand Down Expand Up @@ -792,10 +792,10 @@ static bool hitag2_crypto(uint8_t *rx, const size_t rxlen, uint8_t *tx, size_t *

uint32_t ui32uid = rx[0] | ((uint32_t)rx[1]) << 8 | ((uint32_t)rx[2]) << 16 | ((uint32_t)rx[3]) << 24;
DBG Dbprintf("hitag2_crypto: key=0x%x%x uid=0x%x"
, (uint32_t)((REV64(ui64key)) >> 32)
, (uint32_t)((REV64(ui64key)) & 0xffffffff)
, REV32(ui32uid)
);
, (uint32_t)((REV64(ui64key)) >> 32)
, (uint32_t)((REV64(ui64key)) & 0xffffffff)
, REV32(ui32uid)
);

cipher_state = ht2_hitag2_init(REV64(ui64key), REV32(ui32uid), 0);

Expand Down Expand Up @@ -1024,7 +1024,7 @@ void SniffHitag2(bool ledcontrol) {
lf_init(false, false, ledcontrol);
// no logging of the raw signal
// g_logging = lf_get_reader_modulation();
// g_logging = lf_get_reader_modulation();
g_logging = false;
uint32_t total_count = 0;
Expand Down Expand Up @@ -1456,7 +1456,7 @@ void SimulateHitag2(bool ledcontrol) {
// NRZ modulation: (11 => --|) or (11 __|)
nrz_samples[nrzs++] = reader_modulation;
if (nrzs < max_nrzs) {
nrz_samples[nrzs++] = reader_modulation;
nrz_samples[nrzs++] = reader_modulation;
}
// Invert tag modulation state
reader_modulation ^= 1;
Expand Down Expand Up @@ -1875,7 +1875,7 @@ void ReaderHitag(hitag_function htf, const hitag_data *htd, bool ledcontrol) {
// Store the TX frame, we do this now at this point, to avoid delay in processing
// and to be able to overwrite the first samples with the trace (since they currently
// still use the same memory space)
LogTraceBits(tx, txlen, command_start, command_start + command_duration, true);
LogTraceBits(tx, txlen, command_start, command_start + command_duration, true);

// Reset values for receiving frames
memset(rx, 0x00, sizeof(rx));
Expand Down Expand Up @@ -1941,7 +1941,7 @@ void ReaderHitag(hitag_function htf, const hitag_data *htd, bool ledcontrol) {
}

// Check if frame was captured and store it
LogTraceBits(rx, rxlen, response_start, response_start + response_duration, false);
LogTraceBits(rx, rxlen, response_start, response_start + response_duration, false);

// TODO when using cumulative time for command_start, pm3 doesn't reply anymore, e.g. on lf hitag reader --23 -k 4F4E4D494B52
// Use delta time?
Expand Down Expand Up @@ -2217,7 +2217,7 @@ void WriterHitag(hitag_function htf, const hitag_data *htd, int page, bool ledco
// Store the TX frame, we do this now at this point, to avoid delay in processing
// and to be able to overwrite the first samples with the trace (since they currently
// still use the same memory space)
LogTraceBits(tx, txlen, command_start, command_start + command_duration, true);
LogTraceBits(tx, txlen, command_start, command_start + command_duration, true);

// Reset values for receiving frames
memset(rx, 0x00, sizeof(rx));
Expand Down Expand Up @@ -2248,7 +2248,7 @@ void WriterHitag(hitag_function htf, const hitag_data *htd, int page, bool ledco

// Verify if the header consists of five consecutive ones
if (nrzs < 5) {
DBG Dbprintf("Detected unexpected number of manchester decoded samples [%zu]", nrzs);
DBG Dbprintf("Detected unexpected number of manchester decoded samples [%zu]", nrzs);
break;
} else {

Expand Down Expand Up @@ -2287,8 +2287,8 @@ void WriterHitag(hitag_function htf, const hitag_data *htd, int page, bool ledco
}

// Check if frame was captured and store it
LogTraceBits(rx, rxlen, response_start, response_start + response_duration, false);
command_start = 0;
LogTraceBits(rx, rxlen, response_start, response_start + response_duration, false);
command_start = 0;
nrzs = 0;
}

Expand Down
6 changes: 3 additions & 3 deletions armsrc/hitagS.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,9 @@ static void hitagS_handle_reader_command(uint8_t *rx, const size_t rxlen,
temp2++;
*txlen = 32;
state = ht2_hitag2_init(REV64(tag.key),
REV32((tag.pages[0][3] << 24) + (tag.pages[0][2] << 16) + (tag.pages[0][1] << 8) + tag.pages[0][0]),
REV32((rx[3] << 24) + (rx[2] << 16) + (rx[1] << 8) + rx[0])
);
REV32((tag.pages[0][3] << 24) + (tag.pages[0][2] << 16) + (tag.pages[0][1] << 8) + tag.pages[0][0]),
REV32((rx[3] << 24) + (rx[2] << 16) + (rx[1] << 8) + rx[0])
);
Dbprintf(",{0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X}",
rx[0], rx[1], rx[2], rx[3],
rx[4], rx[5], rx[6], rx[7]
Expand Down
22 changes: 11 additions & 11 deletions client/src/cmddata.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ static char *commaprint(size_t n) {
static int comma = '\0';
static char retbuf[30];

char *p = &retbuf[sizeof(retbuf)-1];
char *p = &retbuf[sizeof(retbuf) - 1];
int i = 0;

if (comma == '\0') {

struct lconv *lcp = localeconv();
if (lcp != NULL) {

if(lcp->thousands_sep != NULL && *lcp->thousands_sep != '\0') {
if (lcp->thousands_sep != NULL && *lcp->thousands_sep != '\0') {
comma = *lcp->thousands_sep;
} else {
comma = ',';
Expand All @@ -76,7 +76,7 @@ static char *commaprint(size_t n) {
*p = '\0';

do {
if ( i % 3 == 0 && i != 0 ) {
if (i % 3 == 0 && i != 0) {
*--p = comma;
}

Expand Down Expand Up @@ -3288,9 +3288,9 @@ static int CmdNumCon(const char *Cmd) {
if (slen) {
size_t n = (slen >> 1);
uint8_t *d = calloc(n, sizeof(uint8_t));
if (d != NULL ) {
if (d != NULL) {
hexstr_to_byte_array(s, d, &n);
PrintAndLogEx(SUCCESS, "ascii... " _YELLOW_("%s"), sprint_ascii((const uint8_t*)d, n));
PrintAndLogEx(SUCCESS, "ascii... " _YELLOW_("%s"), sprint_ascii((const uint8_t *)d, n));
free(d);
}
}
Expand All @@ -3314,9 +3314,9 @@ static int CmdNumCon(const char *Cmd) {
str_reverse(s, strlen(s));
size_t n = (slen >> 1);
uint8_t *d = calloc(n, sizeof(uint8_t));
if (d != NULL ) {
if (d != NULL) {
hexstr_to_byte_array(s, d, &n);
PrintAndLogEx(SUCCESS, "ascii... " _YELLOW_("%s"), sprint_ascii((const uint8_t*)d, n));
PrintAndLogEx(SUCCESS, "ascii... " _YELLOW_("%s"), sprint_ascii((const uint8_t *)d, n));
free(d);
}
}
Expand Down Expand Up @@ -3353,9 +3353,9 @@ static int CmdNumCon(const char *Cmd) {
str_inverse_hex(s, strlen(s));
size_t n = (slen >> 1);
uint8_t *d = calloc(n, sizeof(uint8_t));
if (d != NULL ) {
if (d != NULL) {
hexstr_to_byte_array(s, d, &n);
PrintAndLogEx(SUCCESS, "ascii... " _YELLOW_("%s"), sprint_ascii((const uint8_t*)d, n));
PrintAndLogEx(SUCCESS, "ascii... " _YELLOW_("%s"), sprint_ascii((const uint8_t *)d, n));
free(d);
}
}
Expand Down Expand Up @@ -3779,7 +3779,7 @@ static int CmdXor(const char *Cmd) {
PrintAndLogEx(FAILED, "Length mismatch, got %i != %i", hlen, xlen);
return PM3_EINVARG;
}

PrintAndLogEx(SUCCESS, "input... %s", sprint_hex_inrow(hex, hlen));
PrintAndLogEx(SUCCESS, "xor..... %s", sprint_hex_inrow(xor, xlen));
hex_xor(hex, xor, hlen);
Expand Down Expand Up @@ -3841,7 +3841,7 @@ static command_t CommandTable[] = {
{"samples", CmdSamples, IfPm3Present, "Get raw samples for graph window ( GraphBuffer )"},
{"save", CmdSave, AlwaysAvailable, "Save signal trace data ( GraphBuffer )"},
{"setdebugmode", CmdSetDebugMode, AlwaysAvailable, "Set Debugging Level on client side"},
{"xor", CmdXor, AlwaysAvailable, "Xor a input string"},
{"xor", CmdXor, AlwaysAvailable, "Xor a input string"},
{NULL, NULL, NULL, NULL}
};

Expand Down
2 changes: 1 addition & 1 deletion client/src/cmdhf14a.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ int CmdHF14ASniff(const char *Cmd) {
"Sniff the communication between Hitag reader and tag.\n"
"Use `hf 14a list` to view collected data.",
" hf 14a sniff -c -r"
);
);
void *argtable[] = {
arg_param_begin,
arg_lit0("c", "card", "triggered by first data from card"),
Expand Down
26 changes: 13 additions & 13 deletions client/src/cmdhfmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4250,12 +4250,12 @@ void printKeyTableEx(size_t sectorscnt, sector_t *e_sector, uint8_t start_sector
}

PrintAndLogEx(SUCCESS, " " _YELLOW_("%03d") " | %03d | %s | %s | %s | %s %s"
, s
, mfSectorTrailerOfSector(s)
, strA, resA
, strB, resB
, extra
);
, s
, mfSectorTrailerOfSector(s)
, strA, resA
, strB, resB
, extra
);
}

PrintAndLogEx(SUCCESS, "-----+-----+--------------+---+--------------+----");
Expand Down Expand Up @@ -7660,7 +7660,7 @@ static int CmdHF14AMfView(const char *Cmd) {
}

static int parse_gtu_cfg(uint8_t *d, size_t n) {

PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "---------- " _CYAN_("GTU Gen4 Configuration") " -------------------------------------");
if (n != 30 && n != 32) {
Expand All @@ -7676,7 +7676,7 @@ static int parse_gtu_cfg(uint8_t *d, size_t n) {
PrintAndLogEx(INFO, _CYAN_("Config 1 - UID & modes"));
PrintAndLogEx(INFO, "%s", sprint_hex_inrow(d, 8));
PrintAndLogEx(INFO, "%02X.............. " NOLF, d[0]);
bool is_ul_enabled = ( d[0] == 1 );
bool is_ul_enabled = (d[0] == 1);
switch (d[0]) {
case 0x00:
PrintAndLogEx(NORMAL, "MIFARE Classic mode");
Expand Down Expand Up @@ -7743,16 +7743,16 @@ static int parse_gtu_cfg(uint8_t *d, size_t n) {
PrintAndLogEx(INFO, "......%02X........ " NOLF, d[27]);
switch (d[27]) {
case 0x00:
PrintAndLogEx(NORMAL, "%s", (is_ul_enabled) ? _GREEN_("Ultralight EV1") : "Ultralight Ev1" );
PrintAndLogEx(NORMAL, "%s", (is_ul_enabled) ? _GREEN_("Ultralight EV1") : "Ultralight Ev1");
break;
case 0x01:
PrintAndLogEx(NORMAL, "%s", (is_ul_enabled) ? _GREEN_("NTAG") : "NTAG" );
PrintAndLogEx(NORMAL, "%s", (is_ul_enabled) ? _GREEN_("NTAG") : "NTAG");
break;
case 0x02:
PrintAndLogEx(NORMAL, "%s", (is_ul_enabled) ? _GREEN_("Ultralight C") : "Ultralight C" );
PrintAndLogEx(NORMAL, "%s", (is_ul_enabled) ? _GREEN_("Ultralight C") : "Ultralight C");
break;
case 0x03:
PrintAndLogEx(NORMAL, "%s", (is_ul_enabled) ? _GREEN_("Ultralight") : "Ultralight" );
PrintAndLogEx(NORMAL, "%s", (is_ul_enabled) ? _GREEN_("Ultralight") : "Ultralight");
break;
default:
PrintAndLogEx(NORMAL, _RED_("unknown"));
Expand Down Expand Up @@ -7816,7 +7816,7 @@ static int CmdHF14AGen4Info(const char *cmd) {
uint8_t resp[40] = {0};
size_t resplen = 0;
int res = 0;

if (dlen != 32) {
res = mfG4GetConfig(pwd, resp, &resplen, verbose);
if (res != PM3_SUCCESS || resplen == 0) {
Expand Down
16 changes: 8 additions & 8 deletions client/src/cmdlfhitag.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,15 @@ void annotateHitag2(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize,
if (cmdsize == 1) {
bn = bits;
} else if (cmdsize > 1) {
bn = ((cmdsize - 1) * 8) + bits;
bn = ((cmdsize - 1) * 8) + bits;
}
}

// 11000 AUTH only one with 5 bits. cmdsize 1
switch(bn) {
switch (bn) {
case 5: {
_ht2state.state = STATE_HALT;
if(memcmp(binstr, HITAG2_START_AUTH, 5) == 0) {
if (memcmp(binstr, HITAG2_START_AUTH, 5) == 0) {
snprintf(exp, size, "START AUTH");
_ht2state.state = STATE_START_AUTH;
} else {
Expand All @@ -430,22 +430,22 @@ void annotateHitag2(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize,
break;
}

if(memcmp(binstr, HITAG2_HALT, 2) == 0) {
if (memcmp(binstr, HITAG2_HALT, 2) == 0) {
snprintf(exp, size, "HALT");
_ht2state.state = STATE_HALT;
break;
}
if(memcmp(binstr, HITAG2_READ_PAGE, 2) == 0) {
if (memcmp(binstr, HITAG2_READ_PAGE, 2) == 0) {
snprintf(exp, size, "READ_PAGE (%u)", 0);
break;
}

if(memcmp(binstr, HITAG2_READ_PAGE_INVERTED, 2) == 0) {
if (memcmp(binstr, HITAG2_READ_PAGE_INVERTED, 2) == 0) {
snprintf(exp, size, "READ_PAGE_INVERTED (%u)", 0);
break;
}

if(memcmp(binstr, HITAG2_WRITE_PAGE, 2) == 0) {
if (memcmp(binstr, HITAG2_WRITE_PAGE, 2) == 0) {
snprintf(exp, size, "WRITE_PAGE ()");
break;
}
Expand All @@ -465,7 +465,7 @@ void annotateHitag2(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize,

if (_ht2state.state == STATE_AUTH) {
snprintf(exp, size, "DATA");
} else{
} else {
snprintf(exp, size, "?");
}
break;
Expand Down
6 changes: 3 additions & 3 deletions client/src/cmdtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,9 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
uint8_t nbits = parityBytes[0];
if (j == 0) {

// only apply this to lesser than one byte
// only apply this to lesser than one byte
if (data_len == 1) {

if (nbits == 5) {
snprintf(line[0], 120, "%2u: %02X ", nbits, frame[0] >> (8 - nbits));
} else {
Expand All @@ -667,7 +667,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
} else {
snprintf(line[j / 18] + ((j % 18) * 4) + offset, 120, "%02X ", frame[j]);
}

} else {
snprintf(line[j / 18] + ((j % 18) * 4), 120, "%02X ", frame[j]);
}
Expand Down
8 changes: 4 additions & 4 deletions client/src/comms.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ static void PacketResponseReceived(PacketResponseNG *packet) {
case CMD_DEBUG_PRINT_INTEGERS: {
if (packet->ng == false) {
PrintAndLogEx(NORMAL, "[" _MAGENTA_("pm3") "] ["_BLUE_("#")"] " "%" PRIx64 ", %" PRIx64 ", %" PRIx64 ""
, packet->oldarg[0]
, packet->oldarg[1]
, packet->oldarg[2]
);
, packet->oldarg[0]
, packet->oldarg[1]
, packet->oldarg[2]
);
}
break;
}
Expand Down
6 changes: 3 additions & 3 deletions client/src/mifare/aiddesfire.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ static int open_aiddf_file(json_t **root, bool verbose) {

if (verbose) {
PrintAndLogEx(SUCCESS, "Loaded file `" _YELLOW_("%s") "` " _GREEN_("%zu") " records ( " _GREEN_("ok") " )"
, path
, json_array_size(*root)
);
, path
, json_array_size(*root)
);
}

out:
Expand Down
2 changes: 1 addition & 1 deletion client/src/pm3line.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static bool WINAPI terminate_handler(DWORD t) {
static struct sigaction gs_old_sigint_action;
static void sigint_handler(int signum) {

switch(signum) {
switch (signum) {
case SIGINT: {
sigaction(SIGINT, &gs_old_sigint_action, NULL);
pm3line_flush_history();
Expand Down
Loading

0 comments on commit 4e54005

Please sign in to comment.