make style

This commit is contained in:
Philippe Teuwen 2020-11-07 01:32:43 +01:00
commit f63cf02178
12 changed files with 109 additions and 109 deletions

View file

@ -406,7 +406,7 @@ int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_h
}
uint8_t *buf = NULL;
if (strip_leading) {
buf = (DemodBuffer + offset);
@ -427,7 +427,7 @@ int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_h
if (len > 512) {
len = 512;
}
if (invert) {
buf = (DemodBuffer + offset);
for (size_t i = 0; i < len; i++) {
@ -439,11 +439,11 @@ int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_h
}
}
}
if (print_hex) {
buf = (DemodBuffer + offset);
char hex[512] = {0x00};
int num_bits = binarraytohex(hex, sizeof(hex), (char*)buf, len);
int num_bits = binarraytohex(hex, sizeof(hex), (char *)buf, len);
if (num_bits == 0) {
return PM3_ESOFT;
}

View file

@ -1839,7 +1839,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
}
if (card.ats_len >= 3) { // a valid ATS consists of at least the length byte (TL) and 2 CRC bytes
PrintAndLogEx(INFO, "-------------------------- " _CYAN_("ATS") " --------------------------");
bool ta1 = 0, tb1 = 0, tc1 = 0;
@ -1851,7 +1851,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
PrintAndLogEx(WARNING, "ATS may be corrupted. Length of ATS (%d bytes incl. 2 Bytes CRC) doesn't match TL", card.ats_len);
}
PrintAndLogEx(SUCCESS, "ATS: " _YELLOW_("%s")"[ %02x %02x ]", sprint_hex(card.ats, card.ats_len - 2), card.ats[card.ats_len - 1], card.ats[card.ats_len] );
PrintAndLogEx(SUCCESS, "ATS: " _YELLOW_("%s")"[ %02x %02x ]", sprint_hex(card.ats, card.ats_len - 2), card.ats[card.ats_len - 1], card.ats[card.ats_len]);
PrintAndLogEx(INFO, " " _YELLOW_("%02x") "............... TL length is " _GREEN_("%d") " bytes", card.ats[0], card.ats[0]);
if (card.ats[0] > 1) { // there is a format byte (T0)
@ -1913,7 +1913,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
card.ats[pos],
(card.ats[pos] & 0x01) ? "" : _RED_(" NOT"),
(card.ats[pos] & 0x02) ? "" : _RED_(" NOT")
);
);
pos++;
}
@ -1923,13 +1923,13 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
tip[0] = '\0';
if (card.ats[0] - pos >= 7) {
snprintf(tip, sizeof(tip)," ");
snprintf(tip, sizeof(tip), " ");
if ((card.sak & 0x70) == 0x40) { // and no GetVersion()..
if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x01\xBC\xD6", 7) == 0) {
snprintf(tip + strlen(tip), sizeof(tip) - strlen(tip), _GREEN_("%s"), "MIFARE Plus X 2K/4K (SL3)");
} else if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x00\x35\xC7", 7) == 0) {
if ((card.atqa[0] & 0x02) == 0x02)
@ -1939,7 +1939,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
} else if (memcmp(card.ats + pos, "\xC1\x05\x21\x30\x00\xF6\xD1", 7) == 0) {
snprintf(tip + strlen(tip), sizeof(tip) - strlen(tip), _GREEN_("%s"), "MIFARE Plus SE 1K (17pF)");
} else if (memcmp(card.ats + pos, "\xC1\x05\x21\x30\x10\xF6\xD1", 7) == 0) {
snprintf(tip + strlen(tip), sizeof(tip) - strlen(tip), _GREEN_("%s"), "MIFARE Plus SE 1K (70pF)");
}
@ -1973,7 +1973,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
PrintAndLogEx(INFO, "-------------------- " _CYAN_("Historical bytes") " --------------------");
if (card.ats[pos] == 0xC1) {
PrintAndLogEx(INFO, " %s%s", sprint_hex(card.ats + pos, calen), tip);
PrintAndLogEx(INFO, " %s%s", sprint_hex(card.ats + pos, calen), tip);
PrintAndLogEx(SUCCESS, " C1..................... Mifare or (multiple) virtual cards of various type");
PrintAndLogEx(SUCCESS, " %02x.................. length is " _YELLOW_("%d") " bytes", card.ats[pos + 1], card.ats[pos + 1]);
switch (card.ats[pos + 2] & 0xf0) {

View file

@ -878,16 +878,16 @@ static int CmdHFiClassELoad(const char *Cmd) {
}
DumpFileType_t dftype = BIN;
bool use_json = arg_get_lit(ctx, 2);
bool use_eml = arg_get_lit(ctx, 3);
CLIParserFree(ctx);
if (use_json && use_eml) {
PrintAndLogEx(ERR, "Error: can't specify both JSON & EML");
return PM3_EINVARG;
}
if (use_json) {
dftype = JSON;
} else if (use_eml) {
@ -2325,7 +2325,7 @@ static int CmdHFiClass_loclass(const char *Cmd) {
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
bool test = arg_get_lit(ctx, 2);
bool longtest = arg_get_lit(ctx, 3);
bool longtest = arg_get_lit(ctx, 3);
CLIParserFree(ctx);

View file

@ -349,7 +349,7 @@ typedef struct {
static int CmdHelp(const char *Cmd);
static const char *getEncryptionAlgoStr(uint8_t algo) {
switch(algo) {
switch (algo) {
case MFDES_ALGO_AES :
return "AES";
case MFDES_ALGO_3DES :
@ -1133,7 +1133,7 @@ static int mifare_desfire_change_key(uint8_t key_no, uint8_t *new_key, uint8_t n
return PM3_EINVARG;
}
// AID == 000000 6bits LSB needs to be 0
// AID == 000000 6bits LSB needs to be 0
key_no &= 0x0F;
/*
@ -1141,10 +1141,10 @@ static int mifare_desfire_change_key(uint8_t key_no, uint8_t *new_key, uint8_t n
* changing the card master key to one of them require a key_no tweak.
*/
if (0x000000 == tag->selected_application) {
// PICC master key, 6bits LSB needs to be 0
key_no = 0x00;
// PICC master key, keyalgo specific 2bit MSB
switch (new_algo) {
case MFDES_ALGO_DES:
@ -3938,11 +3938,11 @@ static int CmdHF14ADesChangeKey(const char *Cmd) {
PrintAndLogEx(WARNING, "New key must include %d HEX symbols", keylength);
return PM3_EINVARG;
}
PrintAndLogEx(INFO, "changing key number 0x%02x", cmdKeyNo);
PrintAndLogEx(INFO, "old key: %s (%s)", sprint_hex_inrow(key, keylen), getEncryptionAlgoStr(cmdAuthAlgo));
PrintAndLogEx(INFO, "new key: %s (%s)", sprint_hex_inrow(newkey, newkeylen), getEncryptionAlgoStr(newcmdAuthAlgo));
int error = mifare_desfire_change_key(cmdKeyNo, newkey, newcmdAuthAlgo, key, cmdAuthAlgo, aesversion);
if (error == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, " Successfully changed key.");
@ -4660,7 +4660,7 @@ static int CmdHF14aDesNDEF(const char *Cmd) {
bool keyB = arg_get_lit(ctx, 4);
CLIParserFree(ctx);
uint16_t ndefAID = 0xe103;
if (aidlen == 2)
ndefAID = (aid[0] << 8) + aid[1];
@ -4752,7 +4752,7 @@ static int CmdHF14aDesMAD(const char *Cmd) {
CLIParserFree(ctx);
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfdes mad -v`") " for more details");
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfdes mad -v`") " for more details");
return PM3_SUCCESS;
}
*/

View file

@ -137,7 +137,7 @@ int demodHID(bool verbose) {
}
wiegand_message_t packed = initialize_message_object(hi2, hi, lo);
if ( HIDTryUnpack(&packed, false) == false) {
if (HIDTryUnpack(&packed, false) == false) {
PrintAndLogEx(INFO, "raw: " _GREEN_("%08x%08x%08x"), hi2, hi, lo);
printDemodBuff(0, false, false, true);
}
@ -145,7 +145,7 @@ int demodHID(bool verbose) {
PrintAndLogEx(DEBUG, "DEBUG: HID idx: %d, Len: %zu, Printing Demod Buffer: ", idx, size);
if (g_debugMode) {
PrintAndLogEx(DEBUG, "raw: " _GREEN_("%08x%08x%08x"), hi2, hi, lo);
printDemodBuff(0, false, false, false);
}

View file

@ -527,11 +527,11 @@ void SAPDUPrint(sAPDU apdu, size_t maxdatalen) {
apdu.Lc,
apdu.Lc
);
size_t len = apdu.Lc;
if (maxdatalen > 0)
len = MIN(apdu.Lc, maxdatalen);
PrintAndLogEx(INFO, "data { %s%s }", sprint_hex(apdu.data, len), apdu.Lc > len ? "..." : "");
}

View file

@ -515,7 +515,7 @@ static bool Pack_H10304(wiegand_card_t *card, wiegand_message_t *packed) {
set_linear_field(packed, card->FacilityCode, 1, 16);
set_linear_field(packed, card->CardNumber, 17, 19);
set_bit_by_position(packed, evenparity32(get_linear_field(packed, 1, 18)), 0);
set_bit_by_position(packed, oddparity32(get_linear_field(packed, 18, 18)), 36);
return add_HID_header(packed);
@ -545,30 +545,30 @@ static bool Pack_HGeneric37(wiegand_card_t *card, wiegand_message_t *packed) {
packed->Length = 37; // Set number of bits
set_linear_field(packed, card->CardNumber, 4, 32);
set_bit_by_position(packed, 1, 36); // Always 1
// even1
set_bit_by_position(packed,
evenparity32(
get_nonlinear_field(packed, 8, (uint8_t[]) {4, 8, 12, 16, 20, 24, 28, 32})
)
, 0
);
evenparity32(
get_nonlinear_field(packed, 8, (uint8_t[]) {4, 8, 12, 16, 20, 24, 28, 32})
)
, 0
);
// odd1
set_bit_by_position(packed,
oddparity32(
get_nonlinear_field(packed, 8, (uint8_t[]) {6, 10, 14, 18, 22, 26, 30, 34})
)
, 2
);
oddparity32(
get_nonlinear_field(packed, 8, (uint8_t[]) {6, 10, 14, 18, 22, 26, 30, 34})
)
, 2
);
// even2
set_bit_by_position(packed,
evenparity32(
get_nonlinear_field(packed, 8, (uint8_t[]) {7, 11, 15, 19, 23, 27, 31, 35})
)
, 3
);
set_bit_by_position(packed,
evenparity32(
get_nonlinear_field(packed, 8, (uint8_t[]) {7, 11, 15, 19, 23, 27, 31, 35})
)
, 3
);
return add_HID_header(packed);
}
@ -580,10 +580,10 @@ static bool Unpack_HGeneric37(wiegand_message_t *packed, wiegand_card_t *card) {
card->CardNumber = get_linear_field(packed, 4, 32);
card->ParityValid =
(get_bit_by_position(packed, 0) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {4, 8, 12, 16, 20, 24, 28, 32}))) &&
(get_bit_by_position(packed, 2) == oddparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {6, 10, 14, 18, 22, 28, 30, 34}))) &&
(get_bit_by_position(packed, 3) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {7, 11, 15, 19, 23, 27, 31, 35})))
;
(get_bit_by_position(packed, 0) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {4, 8, 12, 16, 20, 24, 28, 32}))) &&
(get_bit_by_position(packed, 2) == oddparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {6, 10, 14, 18, 22, 28, 30, 34}))) &&
(get_bit_by_position(packed, 3) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {7, 11, 15, 19, 23, 27, 31, 35})))
;
return true;
}
@ -599,7 +599,7 @@ static bool Pack_MDI37(wiegand_card_t *card, wiegand_message_t *packed) {
set_linear_field(packed, card->FacilityCode, 3, 4);
set_linear_field(packed, card->CardNumber, 7, 29);
set_bit_by_position(packed, evenparity32(get_linear_field(packed, 1, 18)), 0);
set_bit_by_position(packed, oddparity32(get_linear_field(packed, 18, 18)), 36);
return add_HID_header(packed);
@ -612,7 +612,7 @@ static bool Unpack_MDI37(wiegand_message_t *packed, wiegand_card_t *card) {
card->FacilityCode = get_linear_field(packed, 3, 4);;
card->CardNumber = get_linear_field(packed, 7, 29);
card->ParityValid =
(get_bit_by_position(packed, 0) == evenparity32(get_linear_field(packed, 1, 18))) &&
(get_bit_by_position(packed, 36) == oddparity32(get_linear_field(packed, 18, 18)))
@ -830,7 +830,7 @@ static const cardformat_t FormatTable[] = {
{"H10320", Pack_H10320, Unpack_H10320, "HID H10320 36-bit BCD", {1, 0, 0, 0, 1}}, // from Proxmark forums
{"H10302", Pack_H10302, Unpack_H10302, "HID H10302 37-bit huge ID", {1, 0, 0, 0, 1}}, // from Proxmark forums
{"H10304", Pack_H10304, Unpack_H10304, "HID H10304 37-bit", {1, 1, 0, 0, 1}}, // from cardinfo.barkweb.com.au
{"HGeneric37", Pack_HGeneric37, Unpack_HGeneric37, "HID Generic 37-bit", {1, 0, 0, 0, 1}}, // from cardinfo.barkweb.com.au
{"HGeneric37", Pack_HGeneric37, Unpack_HGeneric37, "HID Generic 37-bit", {1, 0, 0, 0, 1}}, // from cardinfo.barkweb.com.au
{"MDI37", Pack_MDI37, Unpack_MDI37, "PointGuard MDI 37-bit", {1, 1, 0, 0, 1}}, // from cardinfo.barkweb.com.au
{"P10001", Pack_P10001, Unpack_P10001, "HID P10001 Honeywell 40-bit", {1, 1, 0, 1, 0}}, // from cardinfo.barkweb.com.au
{"Casi40", Pack_CasiRusco40, Unpack_CasiRusco40, "Casi-Rusco 40-bit", {1, 0, 0, 0, 0}}, // from cardinfo.barkweb.com.au