From 1afb335478ad34275fe9a6d566d5d9e70b68d240 Mon Sep 17 00:00:00 2001 From: tcprst Date: Sun, 22 Nov 2020 19:39:54 -0500 Subject: [PATCH] make style --- armsrc/iclass.c | 2 +- client/src/cmdhf14a.c | 24 ++++++------ client/src/cmdhficlass.c | 6 +-- client/src/cmdhfmfdes.c | 74 ++++++++++++++++++------------------ client/src/cmdlfem4x05.c | 2 +- client/src/cmdlft55xx.c | 18 ++++----- client/src/cmdmain.c | 6 +-- client/src/crypto/asn1dump.c | 4 +- client/src/emv/emv_tags.c | 26 ++++++------- client/src/fido/fidocore.c | 2 +- client/src/util.c | 14 +++---- 11 files changed, 89 insertions(+), 89 deletions(-) diff --git a/armsrc/iclass.c b/armsrc/iclass.c index 803972e05..86d8094b7 100644 --- a/armsrc/iclass.c +++ b/armsrc/iclass.c @@ -1853,7 +1853,7 @@ void iClass_WriteBlock(uint8_t *msg) { // new block data memcpy(write + 2, payload->data, 8); - + uint8_t pagemap = get_pagemap(&hdr); if (pagemap == PICOPASS_NON_SECURE_PAGEMODE) { // Unsecured tags uses CRC16, but don't include the UPDATE operation code diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 852aae3b8..c8d0a57eb 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -1178,11 +1178,11 @@ static int CmdHF14AAPDU(const char *Cmd) { } CLIParserFree(ctx); - PrintAndLogEx(SUCCESS, "( " _YELLOW_("%s%s%s")" )", - activateField ? "select" : "", - leaveSignalON ? ", keep" : "", - decodeTLV ? ", TLV" : "" - ); + PrintAndLogEx(SUCCESS, "( " _YELLOW_("%s%s%s")" )", + activateField ? "select" : "", + leaveSignalON ? ", keep" : "", + decodeTLV ? ", TLV" : "" + ); PrintAndLogEx(SUCCESS, ">>> %s", sprint_hex_inrow(data, datalen)); if (decodeAPDU) { @@ -1217,7 +1217,7 @@ static int CmdHF14ACmdRaw(const char *Cmd) { "Sends an raw bytes over ISO14443a. With option to use TOPAZ 14a mode.", "hf 14a raw -sc 3000 -> select, crc, where 3000 == 'read block 00'\n" "hf 14a raw -ak -b 7 40 -> send 7 bit byte 0x40\n" - ); + ); void *argtable[] = { arg_param_begin, @@ -1344,13 +1344,13 @@ static int waitCmd(bool i_select, uint32_t timeout) { if (i_select == false && len >= 3) { bool crc = check_crc(CRC_14443_A, data, len); - + char s[16]; - sprintf(s, - (crc) ? _GREEN_("%02X %02X") : _RED_("%02X %02X"), - data[len - 2], - data[len - 1] - ); + sprintf(s, + (crc) ? _GREEN_("%02X %02X") : _RED_("%02X %02X"), + data[len - 2], + data[len - 1] + ); PrintAndLogEx(SUCCESS, "%s[ %s ]", sprint_hex(data, len - 2), s); } else { diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index c72db32b4..2c90278a7 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -1003,7 +1003,7 @@ static int CmdHFiClassEView(const char *Cmd) { void *argtable[] = { arg_param_begin, arg_int0("s", "size", "<256|2048>", "number of bytes to save (default 256)"), - arg_lit0("v", "verbose" , "filename of dumpfile"), + arg_lit0("v", "verbose", "filename of dumpfile"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); @@ -3546,8 +3546,8 @@ int info_iclass(void) { uint8_t cardtype = get_mem_config(hdr); PrintAndLogEx(SUCCESS, " Card type.... " _GREEN_("%s"), card_types[cardtype]); - - + + } DropField(); diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index a69aa0d27..f2282dbfd 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -1182,7 +1182,7 @@ static int mifare_desfire_change_key(uint8_t key_no, uint8_t *new_key, uint8_t n key 8b cpy 8b crc 2b - padding + padding */ // Variable length ciphered key data 24-42 bytes plus padding.. @@ -1190,11 +1190,11 @@ static int mifare_desfire_change_key(uint8_t key_no, uint8_t *new_key, uint8_t n sAPDU apdu = {0x90, MFDES_CHANGE_KEY, 0x00, 0x00, 0x01, data}; // 0xC4 size_t cmdcnt = 0; - + uint8_t new_key_length = 16; switch (new_algo) { case MFDES_ALGO_DES: - // double + // double memcpy(data + cmdcnt + 1, new_key, new_key_length); memcpy(data + cmdcnt + 1 + new_key_length, new_key, new_key_length); break; @@ -1438,11 +1438,11 @@ static int desfire_print_amk_keysetting(uint8_t key_settings, uint8_t num_keys, PrintAndLogEx(SUCCESS, " -- All keys (except AMK,see Bit0) within this application are frozen"); break; default: - PrintAndLogEx(SUCCESS, - " -- Authentication with the specified key is necessary to change any key.\n" - "A change key and a PICC master key (CMK) can only be changed after authentication with the master key.\n" - "For keys other then the master or change key, an authentication with the same key is needed." - ); + PrintAndLogEx(SUCCESS, + " -- Authentication with the specified key is necessary to change any key.\n" + "A change key and a PICC master key (CMK) can only be changed after authentication with the master key.\n" + "For keys other then the master or change key, an authentication with the same key is needed." + ); break; } @@ -1487,15 +1487,15 @@ static int desfire_print_piccmk_keysetting(uint8_t key_settings, uint8_t num_key if (res == PM3_SUCCESS) PrintAndLogEx(SUCCESS, " [0xAA] Authenticate AES : %s", (res == PM3_SUCCESS) ? _YELLOW_("YES") : "NO"); - PrintAndLogEx(INFO, "-------------------------------------------------------------"); - PrintAndLogEx(INFO, " Key setting: 0x%02X [%c%c%c%c]", - key_settings, - (key_settings & (1 << 3)) ? '1' : '0', - (key_settings & (1 << 2)) ? '1' : '0', - (key_settings & (1 << 1)) ? '1' : '0', - (key_settings & (1 << 0)) ? '1' : '0' - ); - + PrintAndLogEx(INFO, "-------------------------------------------------------------"); + PrintAndLogEx(INFO, " Key setting: 0x%02X [%c%c%c%c]", + key_settings, + (key_settings & (1 << 3)) ? '1' : '0', + (key_settings & (1 << 2)) ? '1' : '0', + (key_settings & (1 << 1)) ? '1' : '0', + (key_settings & (1 << 0)) ? '1' : '0' + ); + PrintAndLogEx(SUCCESS, " [1...] CMK Configuration changeable : %s", (key_settings & (1 << 3)) ? _GREEN_("YES") : "NO (frozen)"); PrintAndLogEx(SUCCESS, " [.1..] CMK required for create/delete : %s", (key_settings & (1 << 2)) ? _GREEN_("NO") : "YES"); PrintAndLogEx(SUCCESS, " [..1.] Directory list access with CMK : %s", (key_settings & (1 << 1)) ? _GREEN_("NO") : "YES"); @@ -1645,14 +1645,14 @@ static int handler_desfire_select_application(uint8_t *aid) { sAPDU apdu = {0x90, MFDES_SELECT_APPLICATION, 0x00, 0x00, 0x03, aid}; //0x5a uint32_t recv_len = 0; uint16_t sw = 0; - + int res = send_desfire_cmd(&apdu, !tag->rf_field_on, NULL, &recv_len, &sw, sizeof(dfname_t), true); if (res != PM3_SUCCESS) { PrintAndLogEx(WARNING, - _RED_(" Can't select AID 0x%X -> %s"), - (aid[2] << 16) + (aid[1] << 8) + aid[0], - GetErrorString(res, &sw) - ); + _RED_(" Can't select AID 0x%X -> %s"), + (aid[2] << 16) + (aid[1] << 8) + aid[0], + GetErrorString(res, &sw) + ); DropFieldDesfire(); return res; } @@ -1732,17 +1732,17 @@ static int handler_desfire_createapp(aidhdr_t *aidhdr, bool usename, bool usefid apdu.Lc = apdu.Lc - sizeof(aidhdr->fid); } uint8_t *data = NULL; - + // skip over FID if not used. if (usefid == false && usename) { data = calloc(apdu.Lc, sizeof(uint8_t)); apdu.data = data; - + memcpy(data, aidhdr->aid, sizeof(aidhdr->aid)); data[3] = aidhdr->keysetting1; data[4] = aidhdr->keysetting2; memcpy(data + 5, aidhdr->name, sizeof(aidhdr->name)); - + PrintAndLogEx(INFO, "new data: %s", sprint_hex_inrow(data, apdu.Lc)); } @@ -2070,7 +2070,7 @@ static int getKeySettings(uint8_t *aid) { uint8_t key_setting = 0; int res = 0; if (memcmp(aid, "\x00\x00\x00", 3) == 0) { - + // CARD MASTER KEY //PrintAndLogEx(INFO, "--- " _CYAN_("CMK - PICC, Card Master Key settings")); @@ -2418,7 +2418,7 @@ static int CmdHF14ADesCreateApp(const char *Cmd) { if (usefid) memcpy(aidhdr.fid, fid, sizeof(aidhdr.fid)); - if (usename) + if (usename) memcpy(aidhdr.name, name, sizeof(aidhdr.name)); PrintAndLogEx(INFO, "Creating AID using:"); @@ -2430,14 +2430,14 @@ static int CmdHF14ADesCreateApp(const char *Cmd) { if (usename) PrintAndLogEx(INFO, "DF Name %s", aidhdr.name); -/* - uint8_t rootaid[3] = {0x00, 0x00, 0x00}; - int res = handler_desfire_select_application(rootaid); - if (res != PM3_SUCCESS) { - DropFieldDesfire(); - return res; - } -*/ + /* + uint8_t rootaid[3] = {0x00, 0x00, 0x00}; + int res = handler_desfire_select_application(rootaid); + if (res != PM3_SUCCESS) { + DropFieldDesfire(); + return res; + } + */ int res = handler_desfire_createapp(&aidhdr, usename, usefid); DropFieldDesfire(); @@ -3462,7 +3462,7 @@ static int CmdHF14ADesInfo(const char *Cmd) { PrintAndLogEx(NORMAL, ""); PrintAndLogEx(INFO, "--- " _CYAN_("Hardware Information")); PrintAndLogEx(INFO, " raw: %s", sprint_hex_inrow(info.versionHW, sizeof(info.versionHW))); - + PrintAndLogEx(INFO, " Vendor Id: " _YELLOW_("%s"), getTagInfo(info.versionHW[0])); PrintAndLogEx(INFO, " Type: " _YELLOW_("0x%02X"), info.versionHW[1]); PrintAndLogEx(INFO, " Subtype: " _YELLOW_("0x%02X"), info.versionHW[2]); @@ -3698,7 +3698,7 @@ static int CmdHF14ADesDump(const char *Cmd) { }; CLIExecWithReturn(ctx, Cmd, argtable, true); CLIParserFree(ctx); - + (void)Cmd; // Cmd is not used so far DropFieldDesfire(); diff --git a/client/src/cmdlfem4x05.c b/client/src/cmdlfem4x05.c index 9abc2862c..3b260ed2e 100644 --- a/client/src/cmdlfem4x05.c +++ b/client/src/cmdlfem4x05.c @@ -1882,7 +1882,7 @@ uint32_t static em4x05_Sniff_GetBlock(char *bits, bool fwd) { if (parity != (bits[35] - '0')) parityerror = true; - if (parityerror) + if (parityerror) PrintAndLogEx(ERR, "parity error : "); if (!fwd) { diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c index a3ccf2052..80c8eda4f 100644 --- a/client/src/cmdlft55xx.c +++ b/client/src/cmdlft55xx.c @@ -1027,7 +1027,7 @@ static void T55xx_Print_DownlinkMode(uint8_t downlink_mode) { } // Define prototype to call from within detect. -static int CmdT55xxWakeUp (const char *Cmd); +static int CmdT55xxWakeUp(const char *Cmd); static int CmdT55xxDetect(const char *Cmd) { @@ -1054,7 +1054,7 @@ static int CmdT55xxDetect(const char *Cmd) { return usage_t55xx_detect(); case 'p': password = param_get32ex(Cmd, cmdp + 1, 0, 16); - sprintf (wakecmd,"p %08x q",(uint32_t)(password & 0xFFFFFFFF)); + sprintf(wakecmd, "p %08x q", (uint32_t)(password & 0xFFFFFFFF)); usepwd = true; cmdp += 2; break; @@ -1077,7 +1077,7 @@ static int CmdT55xxDetect(const char *Cmd) { } if (errors) return usage_t55xx_detect(); - + // detect called so clear data blocks T55x7_ClearAllBlockData(); @@ -1096,11 +1096,11 @@ static int CmdT55xxDetect(const char *Cmd) { if (usewake) { // call wake if (try_with_pwd) - CmdT55xxWakeUp (wakecmd); + CmdT55xxWakeUp(wakecmd); else - CmdT55xxWakeUp ("q"); + CmdT55xxWakeUp("q"); // sleep 90 ms - nanosleep (&sleepperiod, &sleepperiod); + nanosleep(&sleepperiod, &sleepperiod); } if (AcquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, (try_with_pwd && usepwd), password, m) == false) @@ -1117,11 +1117,11 @@ static int CmdT55xxDetect(const char *Cmd) { if (usewake) { // call wake if (try_with_pwd) - CmdT55xxWakeUp (wakecmd); + CmdT55xxWakeUp(wakecmd); else - CmdT55xxWakeUp ("q"); + CmdT55xxWakeUp("q"); // sleep 90 ms - nanosleep (&sleepperiod, &sleepperiod); + nanosleep(&sleepperiod, &sleepperiod); } if (AcquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password, downlink_mode)) { diff --git a/client/src/cmdmain.c b/client/src/cmdmain.c index 551f5ccf6..c55c7792e 100644 --- a/client/src/cmdmain.c +++ b/client/src/cmdmain.c @@ -120,7 +120,7 @@ static int lf_search_plus(const char *Cmd) { return retval; } -static int CmdAuto(const char *Cmd) { +static int CmdAuto(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "auto", "Run LF SEARCH / HF SEARCH / DATA PLOT / DATA SAVE", @@ -136,7 +136,7 @@ static int CmdAuto(const char *Cmd) { PrintAndLogEx(INFO, "lf search"); int ret = CmdLFfind(""); - if (ret == PM3_SUCCESS) + if (ret == PM3_SUCCESS) return ret; PrintAndLogEx(INFO, "hf search"); @@ -193,7 +193,7 @@ static int CmdHints(const char *Cmd) { PrintAndLogEx(ERR, "you can't turn off and on at the same time"); return PM3_EINVARG; } - + if (turn_off) { session.show_hints = false; } else if (turn_on) { diff --git a/client/src/crypto/asn1dump.c b/client/src/crypto/asn1dump.c index f1addb9e2..cae25c1b6 100644 --- a/client/src/crypto/asn1dump.c +++ b/client/src/crypto/asn1dump.c @@ -116,7 +116,7 @@ static void asn1_tag_dump_str_time(const struct tlv *tlv, const struct asn1_tag if (longyear == false) PrintAndLogEx(NORMAL, "20" NOLF); - PrintAndLogEx(NORMAL, "%s-" NOLF, sprint_hex(tlv->value, startindx) ); + PrintAndLogEx(NORMAL, "%s-" NOLF, sprint_hex(tlv->value, startindx)); if (len < startindx + 2) break; @@ -276,7 +276,7 @@ static void asn1_tag_dump_object_id(const struct tlv *tlv, const struct asn1_tag asn1_buf.p = (uint8_t *)tlv->value; char pstr[300]; mbedtls_oid_get_numeric_string(pstr, sizeof(pstr), &asn1_buf); - + PrintAndLogEx(INFO, "%*s %s" NOLF, (level * 4), " ", pstr); char *jsondesc = asn1_oid_description(pstr, true); diff --git a/client/src/emv/emv_tags.c b/client/src/emv/emv_tags.c index 661df0e5e..f86b88826 100644 --- a/client/src/emv/emv_tags.c +++ b/client/src/emv/emv_tags.c @@ -462,9 +462,9 @@ static void emv_tag_dump_bitmask(const struct tlv *tlv, const struct emv_tag *ta if (val & 0x80) { PrintAndLogEx(INFO, "%*s" NOLF, (level * 4), " "); PrintAndLogEx(NORMAL, " %s - '%s'", - bitstrings[bit - 1], - (bits->bit == EMV_BIT(byte, bit)) ? bits->name : "Unknown" - ); + bitstrings[bit - 1], + (bits->bit == EMV_BIT(byte, bit)) ? bits->name : "Unknown" + ); } if (bits->bit == EMV_BIT(byte, bit)) bits ++; @@ -535,10 +535,10 @@ static void emv_tag_dump_numeric(const struct tlv *tlv, const struct emv_tag *ta static void emv_tag_dump_yymmdd(const struct tlv *tlv, const struct emv_tag *tag, int level) { PrintAndLogEx(INFO, "%*s" NOLF, (level * 4), " "); PrintAndLogEx(NORMAL, " Date: 20%02lu.%lu.%lu", - emv_value_numeric(tlv, 0, 2), - emv_value_numeric(tlv, 2, 4), - emv_value_numeric(tlv, 4, 6) - ); + emv_value_numeric(tlv, 0, 2), + emv_value_numeric(tlv, 2, 4), + emv_value_numeric(tlv, 4, 6) + ); } static uint32_t emv_get_binary(const unsigned char *S) { @@ -749,12 +749,12 @@ static void emv_tag_dump_cvm_list(const struct tlv *tlv, const struct emv_tag *t PrintAndLogEx(INFO, "%*s" NOLF, (level * 4), " "); PrintAndLogEx(NORMAL, " %02x %02x: '%s' '%s' and '%s' if this CVM is unsuccessful", - tlv->value[i], - tlv->value[i + 1], - method, - condition, - (tlv->value[i] & 0x40) ? "continue" : "fail" - ); + tlv->value[i], + tlv->value[i + 1], + method, + condition, + (tlv->value[i] & 0x40) ? "continue" : "fail" + ); } } diff --git a/client/src/fido/fidocore.c b/client/src/fido/fidocore.c index abe3f28ce..fcebb2674 100644 --- a/client/src/fido/fidocore.c +++ b/client/src/fido/fidocore.c @@ -541,7 +541,7 @@ int FIDO2MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, b res = CborGetArrayBinStringValue(&mapsmt, der, sizeof(der), &derLen); cbor_check(res); if (verbose2) { - PrintAndLogEx(INFO, "DER certificate[%zu]:", derLen); + PrintAndLogEx(INFO, "DER certificate[%zu]:", derLen); PrintAndLogEx(INFO, "------------------DER-------------------"); PrintAndLogEx(INFO, "%s", sprint_hex(der, derLen)); PrintAndLogEx(INFO, "----------------DER---------------------"); diff --git a/client/src/util.c b/client/src/util.c index 2e1cfb0bd..76a2d7885 100644 --- a/client/src/util.c +++ b/client/src/util.c @@ -212,23 +212,23 @@ void print_buffer(const uint8_t *data, const size_t len, int level) { // (16 * 3) + (16) + + 1 memset(buf, 0, sizeof(buf)); sprintf(buf, "%*s%02x: ", (level * 4), " ", i); - - hex_to_buffer((uint8_t *)(buf + strlen(buf)), data + i, 16, (sizeof(buf) - strlen(buf) - 1), 0, 1, true); + + hex_to_buffer((uint8_t *)(buf + strlen(buf)), data + i, 16, (sizeof(buf) - strlen(buf) - 1), 0, 1, true); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "| %s", sprint_ascii(data + i, 16)); PrintAndLogEx(INFO, "%s", buf); } - + // the last odd bytes uint8_t mod = len % 16; - + if (mod) { memset(buf, 0, sizeof(buf)); sprintf(buf, "%*s%02x: ", (level * 4), " ", i); hex_to_buffer((uint8_t *)(buf + strlen(buf)), data + i, mod, (sizeof(buf) - strlen(buf) - 1), 0, 1, true); - + // add the spaces... - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%*s", ((16 - mod) * 3) , " "); - + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%*s", ((16 - mod) * 3), " "); + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "| %s", sprint_ascii(data + i, mod)); PrintAndLogEx(INFO, "%s", buf); }