make style

This commit is contained in:
Philippe Teuwen 2022-01-09 14:10:26 +01:00
commit 5a4584358c
12 changed files with 88 additions and 96 deletions

View file

@ -116,7 +116,7 @@ static void cad_aid_uint_to_byte(uint32_t aid, uint8_t *data) {
* is for the specified region & facility, false otherwise.
*/
static bool cad_facility_match(const uint8_t *entry, uint8_t region_code, uint16_t facility_code) {
return (entry[0] == region_code) &&
return (entry[0] == region_code) &&
((entry[1] << 8) + entry[2] == facility_code);
}
@ -152,9 +152,9 @@ static int authenticate(DesfireContext_t *ctx, bool verbose) {
int res = DesfireAuthenticate(ctx, DACEV1, false);
if (res != PM3_SUCCESS) {
PrintAndLogEx(ERR, "Desfire authenticate " _RED_("error") ". Result: [%d] %s",
res,
DesfireAuthErrorToStr(res)
);
res,
DesfireAuthErrorToStr(res)
);
return res;
}
@ -200,7 +200,7 @@ static bool aid_exists(DesfireContext_t *ctx, uint32_t aid, bool verbose) {
PrintAndLogEx(INFO, "AID %06X %s",
aid,
res == PM3_SUCCESS ? "exists" : "does not exist"
);
);
}
return (res == PM3_SUCCESS);
@ -273,9 +273,9 @@ static int hfgal_read_creds_app(DesfireContext_t *ctx, uint32_t aid, uint8_t *si
// Check file contained 16 bytes of data
if (read_len != 16) {
PM3_RET_ERR(PM3_EFAILED, "Failed reading file 0 in AID %06X, expected 16 bytes, got %zu bytes",
aid,
read_len
);
aid,
read_len
);
}
// Check second half of file is the bitwise inverse of the first half
@ -285,9 +285,9 @@ static int hfgal_read_creds_app(DesfireContext_t *ctx, uint32_t aid, uint8_t *si
if (memcmp(buf, &buf[8], 8) != 0) {
PM3_RET_ERR(PM3_EFAILED, "Invalid cardholder data in file 0 in AID %06X. Received %s",
aid,
sprint_hex_inrow(buf, 16)
);
aid,
sprint_hex_inrow(buf, 16)
);
}
gallagher_decode_creds(buf, creds);
@ -312,7 +312,7 @@ static int hfgal_create_creds_app(DesfireContext_t *ctx, uint8_t *site_key, uint
// UID is required for key diversification
if (ctx->uidlen == 0)
PM3_RET_ERR(PM3_EINVARG, "UID is required for key diversification. "
"Please fetch it before calling `hfgal_create_creds_app`");
"Please fetch it before calling `hfgal_create_creds_app`");
// Create application
DesfireCryptoAlgorithm app_algo = T_AES;
@ -348,7 +348,7 @@ static int hfgal_create_creds_app(DesfireContext_t *ctx, uint8_t *site_key, uint
i,
aid,
sprint_hex_inrow(buf, ARRAYLEN(buf))
);
);
// Authenticate
uint8_t blank_key[CRYPTO_AES128_KEY_SIZE] = {0};
@ -437,7 +437,7 @@ static int hfgal_read_cad(DesfireContext_t *ctx, uint8_t *dest_buf,
PrintAndLogEx(ERR, "hfgal_read_cad destination buffer is incorrectly sized. Received len %d, must be at least %d",
dest_buf_len,
3 * 36
);
);
return PM3_EINVARG;
}
@ -477,9 +477,9 @@ static int hfgal_read_cad(DesfireContext_t *ctx, uint8_t *dest_buf,
PrintAndLogEx(SUCCESS, "Card Application Directory contains:" NOLF);
for (int i = 0; i < num_entries; i++) {
PrintAndLogEx(NORMAL, "%s %06X" NOLF,
(i == 0) ? "" : ",",
cad_aid_byte_to_uint(&dest_buf[i * 6 + 3])
);
(i == 0) ? "" : ",",
cad_aid_byte_to_uint(&dest_buf[i * 6 + 3])
);
}
PrintAndLogEx(NORMAL, "");
}
@ -518,8 +518,8 @@ static int hfgal_create_cad(DesfireContext_t *ctx, uint8_t *site_key, bool verbo
if (verbose) {
PrintAndLogEx(INFO, "Created Card Application Directory (AID " _YELLOW_("%06X") ", empty contents & blank keys)",
CAD_AID
);
CAD_AID
);
}
// Select application & authenticate
@ -537,7 +537,7 @@ static int hfgal_create_cad(DesfireContext_t *ctx, uint8_t *site_key, bool verbo
PrintAndLogEx(INFO, "Diversified key " _YELLOW_("0") " for CAD (AID " _YELLOW_("%06X") "): " _GREEN_("%s"),
CAD_AID,
sprint_hex_inrow(buf, ARRAYLEN(buf))
);
);
// Change key
DesfireSetCommMode(ctx, DCMEncryptedPlain);
@ -587,15 +587,15 @@ static int hfgal_add_aid_to_cad(DesfireContext_t *ctx, uint8_t *site_key, uint32
}
// 6 entries per file
uint8_t file_id = num_entries / 6;
uint8_t file_id = num_entries / 6;
uint8_t entry_num = num_entries % 6;
// Check if facility already exists in CAD.
for (uint8_t i = 0; i < ARRAYLEN(cad); i += 6) {
if (cad_facility_match(&cad[i], creds->region_code, creds->facility_code))
PM3_RET_ERR(PM3_EFATAL, "Facility already exists in CAD, delete or update AID %06X",
cad_aid_byte_to_uint(&cad[i + 3])
);
cad_aid_byte_to_uint(&cad[i + 3])
);
}
// Create entry
@ -610,7 +610,7 @@ static int hfgal_add_aid_to_cad(DesfireContext_t *ctx, uint8_t *site_key, uint32
entry_num,
file_id,
sprint_hex_inrow(entry, 6)
);
);
}
// Select application & authenticate
@ -721,9 +721,9 @@ static int hfgal_remove_aid_from_cad(DesfireContext_t *ctx, uint8_t *site_key,
if (verbose) {
PrintAndLogEx(INFO, "Deleted unnecessary file " _YELLOW_("%d") " from CAD (AID " _YELLOW_("%06X")")",
file_id,
CAD_AID
);
file_id,
CAD_AID
);
}
}
@ -775,7 +775,7 @@ static int hfgal_read_card(uint32_t aid, uint8_t *site_key, bool verbose, bool q
current_aid,
region_code,
facility_code
);
);
} else {
PrintAndLogEx(INFO, "Reading AID: " _YELLOW_("%06X"), current_aid);
}
@ -786,7 +786,7 @@ static int hfgal_read_card(uint32_t aid, uint8_t *site_key, bool verbose, bool q
res = hfgal_read_creds_app(&dctx, current_aid, site_key, &creds, verbose);
PM3_RET_IF_ERR_MAYBE_MSG(res, !quiet, "Failed reading card application credentials");
PrintAndLogEx(SUCCESS, "Gallagher (AID %06X) - region: " _GREEN_("%u")
PrintAndLogEx(SUCCESS, "Gallagher (AID %06X) - region: " _GREEN_("%u")
", fc: " _GREEN_("%u")
", cn: " _GREEN_("%u")
", issue level: " _GREEN_("%u"),
@ -795,7 +795,7 @@ static int hfgal_read_card(uint32_t aid, uint8_t *site_key, bool verbose, bool q
creds.facility_code,
creds.card_number,
creds.issue_level
);
);
}
return PM3_SUCCESS;
}
@ -899,10 +899,10 @@ static int CmdGallagherClone(const char *cmd) {
CLIGetHexWithReturn(ctx, 3, key, &key_len);
if (key_len && key_len != desfire_get_key_length(key_algo)) {
PM3_RET_ERR_FREE(PM3_EINVARG, "%s key must have %d bytes length instead of %d",
CLIGetOptionListStr(DesfireAlgoOpts, key_algo),
desfire_get_key_length(key_algo),
key_len
);
CLIGetOptionListStr(DesfireAlgoOpts, key_algo),
desfire_get_key_length(key_algo),
key_len
);
}
if (key_len == 0) {
// Default to a key of all zeros
@ -927,11 +927,11 @@ static int CmdGallagherClone(const char *cmd) {
// Check that the AID is in the expected range
if ((memcmp(aid_buf, "\xF4\x81", 2) != 0) ||
(aid_buf[2] < 0x20) ||
(aid_buf[2] > 0x2B)) {
// TODO: this should probably be a warning, but key diversification will throw an error later even if we don't
PM3_RET_ERR_FREE(PM3_EINVARG, "Invalid Gallagher AID %06X, expected 2?81F4, where 0 <= ? <= 0xB", aid);
}
(aid_buf[2] < 0x20) ||
(aid_buf[2] > 0x2B)) {
// TODO: this should probably be a warning, but key diversification will throw an error later even if we don't
PM3_RET_ERR_FREE(PM3_EINVARG, "Invalid Gallagher AID %06X, expected 2?81F4, where 0 <= ? <= 0xB", aid);
}
}
int site_key_len = 0;
@ -1026,8 +1026,8 @@ static int CmdGallagherDelete(const char *cmd) {
// Check that the AID is in the expected range
if ((memcmp(aid_buf, "\xF4\x81", 2) != 0) ||
(aid_buf[2] < 0x20) ||
(aid_buf[2] > 0x2B)) {
(aid_buf[2] < 0x20) ||
(aid_buf[2] > 0x2B)) {
// TODO: this should probably be a warning, but key diversification will throw an error later even if we don't
PM3_RET_ERR_FREE(PM3_EINVARG, "Invalid Gallagher AID %06X, expected 2?81F4, where 0 <= ? <= 0xB", aid);
}
@ -1098,9 +1098,9 @@ static int CmdGallagherDiversify(const char *cmd) {
aid = DesfireAIDByteToUint(aid_buf);
// Check that the AID is in the expected range
if ((memcmp(aid_buf, "\xF4\x81", 2) != 0) ||
(aid_buf[2] < 0x20) ||
(aid_buf[2] > 0x2B)) {
if ((memcmp(aid_buf, "\xF4\x81", 2) != 0) ||
(aid_buf[2] < 0x20) ||
(aid_buf[2] > 0x2B)) {
// TODO: this should probably be a warning, but key diversification will throw an error later even if we don't
PM3_RET_ERR_FREE(PM3_EINVARG, "Invalid Gallagher AID %06X, expected 2?81F4, where 0 <= ? <= 0xB", aid);
}
@ -1152,7 +1152,7 @@ static int CmdGallagherDiversify(const char *cmd) {
aid,
key_num,
key_str
);
);
}
return PM3_SUCCESS;
}

