Skip to content

Commit

Permalink
make style
Browse files Browse the repository at this point in the history
  • Loading branch information
doegox committed Oct 16, 2021
1 parent 2328434 commit dbec6ed
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 131 deletions.
2 changes: 1 addition & 1 deletion client/src/atrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const char *getAtrInfo(const char *atr_str) {
}

for (int j = 0; j < slen; j++) {
tmp_atr[j] = AtrTable[i].bytes[j]=='.' ? '.' : atr_str[j];
tmp_atr[j] = AtrTable[i].bytes[j] == '.' ? '.' : atr_str[j];
}

if (strncmp(tmp_atr, AtrTable[i].bytes, slen) == 0) {
Expand Down
12 changes: 6 additions & 6 deletions client/src/cmdanalyse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ static int CmdAnalyseFreq(const char *Cmd) {
PrintAndLogEx(INFO, " 13.56 mHz has %f m, rf range %f m", len_1356, rf_range_1356);


if (F == 0 && C == 0 && L == 0)
if (F == 0 && C == 0 && L == 0)
return PM3_SUCCESS;


Expand All @@ -1021,22 +1021,22 @@ static int CmdAnalyseFreq(const char *Cmd) {

// From https://goodcalculators.com/resonant-frequency-calculator/
// Calc Resonant Frequency [Hz]
// f = 1 / (2π √L C)
// f = 1 / (2π √L C)
if (F == 0) {
double calc_freq = 1 / (2 * M_PI * sqrtf((L * C)) );
double calc_freq = 1 / (2 * M_PI * sqrtf((L * C)));
PrintAndLogEx(INFO, "Resonating Frequency %lf Hz", calc_freq);
}
// Calc Inductance [H]
// L = 1 / (4π2 f2 C)
// L = 1 / (4π2 f2 C)
if (L == 0) {
double calc_inductance = 1 / (4 * (M_PI * M_PI) * (F * F) * C );
double calc_inductance = 1 / (4 * (M_PI * M_PI) * (F * F) * C);
PrintAndLogEx(INFO, "Inductance %lf Henries", calc_inductance);
}

// Capacitance [F]
// C = 1 / (4π2 f2 L)
if (C == 0) {
double calc_capacitance = 1 / (4 * (M_PI * M_PI) * (F * F) * L);
double calc_capacitance = 1 / (4 * (M_PI * M_PI) * (F * F) * L);
PrintAndLogEx(INFO, "Capacitance %lf Farads", calc_capacitance);
}
return PM3_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion client/src/cmdcrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ static int CmdrevengSearch(const char *Cmd) {
memset(result, 0, 30);
char *inCRC = calloc(crcChars + 1, sizeof(char));
if (inCRC == NULL) {
return 0;
return 0;
}

memcpy(inCRC, inHexStr + (dataLen - crcChars), crcChars);
Expand Down
32 changes: 16 additions & 16 deletions client/src/cmdhficlass.c
Original file line number Diff line number Diff line change
Expand Up @@ -2479,9 +2479,9 @@ void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t e
PrintAndLogEx(INFO, " block# | data | ascii |lck| info");
PrintAndLogEx(INFO, "---------+-------------------------+----------+---+--------------");
PrintAndLogEx(INFO, " 0/0x00 | " _GREEN_("%s") "| " _GREEN_("%s") " | | CSN "
, sprint_hex(iclass_dump, 8)
, sprint_ascii(iclass_dump, 8)
);
, sprint_hex(iclass_dump, 8)
, sprint_ascii(iclass_dump, 8)
);

if (i != 1)
PrintAndLogEx(INFO, "....");
Expand Down Expand Up @@ -2535,12 +2535,12 @@ void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t e
}

PrintAndLogEx(INFO, "%3d/0x%02X | %s | %s | %s "
, i
, i
, sprint_hex_ascii(blk, 8)
, lockstr
, s
);
, i
, i
, sprint_hex_ascii(blk, 8)
, lockstr
, s
);

} else {
const char *info_ks[] = {"CSN", "Config", "E-purse", "Debit", "Credit", "AIA", "User"};
Expand All @@ -2550,13 +2550,13 @@ void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t e
}
if (i >= 6 && i <= 9) {
PrintAndLogEx(INFO, "%3d/0x%02X | " _YELLOW_("%s") "| " _YELLOW_("%s") " | %s | %s "
, i
, i
, sprint_hex(blk, 8)
, sprint_ascii(blk, 8)
, lockstr
, s
);
, i
, i
, sprint_hex(blk, 8)
, sprint_ascii(blk, 8)
, lockstr
, s
);
} else {
PrintAndLogEx(INFO, "%3d/0x%02X | %s | %s | %s ", i, i, sprint_hex_ascii(blk, 8), lockstr, s);
}
Expand Down
18 changes: 9 additions & 9 deletions client/src/cmdhflist.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool i
snprintf(exp, size, "AUTH-1 ");
break;
case MIFARE_ULC_AUTH_2:
if ((gs_mfuc_state == 2) && (cmdsize==19)){
if ((gs_mfuc_state == 2) && (cmdsize == 19)) {
memcpy(gs_mfuc_authdata[1], &cmd[1], 16);
if (trace_mfuc_try_default_3des_keys(&gs_mfuc_key, gs_mfuc_state, gs_mfuc_authdata) == PM3_SUCCESS) {
// buffer too small to print the full key,
Expand Down Expand Up @@ -371,26 +371,26 @@ int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool i
return 0;
}
} else {
if (gs_mfuc_state==1) {
if ((cmd[0]==0xAF) && (cmdsize==11)) {
if (gs_mfuc_state == 1) {
if ((cmd[0] == 0xAF) && (cmdsize == 11)) {
// register RndB
memcpy(gs_mfuc_authdata[0], &cmd[1], 8);
gs_mfuc_state=2;
gs_mfuc_state = 2;
} else {
gs_mfuc_state=0;
gs_mfuc_state = 0;
}
}
if (gs_mfuc_state==3) {
if ((cmd[0]==0x00) && (cmdsize==11)) {
if (gs_mfuc_state == 3) {
if ((cmd[0] == 0x00) && (cmdsize == 11)) {
// register RndA'
memcpy(gs_mfuc_authdata[2], &cmd[1], 8);
if (trace_mfuc_try_default_3des_keys(&gs_mfuc_key, gs_mfuc_state, gs_mfuc_authdata) == PM3_SUCCESS) {
snprintf(exp, size, "AUTH-2 ANSW OK");
gs_mfuc_state=0;
gs_mfuc_state = 0;
return 1;
}
}
gs_mfuc_state=0;
gs_mfuc_state = 0;
}
return 0;
}
Expand Down
8 changes: 4 additions & 4 deletions client/src/cmdhfmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
xdump.card_info = card;
xdump.dump = (uint8_t *)carddata;
xdump.dumplen = bytes;
saveFileJSON(dataFilename, jsfCardMemory, (uint8_t*)&xdump, sizeof(xdump), NULL);
saveFileJSON(dataFilename, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL);
return PM3_SUCCESS;
}

Expand Down Expand Up @@ -2603,7 +2603,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
xdump.card_info = card;
xdump.dump = dump;
xdump.dumplen = bytes;
saveFileJSON(filename, jsfCardMemory, (uint8_t*)&xdump, sizeof(xdump), NULL);
saveFileJSON(filename, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL);

// Generate and show statistics
t1 = msclock() - t1;
Expand Down Expand Up @@ -4008,7 +4008,7 @@ static int CmdHF14AMfESave(const char *Cmd) {
}
xdump.dump = dump;
xdump.dumplen = bytes;
saveFileJSON(filename, jsfCardMemory, (uint8_t*)&xdump, sizeof(xdump), NULL);
saveFileJSON(filename, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL);
free(dump);
return PM3_SUCCESS;
}
Expand Down Expand Up @@ -4845,7 +4845,7 @@ static int CmdHF14AMfCSave(const char *Cmd) {
xdump.card_info = card;
xdump.dump = dump;
xdump.dumplen = bytes;
saveFileJSON(filename, jsfCardMemory, (uint8_t*)&xdump, sizeof(xdump), NULL);
saveFileJSON(filename, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL);
free(dump);
return PM3_SUCCESS;
}
Expand Down
8 changes: 4 additions & 4 deletions client/src/cmdhfmfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ static int trace_mfuc_try_key(uint8_t *key, int state, uint8_t (*authdata)[16])
mbedtls_des3_crypt_cbc(&ctx_des3, MBEDTLS_DES_DECRYPT,
16, iv, authdata[1], RndARndB);
if ((memcmp(&RndB[1], &RndARndB[8], 7) == 0) &&
(RndB[0] == RndARndB[15])) {
return PM3_SUCCESS;
(RndB[0] == RndARndB[15])) {
return PM3_SUCCESS;
}
break;
case 3:
Expand All @@ -284,8 +284,8 @@ static int trace_mfuc_try_key(uint8_t *key, int state, uint8_t (*authdata)[16])
mbedtls_des3_crypt_cbc(&ctx_des3, MBEDTLS_DES_DECRYPT,
8, iv, authdata[2], RndA);
if ((memcmp(&RndARndB[1], RndA, 7) == 0) &&
(RndARndB[0] == RndA[7])) {
return PM3_SUCCESS;
(RndARndB[0] == RndA[7])) {
return PM3_SUCCESS;
}
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion client/src/cmdnfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static int CmdNfcDecode(const char *Cmd) {

bool verbose = arg_get_lit(ctx, 3);
CLIParserFree(ctx);
if (((datalen != 0) && (fnlen != 0)) || ((datalen == 0) && (fnlen == 0))){
if (((datalen != 0) && (fnlen != 0)) || ((datalen == 0) && (fnlen == 0))) {
PrintAndLogEx(ERR, "You must provide either data in hex or a filename");
return PM3_EINVARG;
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/fileutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ int saveFileJSONex(const char *preferredName, JSONFileType ftype, uint8_t *data,
break;
}
case jsfCardMemory: {
iso14a_mf_extdump_t* xdump = (iso14a_mf_extdump_t*) data;
iso14a_mf_extdump_t *xdump = (iso14a_mf_extdump_t *) data;
JsonSaveStr(root, "FileType", "mfcard");
JsonSaveBufAsHexCompact(root, "$.Card.UID", xdump->card_info.uid, xdump->card_info.uidlen);
JsonSaveBufAsHexCompact(root, "$.Card.ATQA", xdump->card_info.atqa, 2);
Expand Down
4 changes: 2 additions & 2 deletions client/src/mifare/mifarehost.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,9 +662,9 @@ int mfStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBl
uint32_t max_keys_chunk = keycnt > maxkeysinblock ? maxkeysinblock : keycnt;

uint8_t *mem = NULL;
uint8_t *p_keyblock = NULL;
uint8_t *p_keyblock = NULL;

if (IfPm3Flash()) {
if (IfPm3Flash()) {

// used for mfCheckKeys_file, which needs a header
mem = calloc((maxkeysinblock * 6) + 5, sizeof(uint8_t));
Expand Down
Loading

0 comments on commit dbec6ed

Please sign in to comment.