make style

This commit is contained in:
Philippe Teuwen 2021-12-30 12:41:23 +01:00
commit eb3c48cd25
5 changed files with 23 additions and 21 deletions

View file

@ -1288,24 +1288,24 @@ void ReadHitagS(hitag_function htf, hitag_data *htd, bool ledcontrol) {
bStop = !false; bStop = !false;
} }
unsigned char response_bytes[ARRAYLEN(response_bit)/8] = {0}; unsigned char response_bytes[ARRAYLEN(response_bit) / 8] = {0};
k = 0; k = 0;
// Check if frame was captured and store it // Check if frame was captured and store it
if (rxlen > 0) { if (rxlen > 0) {
for (i = 0; i < rxlen; i++) { 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) { if (tag.pstate == HT_INIT) {
// Tag Response is AC encoded // Tag Response is AC encoded
for (i = 5; i < rxlen; i += 2) { 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++; k++;
if (k >= 8*ARRAYLEN(response_bytes)) if (k >= 8 * ARRAYLEN(response_bytes))
break; break;
} }
} else { } else {
for (i = 4; i < rxlen; i++) { // ignore first 4 bits: SOF (actually 1 or 6 depending on response protocol) 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++; 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 // Check if frame was captured and store it
if (rxlen > 0) { if (rxlen > 0) {
for (i = 0; i < rxlen; i++) { 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) { if (tag.pstate == HT_INIT) {
// Tag Response is AC encoded // Tag Response is AC encoded
k = 0; k = 0;
for (i = 5; i < rxlen; i += 2) { 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++; k++;
if (k >= 8*ARRAYLEN(response_bytes)) if (k >= 8 * ARRAYLEN(response_bytes))
break; break;
} }
} else { } else {
k = 0; k = 0;
for (i = 4; i < rxlen; i++) { // ignore first 4 bits: SOF (actually 1 or 6 depending on response protocol) 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++; k++;
} }
} }

View file

@ -972,7 +972,7 @@ int readHitagUid(void) {
return (CmdLFHitagReader("--26") == PM3_SUCCESS); 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; if (nbit < 9) return 2;
return (CRC8Hitag1Bits(d, nbit) == 0); return (CRC8Hitag1Bits(d, nbit) == 0);
} }

View file

@ -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]); 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 // handle partial bytes
uint8_t nbits = parityBytes[0]; uint8_t nbits = parityBytes[0];
if (j==0) { if (j == 0) {
partialbytebuff = frame[0] << nbits; partialbytebuff = frame[0] << nbits;
snprintf(line[0], 120, "%02x(%i) ", frame[0] >> (8 - nbits), nbits); snprintf(line[0], 120, "%02x(%i) ", frame[0] >> (8 - nbits), nbits);
offset = 2; offset = 2;

View file

@ -156,7 +156,7 @@ uint32_t CRC8Hitag1Bits(uint8_t *buff, size_t bitsize) {
uint8_t i; uint8_t i;
for (i = 0; i < bitsize; i++) { for (i = 0; i < bitsize; i++) {
data <<= 1; data <<= 1;
data += (buff[i/8] >> (7 - (i % 8))) & 1; data += (buff[i / 8] >> (7 - (i % 8))) & 1;
n += 1; n += 1;
if (n == 8) { if (n == 8) {
crc_update2(&crc, data, n); crc_update2(&crc, data, n);

View file

@ -3859,7 +3859,7 @@
"description": "read mifare classic block", "description": "read mifare classic block",
"notes": [ "notes": [
"hf mf rdbl --blk 0 -k ffffffffffff", "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, "offline": false,
"options": [ "options": [
@ -5520,9 +5520,10 @@
"-h, --help this help", "-h, --help this help",
"-k, --key <hex> key for authentication (ul-c 16 bytes, ev1/ntag 4 bytes)", "-k, --key <hex> key for authentication (ul-c 16 bytes, ev1/ntag 4 bytes)",
"-l swap entered key's endianness", "-l swap entered key's endianness",
"-b, --block <dec> block number to read" "-b, --block <dec> block number to read",
"--force force operation even if address is out of range"
], ],
"usage": "hf mfu rdbl [-hl] [-k <hex>] -b <dec>" "usage": "hf mfu rdbl [-hl] [-k <hex>] -b <dec> [--force]"
}, },
"hf mfu restore": { "hf mfu restore": {
"command": "hf mfu restore", "command": "hf mfu restore",
@ -5602,9 +5603,10 @@
"-k, --key <hex> key for authentication (ul-c 16 bytes, ev1/ntag 4 bytes)", "-k, --key <hex> key for authentication (ul-c 16 bytes, ev1/ntag 4 bytes)",
"-l swap entered key's endianness", "-l swap entered key's endianness",
"-b, --block <dec> block number to write", "-b, --block <dec> block number to write",
"-d, --data <hex> block data (4 or 16 hex bytes, 16 hex bytes will do a compatibility write)" "-d, --data <hex> 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 <hex>] -b <dec> -d <hex>" "usage": "hf mfu wrbl [-hl] [-k <hex>] -b <dec> -d <hex> [--force]"
}, },
"hf plot": { "hf plot": {
"command": "hf plot", "command": "hf plot",
@ -10151,6 +10153,6 @@
"metadata": { "metadata": {
"commands_extracted": 597, "commands_extracted": 597,
"extracted_by": "PM3Help2JSON v1.00", "extracted_by": "PM3Help2JSON v1.00",
"extracted_on": "2021-12-29T15:28:13" "extracted_on": "2021-12-30T11:40:54"
} }
} }