From 140a7f34a443053e31156a36403e5beaa7f438c5 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 23 Jan 2022 20:02:57 +0100 Subject: [PATCH] make style --- armsrc/iso14443a.c | 2 +- client/src/cmdhflist.c | 10 +++---- client/src/cmdtrace.c | 6 ++--- client/src/nfc/ndef.c | 4 +-- client/src/pm3line.c | 10 +++---- client/src/pm3line.h | 2 +- client/src/proxguiqt.cpp | 2 +- common/generator.c | 10 +++---- doc/commands.json | 57 +++++++++++++++++++++------------------- 9 files changed, 53 insertions(+), 50 deletions(-) diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index 6611254f7..bb0f56693 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -1128,7 +1128,7 @@ bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, tag_r } // if uid not supplied then get from emulator memory - if ( (memcmp(data, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 10) == 0) || ((flags & FLAG_UID_IN_EMUL) == FLAG_UID_IN_EMUL)) { + if ((memcmp(data, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 10) == 0) || ((flags & FLAG_UID_IN_EMUL) == FLAG_UID_IN_EMUL)) { if (tagType == 2 || tagType == 7) { uint16_t start = MFU_DUMP_PREFIX_LENGTH; uint8_t emdata[8]; diff --git a/client/src/cmdhflist.c b/client/src/cmdhflist.c index 721b0949d..cba90b6fb 100644 --- a/client/src/cmdhflist.c +++ b/client/src/cmdhflist.c @@ -271,7 +271,7 @@ int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool i gs_ntag_i2c_state = 1; } else { snprintf(exp, size, "RESTORE(%d)", cmd[1]); - } + } } else { return PM3_ESOFT; } @@ -832,7 +832,7 @@ void annotateIso7816(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { void annotateMfDesfire(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { // it's basically a ISO14443a tag, so try annotation from there - if (applyIso14443a(exp, size, cmd, cmdsize, false) != PM3_SUCCESS ) { + if (applyIso14443a(exp, size, cmd, cmdsize, false) != PM3_SUCCESS) { // S-block 11xxx010 if ((cmd[0] & 0xC0) && (cmdsize == 3)) { @@ -1182,14 +1182,14 @@ void annotateSeos(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { if (applyIso14443a(exp, size, cmd, cmdsize, false) != PM3_SUCCESS) { // switch (cmd[0]) { -// default: +// default: // break; // }; - // apply ISO7816 annotations? + // apply ISO7816 annotations? // if (annotateIso7816(exp, size, cmd, cmdsize) == 0) { // } - // apply SEOS annotations? + // apply SEOS annotations? } } diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c index 2e6a04ad9..d44552bfa 100644 --- a/client/src/cmdtrace.c +++ b/client/src/cmdtrace.c @@ -420,7 +420,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr annotateCryptoRF(explanation, sizeof(explanation), frame, data_len); break; case SEOS: - annotateSeos(explanation, sizeof(explanation), frame, data_len); + annotateSeos(explanation, sizeof(explanation), frame, data_len); break; default: break; @@ -724,7 +724,7 @@ int CmdTraceList(const char *Cmd) { "trace list -t mf -> interpret as " _YELLOW_("MIFARE Classic") " and decrypt crypto1 stream\n" "trace list -t seos -> interpret as " _YELLOW_("SEOS") "\n" "trace list -t thinfilm -> interpret as " _YELLOW_("Thinfilm") "\n" - "trace list -t topaz -> interpret as " _YELLOW_("Topaz") "\n" + "trace list -t topaz -> interpret as " _YELLOW_("Topaz") "\n" "\n" "trace list -t mf --dict -> use dictionary keys file\n" "trace list -t 14a -f -> show frame delay times\n" @@ -773,7 +773,7 @@ int CmdTraceList(const char *Cmd) { uint8_t protocol = -1; // validate type of output - if (strcmp(type, "14a") == 0) protocol = ISO_14443A; + if (strcmp(type, "14a") == 0) protocol = ISO_14443A; else if (strcmp(type, "14b") == 0) protocol = ISO_14443B; else if (strcmp(type, "15") == 0) protocol = ISO_15693; else if (strcmp(type, "7816") == 0) protocol = ISO_7816_4; diff --git a/client/src/nfc/ndef.c b/client/src/nfc/ndef.c index 5d80963a5..014e6b688 100644 --- a/client/src/nfc/ndef.c +++ b/client/src/nfc/ndef.c @@ -529,14 +529,14 @@ static int ndefDecodeMime_vcard(NDEFHeader_t *ndef) { PrintAndLogEx(INFO, ""); PrintAndLogEx(INFO, "%.*s", (int)ndef->PayloadLen, ndef->Payload); - char *s = strstr((char*)ndef->Payload, "PHOTO"); + char *s = strstr((char *)ndef->Payload, "PHOTO"); if (s) { s = strtok(s, ";"); while (s) { char *tmp = s; if (strncmp(tmp, "ENCODING", 8) == 0) { } else if (strncmp(tmp, "TYPE", 4) == 0) { - + char *part = strtok(tmp + 4, ":"); while (part) { diff --git a/client/src/pm3line.c b/client/src/pm3line.c index 6d33e9990..f070d3813 100644 --- a/client/src/pm3line.c +++ b/client/src/pm3line.c @@ -32,7 +32,7 @@ #if defined(HAVE_READLINE) -static char* rl_command_generator(const char *text, int state) { +static char *rl_command_generator(const char *text, int state) { static int index; static size_t len; size_t rlen = strlen(rl_line_buffer); @@ -48,14 +48,14 @@ static char* rl_command_generator(const char *text, int state) { // When no pm3 device present // and the command is not available offline, // we skip it. - if ((g_session.pm3_present == false) && (vocabulory[index].offline == false )) { + if ((g_session.pm3_present == false) && (vocabulory[index].offline == false)) { index++; continue; } index++; - if (strncmp (command, rl_line_buffer, rlen) == 0) { + if (strncmp(command, rl_line_buffer, rlen) == 0) { const char *next = command + (rlen - len); const char *space = strstr(next, " "); if (space != NULL) { @@ -70,7 +70,7 @@ static char* rl_command_generator(const char *text, int state) { static char **rl_command_completion(const char *text, int start, int end) { rl_attempted_completion_over = 0; - return rl_completion_matches (text, rl_command_generator); + return rl_completion_matches(text, rl_command_generator); } #endif // HAVE_READLINE @@ -94,7 +94,7 @@ static void sigint_handler(int signum) { } #endif -void pm3line_install_signals(void){ +void pm3line_install_signals(void) { # if defined(_WIN32) // SetConsoleCtrlHandler((PHANDLER_ROUTINE)terminate_handler, true); # else diff --git a/client/src/pm3line.h b/client/src/pm3line.h index 50fd57afe..a22f8540f 100644 --- a/client/src/pm3line.h +++ b/client/src/pm3line.h @@ -21,7 +21,7 @@ void pm3line_init(void); void pm3line_install_signals(void); -char *pm3line_read(const char* s); +char *pm3line_read(const char *s); void pm3line_free(void *ref); void pm3line_update_prompt(const char *prompt); int pm3line_load_history(const char *path); diff --git a/client/src/proxguiqt.cpp b/client/src/proxguiqt.cpp index 0639fd042..be62e1838 100644 --- a/client/src/proxguiqt.cpp +++ b/client/src/proxguiqt.cpp @@ -177,7 +177,7 @@ void ProxGuiQT::_ShowBase64PictureWindow(char *b64) { if (slen == 0) return; - char *myb64data = (char *)calloc(slen + 1, sizeof(uint8_t)); + char *myb64data = (char *)calloc(slen + 1, sizeof(uint8_t)); if (myb64data == NULL) return; diff --git a/common/generator.c b/common/generator.c index be58bc7bc..08ca05a75 100644 --- a/common/generator.c +++ b/common/generator.c @@ -165,10 +165,10 @@ uint32_t ul_ev1_pwdgenE(const uint8_t *uid) { uint8_t hash[20]; mbedtls_sha1(uid, 7, hash); uint32_t pwd = 0; - pwd |= ( hash[ hash[0] % 20 ] ) << 24 ; - pwd |= ( hash[ (hash[0] + 5 ) % 20 ] ) << 16; - pwd |= ( hash[ (hash[0] + 13) % 20 ] ) << 8; - pwd |= ( hash[ (hash[0] + 17) % 20 ] ); + pwd |= (hash[ hash[0] % 20 ]) << 24 ; + pwd |= (hash[(hash[0] + 5) % 20 ]) << 16; + pwd |= (hash[(hash[0] + 13) % 20 ]) << 8; + pwd |= (hash[(hash[0] + 17) % 20 ]); return pwd; } @@ -205,7 +205,7 @@ uint16_t ul_ev1_packgenD(const uint8_t *uid) { uint16_t ul_ev1_packgenE(const uint8_t *uid) { uint32_t pwd = ul_ev1_pwdgenE(uid); - return (0xAD << 8 | ((pwd >> 24) & 0xFF) ); + return (0xAD << 8 | ((pwd >> 24) & 0xFF)); } diff --git a/doc/commands.json b/doc/commands.json index ad96cf2ea..dac618bd0 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -4339,9 +4339,9 @@ "0..3: number of keys stored within the application (max. 14 keys)", "4: ks3 is present", "5: use of 2 byte iso fid, 0: no, 1: yes", - "6..7: crypto method 00: des/2tdea, 01: 3tdea, 10: aes, 11: rfu", + "6..7: crypto method 00: des|2tdea, 01: 3tdea, 10: aes, 11: rfu", "example:", - "2e = with fid, des/2tdea, 14 keys", + "2e = with fid, des|2tdea, 14 keys", "6e = with fid, 3tdea, 14 keys", "ae = with fid, aes, 14 keys", "", @@ -4354,25 +4354,25 @@ "-h, --help this help", "-a, --apdu show apdu requests and responses", "-v, --verbose show technical data", - "-n, --keyno key number", - "-t, --algo crypt algo: des, 2tdea, 3tdea, aes", - "-k, --key key for authenticate (hex 8(des), 16(2tdea or aes) or 24(3tdea) bytes)", - "-f, --kdf key derivation function (kdf): none, an10922, gallagher", + "-n, --keyno key number", + "-t, --algo crypt algo: des, 2tdea, 3tdea, aes", + "-k, --key key for authenticate (hex 8(des), 16(2tdea or aes) or 24(3tdea) bytes)", + "-f, --kdf key derivation function (kdf): none, an10922, gallagher", "-i, --kdfi kdf input (hex 1-31 bytes)", - "-m, --cmode communicaton mode: plain/mac/encrypt", - "-c, --ccset communicaton command set: native/niso/iso", - "-s, --schann secure channel: d40/ev1/ev2/lrp", - "--rawdata rawdata that sends to command", - "--aid application id for create. mandatory. (3 hex bytes, big endian)", - "--fid iso file id. forbidden values: 0000 3f00, 3fff, ffff. (2 hex bytes, big endian). if specified - enable iso file id over all the files in the app.", - "--dfname iso df name 1..16 chars string", - "--ks1 key settings 1 (hex 1 byte). application master key settings. default 0x0f", - "--ks2 key settings 2 (hex 1 byte). default 0x0e", - "--dstalgo application key crypt algo: des, 2tdea, 3tdea, aes. default des", - "--numkeys keys count. 0x00..0x0e. default 0x0e", + "-m, --cmode communicaton mode: plain/mac/encrypt", + "-c, --ccset communicaton command set: native/niso/iso", + "-s, --schann secure channel: d40/ev1/ev2/lrp", + "--rawdata raw data that sends to command", + "--aid application id for create. mandatory. (3 hex bytes, big endian)", + "--fid iso file id. forbidden values: 0000 3f00, 3fff, ffff. (2 hex bytes, big endian). if specified - enable iso file id over all the files in the app.", + "--dfname iso df name 1..16 chars string", + "--ks1 key settings 1 (hex 1 byte). application master key settings. default 0x0f", + "--ks2 key settings 2 (hex 1 byte). default 0x0e", + "--dstalgo application key crypt algo: des, 2tdea, 3tdea, aes. default des", + "--numkeys number of keys 0x00..0x0e. default 0x0e", "--no-auth execute without authentication" ], - "usage": "hf mfdes createapp [-hav] [-n ] [-t ] [-k ] [-f ] [-i ] [-m ] [-c ] [-s ] [--rawdata ] [--aid ] [--fid ] [--dfname ] [--ks1 ] [--ks2 ] [--dstalgo ] [--numkeys ] [--no-auth]" + "usage": "hf mfdes createapp [-hav] [-n ] [-t ] [-k ] [-f ] [-i ] [-m ] [-c ] [-s ] [--rawdata ] [--aid ] [--fid ] [--dfname ] [--ks1 ] [--ks2 ] [--dstalgo ] [--numkeys ] [--no-auth]" }, "hf mfdes createfile": { "command": "hf mfdes createfile", @@ -9983,22 +9983,25 @@ "description": "help this help list list protocol data in trace buffer load load trace from file save save trace buffer to file --------------------------------------------------------------------------------------- trace list available offline: yes annotate trace buffer with selected protocol data you can load a trace from file (see `trace load -h`) or it be downloaded from device by default", "notes": [ "trace list -t raw -> just show raw data without annotations", + "", "trace list -t 14a -> interpret as iso14443-a", - "trace list -t thinfilm -> interpret as thinfilm", - "trace list -t topaz -> interpret as topaz", - "trace list -t mf -> interpret as mifare classic and decrypt crypto1 stream", - "trace list -t des -> interpret as mifare desfire", "trace list -t 14b -> interpret as iso14443-b", - "trace list -t 7816 -> interpret as iso7816-4", "trace list -t 15 -> interpret as iso15693", - "trace list -t iclass -> interpret as iclass", - "trace list -t legic -> interpret as legic", + "trace list -t 7816 -> interpret as iso7816-4", + "trace list -t cryptorf -> interpret as cryptorf", + "", + "trace list -t des -> interpret as mifare desfire", "trace list -t felica -> interpret as iso18092 / felica", "trace list -t hitag1 -> interpret as hitag1", "trace list -t hitag2 -> interpret as hitag2", "trace list -t hitags -> interpret as hitags", + "trace list -t iclass -> interpret as iclass", + "trace list -t legic -> interpret as legic", "trace list -t lto -> interpret as lto-cm", - "trace list -t cryptorf -> interpret as cryptorf", + "trace list -t mf -> interpret as mifare classic and decrypt crypto1 stream", + "trace list -t seos -> interpret as seos", + "trace list -t thinfilm -> interpret as thinfilm", + "trace list -t topaz -> interpret as topaz", "", "trace list -t mf --dict -> use dictionary keys file", "trace list -t 14a -f -> show frame delay times", @@ -10205,6 +10208,6 @@ "metadata": { "commands_extracted": 598, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2022-01-17T10:37:00" + "extracted_on": "2022-01-23T19:02:27" } } \ No newline at end of file