From eb3c48cd259c27cf2df20f8afb30703eb2f549cd Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 30 Dec 2021 12:41:23 +0100 Subject: [PATCH] make style --- armsrc/hitagS.c | 20 ++++++++++---------- client/src/cmdlfhitag.c | 2 +- client/src/cmdtrace.c | 4 ++-- common/crc.c | 4 ++-- doc/commands.json | 14 ++++++++------ 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/armsrc/hitagS.c b/armsrc/hitagS.c index 6837b8abd..79cfe89ad 100644 --- a/armsrc/hitagS.c +++ b/armsrc/hitagS.c @@ -1288,24 +1288,24 @@ void ReadHitagS(hitag_function htf, hitag_data *htd, bool ledcontrol) { bStop = !false; } - unsigned char response_bytes[ARRAYLEN(response_bit)/8] = {0}; + unsigned char response_bytes[ARRAYLEN(response_bit) / 8] = {0}; k = 0; // Check if frame was captured and store it if (rxlen > 0) { for (i = 0; i < rxlen; i++) { - response_bit[i] = (rx[i/8] >> (7 - (i % 8))) & 1; + response_bit[i] = (rx[i / 8] >> (7 - (i % 8))) & 1; } if (tag.pstate == HT_INIT) { // Tag Response is AC encoded for (i = 5; i < rxlen; i += 2) { - response_bytes[k/8] |= response_bit[i] << (7 - (k % 8)); + response_bytes[k / 8] |= response_bit[i] << (7 - (k % 8)); k++; - if (k >= 8*ARRAYLEN(response_bytes)) + if (k >= 8 * ARRAYLEN(response_bytes)) break; } } else { for (i = 4; i < rxlen; i++) { // ignore first 4 bits: SOF (actually 1 or 6 depending on response protocol) - response_bytes[k/8] |= response_bit[i] << (7 - (k % 8)); + response_bytes[k / 8] |= response_bit[i] << (7 - (k % 8)); k++; } } @@ -1531,22 +1531,22 @@ void WritePageHitagS(hitag_function htf, hitag_data *htd, int page, bool ledcont // Check if frame was captured and store it if (rxlen > 0) { for (i = 0; i < rxlen; i++) { - response_bit[i] = (rx[i/8] >> (7 - (i % 8))) & 1; + response_bit[i] = (rx[i / 8] >> (7 - (i % 8))) & 1; } - unsigned char response_bytes[ARRAYLEN(response_bit)/8] = {0}; + unsigned char response_bytes[ARRAYLEN(response_bit) / 8] = {0}; if (tag.pstate == HT_INIT) { // Tag Response is AC encoded k = 0; for (i = 5; i < rxlen; i += 2) { - response_bytes[k/8] |= response_bit[i] << (7 - (k % 8)); + response_bytes[k / 8] |= response_bit[i] << (7 - (k % 8)); k++; - if (k >= 8*ARRAYLEN(response_bytes)) + if (k >= 8 * ARRAYLEN(response_bytes)) break; } } else { k = 0; for (i = 4; i < rxlen; i++) { // ignore first 4 bits: SOF (actually 1 or 6 depending on response protocol) - response_bytes[k/8] |= response_bit[i] << (7 - (k % 8)); + response_bytes[k / 8] |= response_bit[i] << (7 - (k % 8)); k++; } } diff --git a/client/src/cmdlfhitag.c b/client/src/cmdlfhitag.c index f648f42f4..92402fc36 100644 --- a/client/src/cmdlfhitag.c +++ b/client/src/cmdlfhitag.c @@ -972,7 +972,7 @@ int readHitagUid(void) { return (CmdLFHitagReader("--26") == PM3_SUCCESS); } -uint8_t hitag1_CRC_check(uint8_t *d, uint32_t nbit){ +uint8_t hitag1_CRC_check(uint8_t *d, uint32_t nbit) { if (nbit < 9) return 2; return (CRC8Hitag1Bits(d, nbit) == 0); } diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c index 15dff55bf..7b04250d7 100644 --- a/client/src/cmdtrace.c +++ b/client/src/cmdtrace.c @@ -272,10 +272,10 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr snprintf(line[j / 18] + ((j % 18) * 4), 120, "%02x! ", frame[j]); } - } else if (((protocol == PROTO_HITAG1) || (protocol == PROTO_HITAG2) || (protocol == PROTO_HITAGS)) && (parityBytes[0] > 0)){ + } else if (((protocol == PROTO_HITAG1) || (protocol == PROTO_HITAG2) || (protocol == PROTO_HITAGS)) && (parityBytes[0] > 0)) { // handle partial bytes uint8_t nbits = parityBytes[0]; - if (j==0) { + if (j == 0) { partialbytebuff = frame[0] << nbits; snprintf(line[0], 120, "%02x(%i) ", frame[0] >> (8 - nbits), nbits); offset = 2; diff --git a/common/crc.c b/common/crc.c index 033c244d2..cb077182f 100644 --- a/common/crc.c +++ b/common/crc.c @@ -156,7 +156,7 @@ uint32_t CRC8Hitag1Bits(uint8_t *buff, size_t bitsize) { uint8_t i; for (i = 0; i < bitsize; i++) { data <<= 1; - data += (buff[i/8] >> (7 - (i % 8))) & 1; + data += (buff[i / 8] >> (7 - (i % 8))) & 1; n += 1; if (n == 8) { crc_update2(&crc, data, n); @@ -168,4 +168,4 @@ uint32_t CRC8Hitag1Bits(uint8_t *buff, size_t bitsize) { crc_update2(&crc, data, n); } return crc_finish(&crc); -} \ No newline at end of file +} diff --git a/doc/commands.json b/doc/commands.json index 31acc8aeb..a1aba40c8 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -3859,7 +3859,7 @@ "description": "read mifare classic block", "notes": [ "hf mf rdbl --blk 0 -k ffffffffffff", - "hf mf rdbl -b 3 -v -> get block 3, decode sector trailer" + "hf mf rdbl --blk 3 -v -> get block 3, decode sector trailer" ], "offline": false, "options": [ @@ -5520,9 +5520,10 @@ "-h, --help this help", "-k, --key key for authentication (ul-c 16 bytes, ev1/ntag 4 bytes)", "-l swap entered key's endianness", - "-b, --block block number to read" + "-b, --block block number to read", + "--force force operation even if address is out of range" ], - "usage": "hf mfu rdbl [-hl] [-k ] -b " + "usage": "hf mfu rdbl [-hl] [-k ] -b [--force]" }, "hf mfu restore": { "command": "hf mfu restore", @@ -5602,9 +5603,10 @@ "-k, --key key for authentication (ul-c 16 bytes, ev1/ntag 4 bytes)", "-l swap entered key's endianness", "-b, --block block number to write", - "-d, --data block data (4 or 16 hex bytes, 16 hex bytes will do a compatibility write)" + "-d, --data block data (4 or 16 hex bytes, 16 hex bytes will do a compatibility write)", + "--force force operation even if address is out of range" ], - "usage": "hf mfu wrbl [-hl] [-k ] -b -d " + "usage": "hf mfu wrbl [-hl] [-k ] -b -d [--force]" }, "hf plot": { "command": "hf plot", @@ -10151,6 +10153,6 @@ "metadata": { "commands_extracted": 597, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2021-12-29T15:28:13" + "extracted_on": "2021-12-30T11:40:54" } } \ No newline at end of file