View file

@ -367,7 +367,7 @@ static int CmdHF14AMfDarkside(const char *Cmd) {
PrintAndLogEx(SUCCESS, "found valid key: "_GREEN_("%012" PRIx64), key);
break;
}
PrintAndLogEx(SUCCESS, "time in darkside " _YELLOW_("%.0f") " seconds\n",(float)t1 / 1000.0);
PrintAndLogEx(SUCCESS, "time in darkside " _YELLOW_("%.0f") " seconds\n", (float)t1 / 1000.0);
return PM3_SUCCESS;
}

View file

@ -60,7 +60,7 @@
static uint16_t sums[NUM_SUMS] = {0, 32, 56, 64, 80, 96, 104, 112, 120, 128, 136, 144, 152, 160, 176, 192, 200, 224, 256};
// number of possible partial sum property values
#define NUM_PART_SUMS 9
#define NUM_PART_SUMS 9
typedef enum {
EVEN_STATE = 0,

View file

@ -48,7 +48,7 @@ static const uint64_t g_mifare_default_keys[] = {
0x4E3552426B32, // ID06
0x6A1987C40A21, // Salto
0xef1232ab18a0, // Schlage
0x3B7E4FD575AD, //
0x3B7E4FD575AD, //
0xb7bf0c13066e, // Gallagher
0x135b88a94b8b, // Saflock
0x5a7a52d5e20d, // Bosch

View file

@ -1,17 +1,9 @@
//-----------------------------------------------------------------------------
// Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
// Copyright (C) 2021 <iceman>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// See LICENSE.txt for the text of the license.
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
// at your option, any later version. See the LICENSE.txt file for the text of
// the license.
//-----------------------------------------------------------------------------
// readline auto complete utilities
//-----------------------------------------------------------------------------

View file

@ -8,7 +8,7 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

View file

@ -1422,7 +1422,7 @@ int HIDFindCardFormat(const char *format) {
bool HIDPack(int format_idx, wiegand_card_t *card, wiegand_message_t *packed, bool preamble) {
memset(packed, 0, sizeof(wiegand_message_t));
if ((format_idx < 0) || (format_idx >= ARRAYLEN(FormatTable) - 1) )
if ((format_idx < 0) || (format_idx >= ARRAYLEN(FormatTable) - 1))
return false;
return FormatTable[format_idx].Pack(card, packed, preamble);

View file

@ -245,4 +245,4 @@ uint16_t get_sw(const uint8_t *d, uint8_t n) {
n -= 2;
return d[n] * 0x0100 + d[n + 1];
}
}

View file

@ -1311,7 +1311,7 @@ uint8_t detectFSKClk(const uint8_t *bits, size_t size, uint8_t fcHigh, uint8_t f
// look for Sequence Terminator - should be pulses of clk*(1 or 2), clk*2, clk*(1.5 or 2), by idx we mean graph position index...
static bool findST(int *stStopLoc, int *stStartIdx,
static bool findST(int *stStopLoc, int *stStartIdx,
const int lowToLowWaveLen[], const int highToLowWaveLen[],
int clk, int tol, int buffSize, size_t *i) {
if (buffSize < *i + 4) return false;

View file

@ -2322,30 +2322,30 @@
},
"hf gallagher clone": {
"command": "hf gallagher clone",
"description": "clone gallagher credentials to a writable desfire card",
"description": "clone gallagher credentials to a writable desfire card specify site key is required if using non-default key key, lengths for the different crypto: des 8 bytes 2tdea or aes 16 bytes 3tdea 24 bytes aid id, default finds lowest available in range 0x2?81f4, where 0 <= ? <= 0xb.",
"notes": [
"hf gallagher clone --rc 1 --fc 22 --cn 3333 --il 4 --sitekey 00112233445566778899aabbccddeeff"
],
"offline": false,
"options": [
"-h, --help this help",
"-n, --keynum <decimal> key number [default=0]",
"-t, --algo <des/2tdea/3tdea/aes> crypt algo: des, 2tdea, 3tdea, aes",
"-k, --key <hex> key for authentication to the picc (hex 8(des), 16(2tdea or aes) or 24(3tdea) bytes)",
"--rc <decimal> region code. 4 bits max",
"--fc <decimal> facility code. 2 bytes max",
"--cn <decimal> card number. 3 bytes max",
"--il <decimal> issue level. 4 bits max",
"--aid <hex> application id to write (3 bytes) [default finds lowest available in range 0x2?81f4, where 0 <= ? <= 0xb]",
"--sitekey <hex> mifare site key to compute diversified keys (16 bytes, required if using non-default key)",
"-n, --keynum <dec> key number [default = 0]",
"-t, --algo <des|2tdea|3tdea|aes> crypt algo: des, 2tdea, 3tdea, aes",
"-k, --key <hex> key for authentication to the picc",
"--rc <dec> region code. 4 bits max",
"--fc <dec> facility code. 2 bytes max",
"--cn <dec> card number. 3 bytes max",
"--il <dec> issue level. 4 bits max",
"--aid <hex> application id to write (3 bytes)",
"--sitekey <hex> site key to compute diversified keys (16 bytes)",
"--apdu show apdu requests and responses",
"-v, --verbose verbose mode"
],
"usage": "hf gallagher clone [-hv] [-n <decimal>] [-t <des/2tdea/3tdea/aes>] [-k <hex>] --rc <decimal> --fc <decimal> --cn <decimal> --il <decimal> [--aid <hex>] [--sitekey <hex>] [--apdu]"
"usage": "hf gallagher clone [-hv] [-n <dec>] [-t <des|2tdea|3tdea|aes>] [-k <hex>] --rc <dec> --fc <dec> --cn <dec> --il <dec> [--aid <hex>] [--sitekey <hex>] [--apdu]"
},
"hf gallagher delete": {
"command": "hf gallagher delete",
"description": "delete gallagher application from a desfire card",
"description": "delete gallagher application from a desfire card specify site key is required if using non-default key",
"notes": [
"hf gallagher delete --aid 2081f4 --sitekey 00112233445566778899aabbccddeeff"
],
@ -2353,7 +2353,7 @@
"options": [
"-h, --help this help",
"--aid <hex> application id to delete (3 bytes)",
"--sitekey <hex> mifare site key to compute diversified keys (16 bytes, required if using non-default key)",
"--sitekey <hex> site key to compute diversified keys (16 bytes)",
"--apdu show apdu requests and responses",
"-v, --verbose verbose mode"
],
@ -2361,7 +2361,7 @@
},
"hf gallagher diversifykey": {
"command": "hf gallagher diversifykey",
"description": "diversify gallagher key",
"description": "diversify gallagher key specify site key is required if using non-default key",
"notes": [
"hf gallagher diversify --uid 11223344556677 --aid 2081f4"
],
@ -2369,25 +2369,25 @@
"options": [
"-h, --help this help",
"--aid <hex> application id for diversification (3 bytes)",
"--keynum <decimal> key number [default=0]",
"--keynum <dec> key number [default = 0]",
"--uid <hex> card uid to delete (4 or 7 bytes)",
"--sitekey <hex> mifare site key to compute diversified keys (16 bytes, required if using non-default key)",
"--sitekey <hex> site key to compute diversified keys (16 bytes)",
"--apdu show apdu requests and responses"
],
"usage": "hf gallagher diversify [-h] --aid <hex> [--keynum <decimal>] [--uid <hex>] [--sitekey <hex>] [--apdu]"
"usage": "hf gallagher diversify [-h] --aid <hex> [--keynum <dec>] [--uid <hex>] [--sitekey <hex>] [--apdu]"
},
"hf gallagher help": {
"command": "hf gallagher help",
"description": "help this help diversifykey diversify gallagher key --------------------------------------------------------------------------------------- hf gallagher reader available offline: no read a gallagher desfire tag",
"description": "help this help diversifykey diversify gallagher key --------------------------------------------------------------------------------------- hf gallagher reader available offline: no read a gallagher desfire tag from the card application directory, cad specify site key is required if using non-default key",
"notes": [
"hf gallagher reader --aid 2081f4 --sitekey 00112233445566778899aabbccddeeff -> act as a reader that skips reading the card application directory and uses a non-default site key",
"hf gallagher reader -@ -> continuous reader mode"
"hf gallagher reader -@ -> continuous reader mode",
"hf gallagher reader --aid 2081f4 --sitekey 00112233445566778899aabbccddeeff -> skip cad"
],
"offline": true,
"options": [
"-h, --help this help",
"--aid <hex> application id to read (3 bytes). if specified, then the card application directory is not used",
"--sitekey <hex> mifare site key to compute diversified keys (16 bytes, required if using non-default key)",
"--aid <hex> application id to read (3 bytes). if specified, the cad is not used",
"--sitekey <hex> site key to compute diversified keys (16 bytes)",
"-@, --continuous continuous reader mode",
"--apdu show apdu requests and responses",
"-v, --verbose verbose mode"
@ -7194,7 +7194,7 @@
},
"lf gproxii clone": {
"command": "lf gproxii clone",
"description": "clone a guardall tag to a t55x7, q5/t5555 or em4305/4469 tag. the facility-code is 8-bit and the card number is 16-bit. larger values are truncated. currently work only on 26bit",
"description": "clone a guardall tag to a t55x7, q5/t5555 or em4305/4469 tag. the facility-code is 8-bit and the card number is 20-bit. larger values are truncated. currently work only on 26 | 36 bit format",
"notes": [
"lf gproxii clone --fmt 26 --fc 123 --cn 1337",
"lf gproxii clone --q5 --fmt 26 --fc 123 --cn 1337 -> encode for q5/t5555 tag",
@ -7240,7 +7240,7 @@
},
"lf gproxii sim": {
"command": "lf gproxii sim",
"description": "enables simulation of guardall card with specified card number. simulation runs until the button is pressed or another usb command is issued. the facility-code is 8-bit and the card number is 16-bit. larger values are truncated. currently work only on 26bit",
"description": "enables simulation of guardall card with specified card number. simulation runs until the button is pressed or another usb command is issued. the facility-code is 8-bit and the card number is 16-bit. larger values are truncated. currently work only on 26 | 36 bit format",
"notes": [
"lf gproxii sim --fmt 26 --fc 123 --cn 1337"
],
@ -10237,6 +10237,6 @@
"metadata": {
"commands_extracted": 601,
"extracted_by": "PM3Help2JSON v1.00",
"extracted_on": "2022-01-06T19:05:01"
"extracted_on": "2022-01-09T13:10:14"
}
}

View file

@ -94,8 +94,8 @@ static uint64_t expand(uint64_t mask, uint64_t value) {
static void bitslice(const uint64_t value, bitslice_t *restrict bitsliced_value) {
// set constants
bitslice_t bs_zeroes, bs_ones;
memset((uint8_t*)&bs_ones, 0xff, VECTOR_SIZE);
memset((uint8_t*)&bs_zeroes, 0x00, VECTOR_SIZE);
memset((uint8_t *)&bs_ones, 0xff, VECTOR_SIZE);
memset((uint8_t *)&bs_zeroes, 0x00, VECTOR_SIZE);
for (size_t bit_idx = 0; bit_idx < 32; bit_idx++) {
const bool bit = get_bit(32 - 1 - bit_idx, value);

View file

@ -24,7 +24,7 @@ License: GNU General Public License v3 or any later version (see LICENSE.txt)
#include "opencl.h"
bool plat_dev_enabled(unsigned int id, const unsigned int *sel,
bool plat_dev_enabled(unsigned int id, const unsigned int *sel,
unsigned int cnt, unsigned int cur_type, unsigned int allow_type) {
// usefulonly with devices
if (allow_type != CL_DEVICE_TYPE_ALL) {
@ -69,10 +69,10 @@ unsigned int get_smallest_profile(compute_platform_ctx_t *cd_ctx, size_t ocl_pla
}
int discoverDevices(unsigned int profile_selected, uint32_t device_types_selected,
cl_uint *platform_detected_cnt, size_t *selected_platforms_cnt,
size_t *selected_devices_cnt, compute_platform_ctx_t **cd_ctx,
unsigned int *plat_sel, unsigned int plat_cnt, unsigned int *dev_sel,
unsigned int dev_cnt, bool verbose, bool show) {
cl_uint *platform_detected_cnt, size_t *selected_platforms_cnt,
size_t *selected_devices_cnt, compute_platform_ctx_t **cd_ctx,
unsigned int *plat_sel, unsigned int plat_cnt, unsigned int *dev_sel,
unsigned int dev_cnt, bool verbose, bool show) {
int err = 0;
unsigned int ocl_platform_max = MAX_OPENCL_DEVICES; // 16
cl_uint ocl_platform_cnt;