From c00e4801b73fd9175033e970fd6853262a2f4f80 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 6 Feb 2026 13:23:15 +0100 Subject: [PATCH] make style --- armsrc/appmain.c | 8 +- armsrc/frozen.c | 2 +- armsrc/iso14443a.c | 14 +- armsrc/mifarecmd.c | 2 +- armsrc/seos.c | 68 +- client/deps/id48/public/id48.h | 10 +- client/deps/id48/tests/espresso/array_size2.h | 140 ++- client/deps/id48/tests/espresso/main.c | 4 +- .../id48/tests/espresso/verify_espresso.c | 472 ++++--- .../deps/id48/tests/generator/array_size2.h | 140 ++- client/deps/id48/tests/recovery/array_size2.h | 140 ++- client/deps/id48/tests/recovery/main.c | 110 +- client/deps/reveng/bmpbit.c | 12 +- client/deps/reveng/preset.c | 458 +++---- client/pyscripts/des_talk.py | 2 +- client/pyscripts/mfulaes_mask_recovery.py | 2 +- client/src/cmdflashmemspiffs.c | 2 +- client/src/cmdhf14a.c | 4 +- client/src/cmdhfepa.c | 2 +- client/src/cmdhffelica.c | 38 +- client/src/cmdhfgallagher.c | 18 +- client/src/cmdhficlass.c | 28 +- client/src/cmdhflegic.c | 4 +- client/src/cmdhfmf.c | 4 +- client/src/cmdhfmfu.c | 16 +- client/src/cmdhfntag424.c | 4 +- client/src/cmdhfsaflok.c | 1095 +++++++++-------- client/src/cmdhfseos.c | 28 +- client/src/cmdlft55xx.c | 6 +- client/src/cmdtrace.c | 2 +- client/src/flash.c | 2 +- client/src/pm3_luawrap.c | 6 +- client/src/proxmark3.c | 2 +- common/bruteforce.h | 4 +- common/iso15693tools.h | 24 +- common/mbedtls/aesni.c | 26 +- common/mbedtls/camellia.c | 16 +- common/mbedtls/ctr_drbg.c | 2 +- common/mbedtls/memory_buffer_alloc.c | 16 +- common/mbedtls/ssl.h | 4 +- common/mbedtls/ssl_cli.c | 2 +- common/mbedtls/ssl_msg.c | 2 +- common/mbedtls/x509_crt.c | 2 +- doc/commands.json | 2 +- include/pm3_cmd.h | 2 +- include/seos_cmd.h | 6 +- tools/deprecated-hid-flasher/flasher/flash.c | 2 +- tools/mfulc_des_brute/mfulc_des_brute.c | 14 +- 48 files changed, 1479 insertions(+), 1490 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index dc7a8c8b1..7f91c2b94 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -1786,10 +1786,10 @@ static void PacketReceived(PacketCommandNG *packet) { } PACKED; struct p *payload = (struct p *) packet->data.asBytes; SimulateIso14443aTagEx(payload->tagtype, payload->flags, payload->uid, - payload->exitAfter, payload->rats, sizeof(payload->rats), - payload->ulauth_1a1, payload->ulauth_1a1_len, - payload->ulauth_1a2, payload->ulauth_1a2_len - ); // ## Simulate iso14443a tag - pass tag type & UID + payload->exitAfter, payload->rats, sizeof(payload->rats), + payload->ulauth_1a1, payload->ulauth_1a1_len, + payload->ulauth_1a2, payload->ulauth_1a2_len + ); // ## Simulate iso14443a tag - pass tag type & UID break; } case CMD_HF_ISO14443A_SIM_AID: { diff --git a/armsrc/frozen.c b/armsrc/frozen.c index b4f57aa74..1062e3ff9 100644 --- a/armsrc/frozen.c +++ b/armsrc/frozen.c @@ -541,7 +541,7 @@ static int b64dec(const char *src, int n, char *dst) { int len = 0; while (src + 3 < end) { int a = b64rev(src[0]), b = b64rev(src[1]), c = b64rev(src[2]), - d = b64rev(src[3]); + d = b64rev(src[3]); dst[len++] = (a << 2) | (b >> 4); if (src[2] != '=') { dst[len++] = (b << 4) | (c >> 2); diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index e66c1bf7e..0b761002a 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -1881,13 +1881,13 @@ void SimulateIso14443aTagEx(uint8_t tagType, uint16_t flags, uint8_t *useruid, u emlGet(emdata, start, MIFARE_BLOCK_SIZE); // mask key pages if needed if ((tagType == 13) && (block >= 0x29) && (block <= 0x2F)) { - uint8_t offset = block >= 0x2C ? 0 : 0x2C - block; - uint8_t length = block >= 0x2C ? 0x30 - block : block - 0x28; - memset(emdata + offset * 4, 0x00, length * 4); + uint8_t offset = block >= 0x2C ? 0 : 0x2C - block; + uint8_t length = block >= 0x2C ? 0x30 - block : block - 0x28; + memset(emdata + offset * 4, 0x00, length * 4); } else if ((tagType == 14) && (block >= 0x2D) && (block <= 0x37)) { - uint8_t offset = block >= 0x30 ? 0 : 0x30 - block; - uint8_t length = block >= 0x30 ? (0x37 - block > 4 ? 4 : 0x37 - block) : block - 0x2C; - memset(emdata + offset * 4, 0x00, length * 4); + uint8_t offset = block >= 0x30 ? 0 : 0x30 - block; + uint8_t length = block >= 0x30 ? (0x37 - block > 4 ? 4 : 0x37 - block) : block - 0x2C; + memset(emdata + offset * 4, 0x00, length * 4); } // TODO: implement cyclic memory if we reach AUTH0 and AUTH1=0 and unauth on ULC/ULAES, or if we reach end of memory AddCrc14A(emdata, MIFARE_BLOCK_SIZE); @@ -1987,7 +1987,7 @@ void SimulateIso14443aTagEx(uint8_t tagType, uint16_t flags, uint8_t *useruid, u if (wrblock > pages) { // send NACK 0x0 == invalid argument EmSend4bit(CARD_NACK_IV); - // TODO: check if wrblock >= AUTH0 and unauth on ULC/ULAES -> NACK + // TODO: check if wrblock >= AUTH0 and unauth on ULC/ULAES -> NACK } else { // send ACK EmSend4bit(CARD_ACK); diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index d15637d1d..d2da56917 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -1797,7 +1797,7 @@ void MifareStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t targetBlockNo, // NT1 is any: // NT2 case: random, but is static(static encrypted nested). - // pre-generate nonces: the distance value is related to the key type, so if the key type is the same, + // pre-generate nonces: the distance value is related to the key type, so if the key type is the same, // we can directly use the measured distance value. (Experience) if (targetKeyType == 1 && nt1 == 0x009080A2 && forceDetectDist == 0) { target_nt[0] = prng_successor(nt1, 161); diff --git a/armsrc/seos.c b/armsrc/seos.c index e19d2dfc3..4e4cacb66 100644 --- a/armsrc/seos.c +++ b/armsrc/seos.c @@ -123,7 +123,7 @@ static bool generate_cmac(const uint8_t *key, const uint8_t *input, size_t lengt } static void seos_kdf(bool forEncryption, uint8_t *masterKey, uint8_t keyslot, uint8_t *work_buffer, - uint8_t *adfOid, size_t adfoid_len, uint8_t *diversifier, uint8_t diversifier_len, uint8_t *out, int encryption_algorithm, int hash_algorithm) { + uint8_t *adfOid, size_t adfoid_len, uint8_t *diversifier, uint8_t diversifier_len, uint8_t *out, int encryption_algorithm, int hash_algorithm) { // Encryption key = 04 // KEK Encryption key = 05 @@ -142,8 +142,8 @@ static void seos_kdf(bool forEncryption, uint8_t *masterKey, uint8_t keyslot, ui work_buffer[16] = encryption_algorithm; work_buffer[17] = hash_algorithm; work_buffer[18] = keyslot; - memcpy(work_buffer+19, adfOid, adfoid_len); - memcpy(work_buffer+19+adfoid_len, diversifier, diversifier_len); + memcpy(work_buffer + 19, adfOid, adfoid_len); + memcpy(work_buffer + 19 + adfoid_len, diversifier, diversifier_len); // This CMAC always uses AES, regardless of the main encryption algorithm in use. generate_cmac(masterKey, work_buffer, 19 + adfoid_len + diversifier_len, out, SEOS_ENCRYPTION_AES); @@ -370,7 +370,7 @@ void SimulateSeos(seos_emulate_req_t *msg) { while (tlv_offset < received_tlv_len) { uint8_t tag = received_tlv[tlv_offset++]; uint8_t length = received_tlv[tlv_offset++]; - uint8_t* value = &received_tlv[tlv_offset]; + uint8_t *value = &received_tlv[tlv_offset]; if (tag == 0x06) { if (length == msg->oid_len && memcmp(value, msg->oid, length) == 0) { selected_oid = true; @@ -383,7 +383,7 @@ void SimulateSeos(seos_emulate_req_t *msg) { if (selected_oid) { // Synthesized IV: half a block of random data followed by half of the CMAC of that data memset(cryptogram_iv, 0, half_bs); // TODO: Maybe actually use random data? - if (!generate_cmac(msg->privmac, cryptogram_iv, half_bs, cryptogram_iv+half_bs, msg->encr_alg)) { + if (!generate_cmac(msg->privmac, cryptogram_iv, half_bs, cryptogram_iv + half_bs, msg->encr_alg)) { Dbprintf(_RED_("Select ADF failed") ": Failed to create IV CMAC."); break; } @@ -396,12 +396,12 @@ void SimulateSeos(seos_emulate_req_t *msg) { reply[reply_idx++] = 0x06; // Tag: selected OID reply[reply_idx++] = msg->oid_len; - memcpy(reply+reply_idx, msg->oid, msg->oid_len); + memcpy(reply + reply_idx, msg->oid, msg->oid_len); reply_idx += msg->oid_len; reply[reply_idx++] = 0xCF; // Tag: diversifier reply[reply_idx++] = msg->diversifier_len; - memcpy(reply+reply_idx, msg->diversifier, msg->diversifier_len); + memcpy(reply + reply_idx, msg->diversifier, msg->diversifier_len); reply_idx += msg->diversifier_len; uint8_t tlv_base = 1 + offset; @@ -414,11 +414,11 @@ void SimulateSeos(seos_emulate_req_t *msg) { dynamic_response_info.response[tlv_idx++] = 0x85; // Tag: cryptogram dynamic_response_info.response[tlv_idx++] = reply_len + bs; // Length - memcpy(dynamic_response_info.response+tlv_idx, cryptogram_iv, bs); + memcpy(dynamic_response_info.response + tlv_idx, cryptogram_iv, bs); tlv_idx += bs; // Generate cryptogram directly into response buffer - if (!generate_cryptogram(msg->privenc, true, reply, reply_len, dynamic_response_info.response+tlv_idx, msg->encr_alg)) { + if (!generate_cryptogram(msg->privenc, true, reply, reply_len, dynamic_response_info.response + tlv_idx, msg->encr_alg)) { Dbprintf(_RED_("Select ADF failed") ": Failed to create reply cryptogram."); break; } @@ -427,14 +427,14 @@ void SimulateSeos(seos_emulate_req_t *msg) { // Always an 8-byte CMAC const uint8_t cmac_size = 8; uint8_t *cmac = work_buffer_a; - if (!generate_cmac(msg->privmac, dynamic_response_info.response+tlv_base, tlv_idx-tlv_base, cmac, msg->encr_alg)) { + if (!generate_cmac(msg->privmac, dynamic_response_info.response + tlv_base, tlv_idx - tlv_base, cmac, msg->encr_alg)) { Dbprintf(_RED_("Select ADF failed") ": Failed to create reply CMAC."); break; } dynamic_response_info.response[tlv_idx++] = 0x8E; // Tag: CMAC dynamic_response_info.response[tlv_idx++] = cmac_size; // Length - memcpy(dynamic_response_info.response+tlv_idx, cmac, cmac_size); + memcpy(dynamic_response_info.response + tlv_idx, cmac, cmac_size); tlv_idx += cmac_size; dynamic_response_info.response_n = tlv_idx; @@ -463,10 +463,10 @@ void SimulateSeos(seos_emulate_req_t *msg) { uint8_t tlv_idx = 1 + offset; dynamic_response_info.response[tlv_idx++] = 0x7C; // Tag: mutual auth - dynamic_response_info.response[tlv_idx++] = sizeof(RND_ICC)+2; // Length + dynamic_response_info.response[tlv_idx++] = sizeof(RND_ICC) +2; // Length dynamic_response_info.response[tlv_idx++] = 0x81; // Tag: request for RND.ICC dynamic_response_info.response[tlv_idx++] = sizeof(RND_ICC); // Length - memcpy(dynamic_response_info.response+tlv_idx, RND_ICC, sizeof(RND_ICC)); + memcpy(dynamic_response_info.response + tlv_idx, RND_ICC, sizeof(RND_ICC)); tlv_idx += sizeof(RND_ICC); dynamic_response_info.response_n = tlv_idx; @@ -534,7 +534,7 @@ void SimulateSeos(seos_emulate_req_t *msg) { const uint8_t reply_len = reply_plain_len + 8; uint8_t *reply = work_buffer_b; generate_cryptogram(diver_encr_key, false, reply_plain, reply_plain_len, reply, msg->encr_alg); - if (!generate_cmac(diver_cmac_key, reply, reply_plain_len, reply+reply_plain_len, msg->encr_alg)) { + if (!generate_cmac(diver_cmac_key, reply, reply_plain_len, reply + reply_plain_len, msg->encr_alg)) { Dbprintf(_RED_("Mutual auth failed") ": Failed to create reply CMAC."); break; } @@ -542,10 +542,10 @@ void SimulateSeos(seos_emulate_req_t *msg) { uint8_t tlv_idx = 1 + offset; dynamic_response_info.response[tlv_idx++] = 0x7C; // Tag: mutual auth - dynamic_response_info.response[tlv_idx++] = reply_len+2; // Length + dynamic_response_info.response[tlv_idx++] = reply_len + 2; // Length dynamic_response_info.response[tlv_idx++] = 0x82; // Tag: request for challenge dynamic_response_info.response[tlv_idx++] = reply_len; // Length - memcpy(dynamic_response_info.response+tlv_idx, reply, reply_len); + memcpy(dynamic_response_info.response + tlv_idx, reply, reply_len); tlv_idx += reply_len; dynamic_response_info.response_n = tlv_idx; @@ -564,17 +564,17 @@ void SimulateSeos(seos_emulate_req_t *msg) { hash_input[hash_idx++] = 0x00; hash_input[hash_idx++] = 0x01; // Only copy first 8 bytes of each KEY - memcpy(hash_input+hash_idx, KEY_IFD, 8); + memcpy(hash_input + hash_idx, KEY_IFD, 8); hash_idx += 8; - memcpy(hash_input+hash_idx, KEY_ICC, 8); + memcpy(hash_input + hash_idx, KEY_ICC, 8); hash_idx += 8; // Yes, this is supposed to be the same thing twice hash_input[hash_idx++] = msg->encr_alg; hash_input[hash_idx++] = msg->encr_alg; // Copy full RND values - memcpy(hash_input+hash_idx, RND_ICC, 8); + memcpy(hash_input + hash_idx, RND_ICC, 8); hash_idx += 8; - memcpy(hash_input+hash_idx, RND_IFD, 8); + memcpy(hash_input + hash_idx, RND_IFD, 8); hash_idx += 8; uint8_t *hash_output = work_buffer_b; @@ -593,9 +593,9 @@ void SimulateSeos(seos_emulate_req_t *msg) { } memcpy(diver_encr_key, hash_output, 16); - memcpy(diver_cmac_key, hash_output+16, 16); + memcpy(diver_cmac_key, hash_output + 16, 16); } else { - Dbprintf( _RED_("Mutual auth failed") ": Incorrect tag %02X found.", received_tlv[0]); + Dbprintf(_RED_("Mutual auth failed") ": Incorrect tag %02X found.", received_tlv[0]); } } break; @@ -617,8 +617,8 @@ void SimulateSeos(seos_emulate_req_t *msg) { uint8_t tlv_offset = 0; while (tlv_offset < received_tlv_len) { uint8_t tag = received_tlv[tlv_offset]; - uint8_t length = received_tlv[tlv_offset+1]; - uint8_t* value = &received_tlv[tlv_offset+2]; + uint8_t length = received_tlv[tlv_offset + 1]; + uint8_t *value = &received_tlv[tlv_offset + 2]; if (tag == 0x85) { cryptogram = value; @@ -642,7 +642,7 @@ void SimulateSeos(seos_emulate_req_t *msg) { memcpy(rndCounter, RND_ICC, half_bs); memcpy(rndCounter + half_bs, RND_IFD, half_bs); - for (int8_t i=bs-1; i>=0; i--) { + for (int8_t i = bs - 1; i >= 0; i--) { rndCounter[i]++; if (rndCounter[i] != 0x00) break; } @@ -678,7 +678,7 @@ void SimulateSeos(seos_emulate_req_t *msg) { break; } if (memcmp(cmac, recvd_cmac, recvd_cmac_length) != 0) { - Dbprintf( _RED_("Get Data failed") ": Invalid CMAC."); + Dbprintf(_RED_("Get Data failed") ": Invalid CMAC."); break; } @@ -699,7 +699,7 @@ void SimulateSeos(seos_emulate_req_t *msg) { break; } - if (request[1] != msg->data_tag_len || memcmp(request+2, msg->data_tag, msg->data_tag_len) != 0) { + if (request[1] != msg->data_tag_len || memcmp(request + 2, msg->data_tag, msg->data_tag_len) != 0) { Dbprintf(_RED_("Get Data failed") ": Requested invalid data tag."); break; } @@ -714,10 +714,10 @@ void SimulateSeos(seos_emulate_req_t *msg) { uint8_t *reply = work_buffer_a; uint8_t reply_idx = 0; - memcpy(reply+reply_idx, msg->data_tag, msg->data_tag_len); // Tag + memcpy(reply + reply_idx, msg->data_tag, msg->data_tag_len); // Tag reply_idx += msg->data_tag_len; reply[reply_idx++] = msg->data_len; // Length - memcpy(reply+reply_idx, msg->data, msg->data_len); // Value + memcpy(reply + reply_idx, msg->data, msg->data_len); // Value reply_idx += msg->data_len; if (reply_idx != reply_len) { @@ -735,7 +735,7 @@ void SimulateSeos(seos_emulate_req_t *msg) { // Only include a cryptogram for GET DATA dynamic_response_info.response[tlv_idx++] = 0x85; // Tag: cryptogram dynamic_response_info.response[tlv_idx++] = reply_len; // Length - memcpy(dynamic_response_info.response+tlv_idx, reply_cryptogram, reply_len); + memcpy(dynamic_response_info.response + tlv_idx, reply_cryptogram, reply_len); tlv_idx += reply_len; } @@ -747,7 +747,7 @@ void SimulateSeos(seos_emulate_req_t *msg) { // Unlike every other CMAC, this time we need to prepend // the same counter from above, but increment it again - for (int8_t i=bs-1; i>=0; i--) { + for (int8_t i = bs - 1; i >= 0; i--) { rndCounter[i]++; if (rndCounter[i] != 0x00) break; } @@ -774,7 +774,7 @@ void SimulateSeos(seos_emulate_req_t *msg) { dynamic_response_info.response[tlv_idx++] = 0x8E; // Tag: CMAC dynamic_response_info.response[tlv_idx++] = cmac_size; // Length - memcpy(dynamic_response_info.response+tlv_idx, cmac, cmac_size); + memcpy(dynamic_response_info.response + tlv_idx, cmac, cmac_size); tlv_idx += cmac_size; dynamic_response_info.response_n = tlv_idx; @@ -783,7 +783,7 @@ void SimulateSeos(seos_emulate_req_t *msg) { apdu_status[0] = 0x90; apdu_status[1] = 0x00; } else { - Dbprintf( _RED_("Get Data failed") ": No cryptogram or CMAC found in request."); + Dbprintf(_RED_("Get Data failed") ": No cryptogram or CMAC found in request."); } } break; @@ -859,4 +859,4 @@ void SimulateSeos(seos_emulate_req_t *msg) { } reply_ng(CMD_HF_SEOS_SIMULATE, retval, NULL, 0); -} \ No newline at end of file +} diff --git a/client/deps/id48/public/id48.h b/client/deps/id48/public/id48.h index 502d8a1e5..87f94a6cc 100644 --- a/client/deps/id48/public/id48.h +++ b/client/deps/id48/public/id48.h @@ -31,13 +31,13 @@ #include #include #if defined(NDEBUG) - #define ASSERT(x) ((void)0) +#define ASSERT(x) ((void)0) #elif defined(ID48_NO_STDIO) - #define ASSERT(x) ((void)0) +#define ASSERT(x) ((void)0) #else // neither NDEBUG nor ID48_NO_STDIO defined - #include - #include - #define ASSERT(x) assert((x)) +#include +#include +#define ASSERT(x) assert((x)) #endif diff --git a/client/deps/id48/tests/espresso/array_size2.h b/client/deps/id48/tests/espresso/array_size2.h index 2f9a18e38..951223d3b 100644 --- a/client/deps/id48/tests/espresso/array_size2.h +++ b/client/deps/id48/tests/espresso/array_size2.h @@ -45,27 +45,25 @@ SOFTWARE. */ #ifndef __has_feature - #define __has_feature(x) 0 /* Compatibility with non-clang compilers. */ +#define __has_feature(x) 0 /* Compatibility with non-clang compilers. */ #endif #if (defined(__cplusplus) && __cplusplus >= 201103L) || /* any compiler claiming C++11 support */ \ (defined(__cplusplus) && _MSC_VER >= 1900 && __cplusplus != 199711L) || /* Visual C++ 2015 or higher */ \ __has_feature(cxx_constexpr) /* CLang versions supporting constexp */ - #include /* required for size_t */ - #if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) - #pragma message( "ARRAY_SIZE2 -- Using C++11 version" ) - #endif +#include /* required for size_t */ +#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) +#pragma message( "ARRAY_SIZE2 -- Using C++11 version" ) +#endif - namespace detail - { - template - constexpr size_t ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(T const (&)[N]) noexcept - { - return N; - } - } /* namespace detail */ - #define ARRAY_SIZE2(arr) detail::ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(arr) +namespace detail { +template +constexpr size_t ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(T const(&)[N]) noexcept { + return N; +} +} /* namespace detail */ +#define ARRAY_SIZE2(arr) detail::ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(arr) #elif defined(__cplusplus) && __cplusplus >= 199711L && ( /* C++ 98 trick */ \ defined(__INTEL_COMPILER) || \ @@ -75,81 +73,81 @@ SOFTWARE. (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ ))) - #include /* required for size_t */ - #if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) - #pragma message "ARRAY_SIZE2 -- Using C++98 version" - #endif - template - char(&_ArraySizeHelperRequiresArray(T(&)[N]))[N]; - #define ARRAY_SIZE2(x) sizeof(_ArraySizeHelperRequiresArray(x)) +#include /* required for size_t */ +#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) +#pragma message "ARRAY_SIZE2 -- Using C++98 version" +#endif +template +char(&_ArraySizeHelperRequiresArray(T(&)[N]))[N]; +#define ARRAY_SIZE2(x) sizeof(_ArraySizeHelperRequiresArray(x)) #elif defined(__cplusplus) /* && ((__cplusplus >= 199711L) || defined(__INTEL_COMPILER) || defined(__clang__)) */ - - #if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) - #pragma message( "ARRAY_SIZE2 -- Using Ivan J. Johnson's C++ version" ) - #endif - /* - Works on older compilers, even Visual C++ 6.... - Created by Ivan J. Johnson, March 06, 2007 - See http://drdobbs.com/cpp/197800525?pgno=1 - Full description is in markdown file array_size2.md - */ - #define ARRAY_SIZE2(arr) ( \ +#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) +#pragma message( "ARRAY_SIZE2 -- Using Ivan J. Johnson's C++ version" ) +#endif +/* + Works on older compilers, even Visual C++ 6.... + Created by Ivan J. Johnson, March 06, 2007 + See http://drdobbs.com/cpp/197800525?pgno=1 + + Full description is in markdown file array_size2.md +*/ +#define ARRAY_SIZE2(arr) ( \ 0 * sizeof(reinterpret_cast(arr)) + /*check1*/ \ 0 * sizeof(::Bad_arg_to_ARRAY_SIZE2::check_type((arr), &(arr))) + /*check2*/ \ sizeof(arr) / sizeof((arr)[0]) /* eval */ \ ) - struct Bad_arg_to_ARRAY_SIZE2 { - class Is_pointer; /* incomplete */ - class Is_array {}; - template - static Is_pointer check_type(T const *, T const * const *); - static Is_array check_type(void const *, void const *); - }; +struct Bad_arg_to_ARRAY_SIZE2 { + class Is_pointer; /* incomplete */ + class Is_array {}; + template + static Is_pointer check_type(T const *, T const * const *); + static Is_array check_type(void const *, void const *); +}; #elif !defined(__cplusplus) && defined(__GNUC__) - #include +#include - /** - Even C can have type-safety for equivalent of ARRAY_SIZE() macro, - when using the following two GCC extensions: - typeof() - __builtin_types_compatible_p() - */ +/** + Even C can have type-safety for equivalent of ARRAY_SIZE() macro, + when using the following two GCC extensions: + typeof() + __builtin_types_compatible_p() +*/ - #if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) - #pragma message( "ARRAY_SIZE2 -- Using GNUC version" ) - #endif +#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) +#pragma message( "ARRAY_SIZE2 -- Using GNUC version" ) +#endif - /** - validated using: - MSP430 gcc 4.5.3 - x86-64 icc 16.0.3 - x86-64 gcc 4.1.2 - x86-64 clang 3.0.0 - AVR gcc 4.5.4 - ARM gcc 4.5.4 - */ +/** + validated using: + MSP430 gcc 4.5.3 + x86-64 icc 16.0.3 + x86-64 gcc 4.1.2 + x86-64 clang 3.0.0 + AVR gcc 4.5.4 + ARM gcc 4.5.4 +*/ - #define __SIMPLEHACKS_COMPATIBLE_TYPES__(a,b) __builtin_types_compatible_p(__typeof__(a), __typeof__(b)) /* GCC extensions */ - #define __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(x) (sizeof(struct { uint8_t q: (-!!(x)*0x1ee7)+1u;})-1u) /* if x is zero, reports "error: negative width in bit-field ''" */ - #define __SIMPLEHACKS_MUST_BE_ARRAY__(x) __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(__SIMPLEHACKS_COMPATIBLE_TYPES__((x), &(*x))) - #define ARRAY_SIZE2(_arr) ( (sizeof(_arr) / sizeof((_arr)[0])) + __SIMPLEHACKS_MUST_BE_ARRAY__(_arr) ) /* compile-time error if not an array */ +#define __SIMPLEHACKS_COMPATIBLE_TYPES__(a,b) __builtin_types_compatible_p(__typeof__(a), __typeof__(b)) /* GCC extensions */ +#define __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(x) (sizeof(struct { uint8_t q: (-!!(x)*0x1ee7)+1u;})-1u) /* if x is zero, reports "error: negative width in bit-field ''" */ +#define __SIMPLEHACKS_MUST_BE_ARRAY__(x) __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(__SIMPLEHACKS_COMPATIBLE_TYPES__((x), &(*x))) +#define ARRAY_SIZE2(_arr) ( (sizeof(_arr) / sizeof((_arr)[0])) + __SIMPLEHACKS_MUST_BE_ARRAY__(_arr) ) /* compile-time error if not an array */ #else - /** - The good news is that all compilers (as of 20202-05-08) - on godbolt.org are fully supported. Therefore, if some - other compiler does not support any of the above method, - it's important to force a compile-time error, to avoid - any suggestion that this provides a safe macro. - */ - - #error "Unable to provide type-safe ARRAY_SIZE2 macro" +/** + The good news is that all compilers (as of 20202-05-08) + on godbolt.org are fully supported. Therefore, if some + other compiler does not support any of the above method, + it's important to force a compile-time error, to avoid + any suggestion that this provides a safe macro. +*/ + +#error "Unable to provide type-safe ARRAY_SIZE2 macro" #endif diff --git a/client/deps/id48/tests/espresso/main.c b/client/deps/id48/tests/espresso/main.c index 5dbd54765..e1b6d7234 100644 --- a/client/deps/id48/tests/espresso/main.c +++ b/client/deps/id48/tests/espresso/main.c @@ -13,8 +13,8 @@ int main(void) { printf("Verifying Espresso Results...\n"); result = verify_espresso_results(); printf("Verifying Espresso Results: %s\n", - result ? "SUCCESS" : "----> FAILURE <----" - ); + result ? "SUCCESS" : "----> FAILURE <----" + ); } // if (result) { // printf("Hello2...\n"); diff --git a/client/deps/id48/tests/espresso/verify_espresso.c b/client/deps/id48/tests/espresso/verify_espresso.c index 9e9abeb13..7c9ebd8b0 100644 --- a/client/deps/id48/tests/espresso/verify_espresso.c +++ b/client/deps/id48/tests/espresso/verify_espresso.c @@ -9,78 +9,78 @@ #include "verify_espresso.h" #if !defined true - #define true ((bool)1u) +#define true ((bool)1u) #endif #if !defined false - #define false ((bool)0u) +#define false ((bool)0u) #endif #if 1 // constant names for use in LUT_PLA_NAMES_xx - static const char * const NAME_A = "a"; - static const char * const NAME_B = "b"; - static const char * const NAME_C = "c"; - static const char * const NAME_L0 = "l0"; - static const char * const NAME_L2 = "l2"; - static const char * const NAME_L3 = "l3"; - static const char * const NAME_L4 = "l4"; - static const char * const NAME_L5 = "l5"; - static const char * const NAME_L6 = "l6"; - static const char * const NAME_M0 = "m0"; - static const char * const NAME_M1 = "m1"; - static const char * const NAME_M3 = "m3"; - static const char * const NAME_M5 = "m5"; - static const char * const NAME_R0 = "r0"; - static const char * const NAME_R1 = "r1"; - static const char * const NAME_R2 = "r2"; - static const char * const NAME_R3 = "r3"; - static const char * const NAME_R4 = "r4"; - static const char * const NAME_R5 = "r5"; - static const char * const NAME_R6 = "r6"; +static const char *const NAME_A = "a"; +static const char *const NAME_B = "b"; +static const char *const NAME_C = "c"; +static const char *const NAME_L0 = "l0"; +static const char *const NAME_L2 = "l2"; +static const char *const NAME_L3 = "l3"; +static const char *const NAME_L4 = "l4"; +static const char *const NAME_L5 = "l5"; +static const char *const NAME_L6 = "l6"; +static const char *const NAME_M0 = "m0"; +static const char *const NAME_M1 = "m1"; +static const char *const NAME_M3 = "m3"; +static const char *const NAME_M5 = "m5"; +static const char *const NAME_R0 = "r0"; +static const char *const NAME_R1 = "r1"; +static const char *const NAME_R2 = "r2"; +static const char *const NAME_R3 = "r3"; +static const char *const NAME_R4 = "r4"; +static const char *const NAME_R5 = "r5"; +static const char *const NAME_R6 = "r6"; #endif // constant names for use in LUT_PLA_NAMES_xx #if 1 // LUT_PLA_NAMES_xx -- name arrays for generating espresso input files - // NOTE: these arrays are in order of the most significant to least significant bit. - // did i get confused by that? - const char * const LUT_PLA_NAMES_g1[5] = { NAME_A , NAME_L2, NAME_L3, NAME_L0, NAME_L6, }; - const char * const LUT_PLA_NAMES_g2[5] = { NAME_L5, NAME_B , NAME_M0, NAME_L4, NAME_M1, }; - const char * const LUT_PLA_NAMES_g3[5] = { NAME_M5, NAME_C , NAME_R1, NAME_M3, NAME_R3, }; - const char * const LUT_PLA_NAMES_g4[5] = { NAME_R2, NAME_R4, NAME_R6, NAME_R0, NAME_R5, }; - const char * const LUT_PLA_NAMES_XX[8] = { - NAME_L0, NAME_L4, NAME_L6, NAME_M1, - NAME_M3, NAME_R0, NAME_R3, NAME_R5, - }; +// NOTE: these arrays are in order of the most significant to least significant bit. +// did i get confused by that? +const char *const LUT_PLA_NAMES_g1[5] = { NAME_A, NAME_L2, NAME_L3, NAME_L0, NAME_L6, }; +const char *const LUT_PLA_NAMES_g2[5] = { NAME_L5, NAME_B, NAME_M0, NAME_L4, NAME_M1, }; +const char *const LUT_PLA_NAMES_g3[5] = { NAME_M5, NAME_C, NAME_R1, NAME_M3, NAME_R3, }; +const char *const LUT_PLA_NAMES_g4[5] = { NAME_R2, NAME_R4, NAME_R6, NAME_R0, NAME_R5, }; +const char *const LUT_PLA_NAMES_XX[8] = { + NAME_L0, NAME_L4, NAME_L6, NAME_M1, + NAME_M3, NAME_R0, NAME_R3, NAME_R5, +}; #endif // LUT_PLA_NAMES_xx -- name arrays for generating espresso input files #if 1 // actual lookup tables - // LUTs were internal-only, and not even exposed to library internals. - // so just copy/paste here for now for initial testing - /// initial_idx = (l0 << 7) | (l4 << 6) | (l6 << 5) | (m1 << 4) | (m3 << 3) | (r0 << 2) | (r3 << 1) | (r5 << 0) - static const uint8_t small_lut_XX[32] = { // aka 256 bits - 0x44, 0xff, 0x4f, 0x4f, 0x55, 0xff, 0x55, 0x55, - 0xcc, 0xff, 0xcf, 0x4f, 0xcc, 0xff, 0xcc, 0x44, - 0x00, 0x00, 0x0f, 0x0f, 0x55, 0x55, 0x55, 0x55, - 0xcc, 0x00, 0xcf, 0x0f, 0xcc, 0x00, 0xcc, 0x00, - }; - /// g1_idx = (a << 4) | (l2 << 3) | (l3 << 2) | (l0 << 1) | (l6 << 0) - static const uint8_t small_lut_group1[4] = { // aka 32 bits - 0x4f, 0x92, 0xa1, 0x7c, - }; - /// g2_idx = (l5 << 4) | (b << 3) | (m0 << 2) | (l4 << 1) | (m1 << 0) - static const uint8_t small_lut_group2[4] = { // aka 32 bits - 0x8f, 0x52, 0x61, 0xbc, - }; - /// g3_idx = (m5 << 4) | (c << 3) | (r1 << 2) | (m3 << 1) | (r3 << 0) - static const uint8_t small_lut_group3[4] = { // aka 32 bits - 0x8f, 0x34, 0x61, 0xda, - }; - /// g4_idx = (r2 << 4) | (r4 << 3) | (r6 << 2) | (r0 << 1) | (r5 << 0) - static const uint8_t small_lut_group4[4] = { // aka 32 bits - 0x8f, 0x34, 0x52, 0xe9, - }; - static inline bool get_bit(const uint8_t *table_start, uint32_t bit_idx) { - const uint32_t byte = bit_idx / 8u; - const uint8_t mask = 1u << (bit_idx % 8u); - return (table_start[byte] & mask) != 0; - } +// LUTs were internal-only, and not even exposed to library internals. +// so just copy/paste here for now for initial testing +/// initial_idx = (l0 << 7) | (l4 << 6) | (l6 << 5) | (m1 << 4) | (m3 << 3) | (r0 << 2) | (r3 << 1) | (r5 << 0) +static const uint8_t small_lut_XX[32] = { // aka 256 bits + 0x44, 0xff, 0x4f, 0x4f, 0x55, 0xff, 0x55, 0x55, + 0xcc, 0xff, 0xcf, 0x4f, 0xcc, 0xff, 0xcc, 0x44, + 0x00, 0x00, 0x0f, 0x0f, 0x55, 0x55, 0x55, 0x55, + 0xcc, 0x00, 0xcf, 0x0f, 0xcc, 0x00, 0xcc, 0x00, +}; +/// g1_idx = (a << 4) | (l2 << 3) | (l3 << 2) | (l0 << 1) | (l6 << 0) +static const uint8_t small_lut_group1[4] = { // aka 32 bits + 0x4f, 0x92, 0xa1, 0x7c, +}; +/// g2_idx = (l5 << 4) | (b << 3) | (m0 << 2) | (l4 << 1) | (m1 << 0) +static const uint8_t small_lut_group2[4] = { // aka 32 bits + 0x8f, 0x52, 0x61, 0xbc, +}; +/// g3_idx = (m5 << 4) | (c << 3) | (r1 << 2) | (m3 << 1) | (r3 << 0) +static const uint8_t small_lut_group3[4] = { // aka 32 bits + 0x8f, 0x34, 0x61, 0xda, +}; +/// g4_idx = (r2 << 4) | (r4 << 3) | (r6 << 2) | (r0 << 1) | (r5 << 0) +static const uint8_t small_lut_group4[4] = { // aka 32 bits + 0x8f, 0x34, 0x52, 0xe9, +}; +static inline bool get_bit(const uint8_t *table_start, uint32_t bit_idx) { + const uint32_t byte = bit_idx / 8u; + const uint8_t mask = 1u << (bit_idx % 8u); + return (table_start[byte] & mask) != 0; +} #endif // actual lookup tables @@ -217,9 +217,9 @@ typedef struct _INDEX_XX { typedef struct _ESPRESSO_GENERATOR_ARGUMENTS { uint8_t const input_count; - char const * const * names; - char const * const output_name; - uint8_t const * lut_start; + char const *const *names; + char const *const output_name; + uint8_t const *lut_start; } ESPRESSO_GENERATOR_ARGUMENTS; static bool verify_lut_g1(void); @@ -243,16 +243,16 @@ static bool espresso_implementation_g1_alt0(uint8_t idx) { bool l0 = idx & (1u << 1); bool l6 = idx & (1u << 0); return - ( a && l2 && _ && l0 && !(l6) ) || - ( a && _ && l3 && !(l0) && l6 ) || - ( !(a) && !(l2) && !(l3) && _ && _ ) || - ( _ && !(l2) && !(l3) && !(l0) && !(l6) ) || - ( _ && l2 && l3 && !(l0) && !(l6) ) || - ( !(a) && !(l2) && _ && l0 && !(l6) ) || - ( !(a) && _ && !(l3) && !(l0) && l6 ) || - ( a && l2 && !(l3) && l0 && _ ) || - ( a && !(l2) && l3 && _ && l6 ) || - ( !(a) && l2 && l3 && l0 && l6 ) ; + (a && l2 && _ && l0 && !(l6)) || + (a && _ && l3 && !(l0) && l6) || + (!(a) && !(l2) && !(l3) && _ && _) || + (_ && !(l2) && !(l3) && !(l0) && !(l6)) || + (_ && l2 && l3 && !(l0) && !(l6)) || + (!(a) && !(l2) && _ && l0 && !(l6)) || + (!(a) && _ && !(l3) && !(l0) && l6) || + (a && l2 && !(l3) && l0 && _) || + (a && !(l2) && l3 && _ && l6) || + (!(a) && l2 && l3 && l0 && l6) ; } static bool espresso_implementation_g1_alt1(uint8_t idx) { // output_g1 = (a&l2&l0&!l6) | (a&l3&!l0&l6) | (!a&!l2&!l3) | (!l2&!l3&!l0&!l6) | (l2&l3&!l0&!l6) | (!a&!l2&l0&!l6) | (!a&!l3&!l0&l6) | (a&l2&!l3&l0) | (a&!l2&l3&l6) | (!a&l2&l3&l0&l6); @@ -264,16 +264,16 @@ static bool espresso_implementation_g1_alt1(uint8_t idx) { bool l0 = t.l0; bool l6 = t.l6; return - ( a && l0 && l2 && _ && !(l6) ) || - ( a && !(l0) && _ && l3 && l6 ) || - ( !(a) && _ && !(l2) && !(l3) && _ ) || - ( _ && !(l0) && !(l2) && !(l3) && !(l6) ) || - ( _ && !(l0) && l2 && l3 && !(l6) ) || - ( !(a) && l0 && !(l2) && _ && !(l6) ) || - ( !(a) && !(l0) && _ && !(l3) && l6 ) || - ( a && l0 && l2 && !(l3) && _ ) || - ( a && _ && !(l2) && l3 && l6 ) || - ( !(a) && l0 && l2 && l3 && l6 ) ; + (a && l0 && l2 && _ && !(l6)) || + (a && !(l0) && _ && l3 && l6) || + (!(a) && _ && !(l2) && !(l3) && _) || + (_ && !(l0) && !(l2) && !(l3) && !(l6)) || + (_ && !(l0) && l2 && l3 && !(l6)) || + (!(a) && l0 && !(l2) && _ && !(l6)) || + (!(a) && !(l0) && _ && !(l3) && l6) || + (a && l0 && l2 && !(l3) && _) || + (a && _ && !(l2) && l3 && l6) || + (!(a) && l0 && l2 && l3 && l6) ; } static const lookuptable_func_t alt_for_g1[] = { espresso_implementation_g1_alt0, @@ -290,17 +290,17 @@ static bool espresso_implementation_g2_alt0(uint8_t idx) { bool l4 = idx & (1u << 1); bool m1 = idx & (1u << 0); static const bool _ = true; - return - ( _ && b && m0 && !(l4) && !(m1) ) | - ( l5 && b && _ && l4 && m1 ) | - ( !(l5) && !(b) && !(m0) && _ && _ ) | - ( _ && !(b) && !(m0) && !(l4) && !(m1) ) | - ( l5 && b && !(m0) && l4 && _ ) | - ( l5 && !(b) && m0 && l4 && !(m1) ) | - ( !(l5) && b && m0 && _ && !(m1) ) | - ( !(l5) && _ && !(m0) && !(l4) && m1 ) | - ( l5 && _ && m0 && !(l4) && m1 ) | - ( !(l5) && !(b) && _ && l4 && m1 ) ; + return + (_ && b && m0 && !(l4) && !(m1)) | + (l5 && b && _ && l4 && m1) | + (!(l5) && !(b) && !(m0) && _ && _) | + (_ && !(b) && !(m0) && !(l4) && !(m1)) | + (l5 && b && !(m0) && l4 && _) | + (l5 && !(b) && m0 && l4 && !(m1)) | + (!(l5) && b && m0 && _ && !(m1)) | + (!(l5) && _ && !(m0) && !(l4) && m1) | + (l5 && _ && m0 && !(l4) && m1) | + (!(l5) && !(b) && _ && l4 && m1) ; } static bool espresso_implementation_g2_alt1(uint8_t idx) { // output_g2 = (b&m0&!l4&!m1) | (l5&b&l4&m1) | (!l5&!b&!m0) | (!b&!m0&!l4&!m1) | (l5&b&!m0&l4) | (l5&!b&m0&l4&!m1) | (!l5&b&m0&!m1) | (!l5&!m0&!l4&m1) | (l5&m0&!l4&m1) | (!l5&!b&l4&m1); @@ -311,17 +311,17 @@ static bool espresso_implementation_g2_alt1(uint8_t idx) { bool l4 = t.l4; bool m1 = t.m1; static const bool _ = true; - return - ( _ && b && m0 && !(l4) && !(m1) ) | - ( l5 && b && _ && l4 && m1 ) | - ( !(l5) && !(b) && !(m0) && _ && _ ) | - ( _ && !(b) && !(m0) && !(l4) && !(m1) ) | - ( l5 && b && !(m0) && l4 && _ ) | - ( l5 && !(b) && m0 && l4 && !(m1) ) | - ( !(l5) && b && m0 && _ && !(m1) ) | - ( !(l5) && _ && !(m0) && !(l4) && m1 ) | - ( l5 && _ && m0 && !(l4) && m1 ) | - ( !(l5) && !(b) && _ && l4 && m1 ) ; + return + (_ && b && m0 && !(l4) && !(m1)) | + (l5 && b && _ && l4 && m1) | + (!(l5) && !(b) && !(m0) && _ && _) | + (_ && !(b) && !(m0) && !(l4) && !(m1)) | + (l5 && b && !(m0) && l4 && _) | + (l5 && !(b) && m0 && l4 && !(m1)) | + (!(l5) && b && m0 && _ && !(m1)) | + (!(l5) && _ && !(m0) && !(l4) && m1) | + (l5 && _ && m0 && !(l4) && m1) | + (!(l5) && !(b) && _ && l4 && m1) ; } static const lookuptable_func_t alt_for_g2[] = { @@ -341,16 +341,16 @@ static bool espresso_implementation_g3_alt0(uint8_t idx) { bool r3 = idx & (1u << 0); static const bool _ = true; return - ( _ && c && r1 && !(m3) && !(r3) ) || - ( m5 && c && _ && m3 && r3 ) || - ( !(m5) && !(c) && !(r1) && _ && _ ) || - ( _ && !(c) && !(r1) && !(m3) && !(r3) ) || - ( !(m5) && _ && !(r1) && m3 && !(r3) ) || - ( m5 && _ && r1 && m3 && !(r3) ) || - ( m5 && c && !(r1) && _ && r3 ) || - ( m5 && !(c) && r1 && !(m3) && r3 ) || - ( !(m5) && c && r1 && !(m3) && _ ) || - ( !(m5) && !(c) && _ && m3 && r3 ) ; + (_ && c && r1 && !(m3) && !(r3)) || + (m5 && c && _ && m3 && r3) || + (!(m5) && !(c) && !(r1) && _ && _) || + (_ && !(c) && !(r1) && !(m3) && !(r3)) || + (!(m5) && _ && !(r1) && m3 && !(r3)) || + (m5 && _ && r1 && m3 && !(r3)) || + (m5 && c && !(r1) && _ && r3) || + (m5 && !(c) && r1 && !(m3) && r3) || + (!(m5) && c && r1 && !(m3) && _) || + (!(m5) && !(c) && _ && m3 && r3) ; } static bool espresso_implementation_g3_alt1(uint8_t idx) { // output_g3 = (c&r1&!m3&!r3) | (m5&c&m3&r3) | (!m5&!c&!r1) | (!c&!r1&!m3&!r3) | (!m5&!r1&m3&!r3) | (m5&r1&m3&!r3) | (m5&c&!r1&r3) | (m5&!c&r1&!m3&r3) | (!m5&c&r1&!m3) | (!m5&!c&m3&r3); @@ -362,16 +362,16 @@ static bool espresso_implementation_g3_alt1(uint8_t idx) { bool m5 = t.m5; static const bool _ = true; return - ( _ && c && r1 && !(m3) && !(r3) ) || - ( m5 && c && _ && m3 && r3 ) || - ( !(m5) && !(c) && !(r1) && _ && _ ) || - ( _ && !(c) && !(r1) && !(m3) && !(r3) ) || - ( !(m5) && _ && !(r1) && m3 && !(r3) ) || - ( m5 && _ && r1 && m3 && !(r3) ) || - ( m5 && c && !(r1) && _ && r3 ) || - ( m5 && !(c) && r1 && !(m3) && r3 ) || - ( !(m5) && c && r1 && !(m3) && _ ) || - ( !(m5) && !(c) && _ && m3 && r3 ) ; + (_ && c && r1 && !(m3) && !(r3)) || + (m5 && c && _ && m3 && r3) || + (!(m5) && !(c) && !(r1) && _ && _) || + (_ && !(c) && !(r1) && !(m3) && !(r3)) || + (!(m5) && _ && !(r1) && m3 && !(r3)) || + (m5 && _ && r1 && m3 && !(r3)) || + (m5 && c && !(r1) && _ && r3) || + (m5 && !(c) && r1 && !(m3) && r3) || + (!(m5) && c && r1 && !(m3) && _) || + (!(m5) && !(c) && _ && m3 && r3) ; } static const lookuptable_func_t alt_for_g3[] = { @@ -389,16 +389,16 @@ static bool espresso_implementation_g4_alt0(uint8_t idx) { bool r5 = idx & (1u << 0); static const bool _ = true; return - ( r2 && _ && r6 && r0 && !(r5) ) | - ( _ && r4 && r6 && !(r0) && r5 ) | - ( !(r2) && !(r4) && !(r6) && _ && _ ) | - ( r2 && r4 && !(r6) && !(r0) && !(r5) ) | - ( r2 && !(r4) && r6 && _ && !(r5) ) | - ( !(r2) && r4 && r6 && !(r0) && _ ) | - ( !(r2) && _ && !(r6) && r0 && !(r5) ) | - ( _ && !(r4) && !(r6) && !(r0) && r5 ) | - ( r2 && r4 && _ && r0 && r5 ) | - ( !(r2) && !(r4) && _ && r0 && r5 ) ; + (r2 && _ && r6 && r0 && !(r5)) | + (_ && r4 && r6 && !(r0) && r5) | + (!(r2) && !(r4) && !(r6) && _ && _) | + (r2 && r4 && !(r6) && !(r0) && !(r5)) | + (r2 && !(r4) && r6 && _ && !(r5)) | + (!(r2) && r4 && r6 && !(r0) && _) | + (!(r2) && _ && !(r6) && r0 && !(r5)) | + (_ && !(r4) && !(r6) && !(r0) && r5) | + (r2 && r4 && _ && r0 && r5) | + (!(r2) && !(r4) && _ && r0 && r5) ; } static bool espresso_implementation_g4_alt1(uint8_t idx) { // output_g4 = (r2&r6&r0&!r5) | (r4&r6&!r0&r5) | (!r2&!r4&!r6) | (r2&r4&!r6&!r0&!r5) | (r2&!r4&r6&!r5) | (!r2&r4&r6&!r0) | (!r2&!r6&r0&!r5) | (!r4&!r6&!r0&r5) | (r2&r4&r0&r5) | (!r2&!r4&r0&r5); @@ -411,16 +411,16 @@ static bool espresso_implementation_g4_alt1(uint8_t idx) { bool r5 = t.r5; static const bool _ = true; return - ( r2 && _ && r6 && r0 && !(r5) ) | - ( _ && r4 && r6 && !(r0) && r5 ) | - ( !(r2) && !(r4) && !(r6) && _ && _ ) | - ( r2 && r4 && !(r6) && !(r0) && !(r5) ) | - ( r2 && !(r4) && r6 && _ && !(r5) ) | - ( !(r2) && r4 && r6 && !(r0) && _ ) | - ( !(r2) && _ && !(r6) && r0 && !(r5) ) | - ( _ && !(r4) && !(r6) && !(r0) && r5 ) | - ( r2 && r4 && _ && r0 && r5 ) | - ( !(r2) && !(r4) && _ && r0 && r5 ) ; + (r2 && _ && r6 && r0 && !(r5)) | + (_ && r4 && r6 && !(r0) && r5) | + (!(r2) && !(r4) && !(r6) && _ && _) | + (r2 && r4 && !(r6) && !(r0) && !(r5)) | + (r2 && !(r4) && r6 && _ && !(r5)) | + (!(r2) && r4 && r6 && !(r0) && _) | + (!(r2) && _ && !(r6) && r0 && !(r5)) | + (_ && !(r4) && !(r6) && !(r0) && r5) | + (r2 && r4 && _ && r0 && r5) | + (!(r2) && !(r4) && _ && r0 && r5) ; } static const lookuptable_func_t alt_for_g4[] = { @@ -442,11 +442,11 @@ static bool espresso_implementation_xx_alt0(uint8_t idx) { bool r5 = idx & (1u << 0); return - ( _ && _ && !(l6) && m1 && _ && !(r0) && _ && _ ) || - ( _ && l4 && _ && _ && !(m3) && _ && r3 && _ ) || - ( _ && !(l4) && l6 && _ && _ && _ && _ && !(r5) ) || - ( !(l0) && _ && _ && !(m1) && m3 && _ && _ && _ ) || - ( !(l0) && _ && _ && _ && _ && _ && r3 && !(r5) ) ; + (_ && _ && !(l6) && m1 && _ && !(r0) && _ && _) || + (_ && l4 && _ && _ && !(m3) && _ && r3 && _) || + (_ && !(l4) && l6 && _ && _ && _ && _ && !(r5)) || + (!(l0) && _ && _ && !(m1) && m3 && _ && _ && _) || + (!(l0) && _ && _ && _ && _ && _ && r3 && !(r5)) ; } static bool espresso_implementation_xx_alt1(uint8_t idx) { // output_XX = (!l6&m1&!r0) | (l4&!m3&r3) | (!l4&l6&!r5) | (!l0&!m1&m3) | (!l0&r3&!r5); @@ -462,11 +462,11 @@ static bool espresso_implementation_xx_alt1(uint8_t idx) { bool r3 = t.r3; bool r5 = t.r5; return - ( _ && _ && !(l6) && m1 && _ && !(r0) && _ && _ ) || - ( _ && l4 && _ && _ && !(m3) && _ && r3 && _ ) || - ( _ && !(l4) && l6 && _ && _ && _ && _ && !(r5) ) || - ( !(l0) && _ && _ && !(m1) && m3 && _ && _ && _ ) || - ( !(l0) && _ && _ && _ && _ && _ && r3 && !(r5) ) ; + (_ && _ && !(l6) && m1 && _ && !(r0) && _ && _) || + (_ && l4 && _ && _ && !(m3) && _ && r3 && _) || + (_ && !(l4) && l6 && _ && _ && _ && _ && !(r5)) || + (!(l0) && _ && _ && !(m1) && m3 && _ && _ && _) || + (!(l0) && _ && _ && _ && _ && _ && r3 && !(r5)) ; } static const lookuptable_func_t alt_for_xx[] = { @@ -478,10 +478,10 @@ static const lookuptable_func_t alt_for_xx[] = { typedef struct _VERIFICATION_T { uint8_t const input_count; - char const * const * names; - char const * const output_name; - uint8_t const * lut_start; - lookuptable_func_t const * const altFns; + char const *const *names; + char const *const output_name; + uint8_t const *lut_start; + lookuptable_func_t const *const altFns; size_t const altFnCount; } VERIFICATION_T; @@ -491,7 +491,7 @@ VERIFICATION_T const verification_table[] = { { .input_count = 5, .names = LUT_PLA_NAMES_g2, .output_name = "g2", .lut_start = small_lut_group2, .altFns = alt_for_g2, .altFnCount = ARRAY_SIZE2(alt_for_g2) }, { .input_count = 5, .names = LUT_PLA_NAMES_g3, .output_name = "g3", .lut_start = small_lut_group3, .altFns = alt_for_g3, .altFnCount = ARRAY_SIZE2(alt_for_g3) }, { .input_count = 5, .names = LUT_PLA_NAMES_g4, .output_name = "g4", .lut_start = small_lut_group4, .altFns = alt_for_g4, .altFnCount = ARRAY_SIZE2(alt_for_g4) }, - { .input_count = 8, .names = LUT_PLA_NAMES_XX, .output_name = "xx", .lut_start = small_lut_XX , .altFns = alt_for_xx, .altFnCount = ARRAY_SIZE2(alt_for_xx) }, + { .input_count = 8, .names = LUT_PLA_NAMES_XX, .output_name = "xx", .lut_start = small_lut_XX, .altFns = alt_for_xx, .altFnCount = ARRAY_SIZE2(alt_for_xx) }, }; @@ -499,84 +499,83 @@ static bool espresso_implementation_g1(bool a, bool l0, bool l2, bool l3, bool // output_g1 = (a&l2&l0&!l6) | (a&l3&!l0&l6) | (!a&!l2&!l3) | (!l2&!l3&!l0&!l6) | (l2&l3&!l0&!l6) | (!a&!l2&l0&!l6) | (!a&!l3&!l0&l6) | (a&l2&!l3&l0) | (a&!l2&l3&l6) | (!a&l2&l3&l0&l6); static const bool _ = true; return - ( a && l0 && l2 && _ && !(l6) ) | - ( a && !(l0) && _ && l3 && l6 ) | - ( !(a) && _ && !(l2) && !(l3) && _ ) | - ( _ && !(l0) && !(l2) && !(l3) && !(l6) ) | - ( _ && !(l0) && l2 && l3 && !(l6) ) | - ( !(a) && l0 && !(l2) && _ && !(l6) ) | - ( !(a) && !(l0) && _ && !(l3) && l6 ) | - ( a && l0 && l2 && !(l3) && _ ) | - ( a && _ && !(l2) && l3 && l6 ) | - ( !(a) && l0 && l2 && l3 && l6 ) ; + (a && l0 && l2 && _ && !(l6)) | + (a && !(l0) && _ && l3 && l6) | + (!(a) && _ && !(l2) && !(l3) && _) | + (_ && !(l0) && !(l2) && !(l3) && !(l6)) | + (_ && !(l0) && l2 && l3 && !(l6)) | + (!(a) && l0 && !(l2) && _ && !(l6)) | + (!(a) && !(l0) && _ && !(l3) && l6) | + (a && l0 && l2 && !(l3) && _) | + (a && _ && !(l2) && l3 && l6) | + (!(a) && l0 && l2 && l3 && l6) ; } static bool espresso_implementation_g2(bool b, bool l4, bool l5, bool m0, bool m1) { // output_g2 = (b&m0&!l4&!m1) | (l5&b&l4&m1) | (!l5&!b&!m0) | (!b&!m0&!l4&!m1) | (l5&b&!m0&l4) | (l5&!b&m0&l4&!m1) | (!l5&b&m0&!m1) | (!l5&!m0&!l4&m1) | (l5&m0&!l4&m1) | (!l5&!b&l4&m1); static const bool _ = true; - return - ( _ && b && m0 && !(l4) && !(m1) ) | - ( l5 && b && _ && l4 && m1 ) | - ( !(l5) && !(b) && !(m0) && _ && _ ) | - ( _ && !(b) && !(m0) && !(l4) && !(m1) ) | - ( l5 && b && !(m0) && l4 && _ ) | - ( l5 && !(b) && m0 && l4 && !(m1) ) | - ( !(l5) && b && m0 && _ && !(m1) ) | - ( !(l5) && _ && !(m0) && !(l4) && m1 ) | - ( l5 && _ && m0 && !(l4) && m1 ) | - ( !(l5) && !(b) && _ && l4 && m1 ) ; + return + (_ && b && m0 && !(l4) && !(m1)) | + (l5 && b && _ && l4 && m1) | + (!(l5) && !(b) && !(m0) && _ && _) | + (_ && !(b) && !(m0) && !(l4) && !(m1)) | + (l5 && b && !(m0) && l4 && _) | + (l5 && !(b) && m0 && l4 && !(m1)) | + (!(l5) && b && m0 && _ && !(m1)) | + (!(l5) && _ && !(m0) && !(l4) && m1) | + (l5 && _ && m0 && !(l4) && m1) | + (!(l5) && !(b) && _ && l4 && m1) ; } static bool espresso_implementation_g3(bool c, bool r1, bool r3, bool m3, bool m5) { // output_g3 = (c&r1&!m3&!r3) | (m5&c&m3&r3) | (!m5&!c&!r1) | (!c&!r1&!m3&!r3) | (!m5&!r1&m3&!r3) | (m5&r1&m3&!r3) | (m5&c&!r1&r3) | (m5&!c&r1&!m3&r3) | (!m5&c&r1&!m3) | (!m5&!c&m3&r3); static const bool _ = true; return - ( _ && c && r1 && !(m3) && !(r3) ) | - ( m5 && c && _ && m3 && r3 ) | - ( !(m5) && !(c) && !(r1) && _ && _ ) | - ( _ && !(c) && !(r1) && !(m3) && !(r3) ) | - ( !(m5) && _ && !(r1) && m3 && !(r3) ) | - ( m5 && _ && r1 && m3 && !(r3) ) | - ( m5 && c && !(r1) && _ && r3 ) | - ( m5 && !(c) && r1 && !(m3) && r3 ) | - ( !(m5) && c && r1 && !(m3) && _ ) | - ( !(m5) && !(c) && _ && m3 && r3 ) ; + (_ && c && r1 && !(m3) && !(r3)) | + (m5 && c && _ && m3 && r3) | + (!(m5) && !(c) && !(r1) && _ && _) | + (_ && !(c) && !(r1) && !(m3) && !(r3)) | + (!(m5) && _ && !(r1) && m3 && !(r3)) | + (m5 && _ && r1 && m3 && !(r3)) | + (m5 && c && !(r1) && _ && r3) | + (m5 && !(c) && r1 && !(m3) && r3) | + (!(m5) && c && r1 && !(m3) && _) | + (!(m5) && !(c) && _ && m3 && r3) ; } static bool espresso_implementation_g4(bool r0, bool r2, bool r4, bool r5, bool r6) { // output_g4 = (r2&r6&r0&!r5) | (r4&r6&!r0&r5) | (!r2&!r4&!r6) | (r2&r4&!r6&!r0&!r5) | (r2&!r4&r6&!r5) | (!r2&r4&r6&!r0) | (!r2&!r6&r0&!r5) | (!r4&!r6&!r0&r5) | (r2&r4&r0&r5) | (!r2&!r4&r0&r5); static const bool _ = true; return - ( r2 && _ && r6 && r0 && !(r5) ) | - ( _ && r4 && r6 && !(r0) && r5 ) | - ( !(r2) && !(r4) && !(r6) && _ && _ ) | - ( r2 && r4 && !(r6) && !(r0) && !(r5) ) | - ( r2 && !(r4) && r6 && _ && !(r5) ) | - ( !(r2) && r4 && r6 && !(r0) && _ ) | - ( !(r2) && _ && !(r6) && r0 && !(r5) ) | - ( _ && !(r4) && !(r6) && !(r0) && r5 ) | - ( r2 && r4 && _ && r0 && r5 ) | - ( !(r2) && !(r4) && _ && r0 && r5 ) ; + (r2 && _ && r6 && r0 && !(r5)) | + (_ && r4 && r6 && !(r0) && r5) | + (!(r2) && !(r4) && !(r6) && _ && _) | + (r2 && r4 && !(r6) && !(r0) && !(r5)) | + (r2 && !(r4) && r6 && _ && !(r5)) | + (!(r2) && r4 && r6 && !(r0) && _) | + (!(r2) && _ && !(r6) && r0 && !(r5)) | + (_ && !(r4) && !(r6) && !(r0) && r5) | + (r2 && r4 && _ && r0 && r5) | + (!(r2) && !(r4) && _ && r0 && r5) ; } static bool espresso_implementation_XX(bool l0, bool l4, bool l6, bool m1, bool m3, bool r0, bool r3, bool r5) { // output_XX = (!l6&m1&!r0) | (l4&!m3&r3) | (!l4&l6&!r5) | (!l0&!m1&m3) | (!l0&r3&!r5); static const bool _ = true; return - ( _ && _ && !(l6) && m1 && _ && !(r0) && _ && _ ) | - ( _ && l4 && _ && _ && !(m3) && _ && r3 && _ ) | - ( _ && !(l4) && l6 && _ && _ && _ && _ && !(r5) ) | - ( !(l0) && _ && _ && !(m1) && m3 && _ && _ && _ ) | - ( !(l0) && _ && _ && _ && _ && _ && r3 && !(r5) ); + (_ && _ && !(l6) && m1 && _ && !(r0) && _ && _) | + (_ && l4 && _ && _ && !(m3) && _ && r3 && _) | + (_ && !(l4) && l6 && _ && _ && _ && _ && !(r5)) | + (!(l0) && _ && _ && !(m1) && m3 && _ && _ && _) | + (!(l0) && _ && _ && _ && _ && _ && r3 && !(r5)); } -static bool verify_alternatives(void) -{ +static bool verify_alternatives(void) { bool any_failures_overall = false; for (uint16_t q = 0; q < ARRAY_SIZE2(verification_table); ++q) { bool any_failures_this_table = false; VERIFICATION_T const * vt = &verification_table[q]; - const char* fstr = vt->output_name; + const char *fstr = vt->output_name; uint16_t limit = 1u << vt->input_count; - for (uint16_t fn_idx = 0; fn_idx < vt->altFnCount; ++fn_idx ) { + for (uint16_t fn_idx = 0; fn_idx < vt->altFnCount; ++fn_idx) { bool any_failures_this_table_alts = false; const lookuptable_func_t fn = vt->altFns[fn_idx]; @@ -608,7 +607,7 @@ static bool verify_alternatives(void) } else { printf("SUCCESS ---------> All alternate for %s \n", fstr); } - + any_failures_overall |= any_failures_this_table; } @@ -620,9 +619,8 @@ static bool verify_alternatives(void) return !any_failures_overall; } -static bool verify_lut_g1(void) -{ - static const char* fstr = "verify_lut_g1"; +static bool verify_lut_g1(void) { + static const char *fstr = "verify_lut_g1"; bool any_failures = false; for (uint8_t i = 0; i < 32; ++i) { INDEX_G1 t = { .as_uint8_t = i }; @@ -640,13 +638,12 @@ static bool verify_lut_g1(void) } return !any_failures; } -static bool verify_lut_g2(void) -{ - static const char* fstr = "verify_lut_g2"; +static bool verify_lut_g2(void) { + static const char *fstr = "verify_lut_g2"; bool any_failures = false; for (uint8_t i = 0; i < 32; ++i) { INDEX_G2 t = { .as_uint8_t = i }; - bool lut_result = get_bit(small_lut_group2, i); + bool lut_result = get_bit(small_lut_group2, i); bool other_result = espresso_implementation_g2(t.b, t.l4, t.l5, t.m0, t.m1); if (lut_result != other_result) { printf("%s: verification failed for index %d\n", fstr, t.as_uint8_t); @@ -660,9 +657,8 @@ static bool verify_lut_g2(void) } return !any_failures; } -static bool verify_lut_g3(void) -{ - static const char* fstr = "verify_lut_g3"; +static bool verify_lut_g3(void) { + static const char *fstr = "verify_lut_g3"; bool any_failures = false; for (uint8_t i = 0; i < 32; ++i) { INDEX_G3 t = { .as_uint8_t = i }; @@ -680,9 +676,8 @@ static bool verify_lut_g3(void) } return !any_failures; } -static bool verify_lut_g4(void) -{ - static const char* fstr = "verify_lut_g4"; +static bool verify_lut_g4(void) { + static const char *fstr = "verify_lut_g4"; bool any_failures = false; for (uint8_t i = 0; i < 32; ++i) { INDEX_G4 t = { .as_uint8_t = i }; @@ -700,9 +695,8 @@ static bool verify_lut_g4(void) } return !any_failures; } -static bool verify_lut_XX(void) -{ - static const char* fstr = "verify_lut_XX"; +static bool verify_lut_XX(void) { + static const char *fstr = "verify_lut_XX"; bool any_failures = false; for (uint16_t ix = 0; ix < 256; ++ix) { uint8_t i = (uint8_t)ix; @@ -737,7 +731,7 @@ static bool generate_espresso_file(uint8_t input_count, const char * const * inp const uint16_t iterations = 1u << input_count; fprintf(f_output, ".ilb"); for (uint16_t i = 0; i < input_count; ++i) { - const char* name = input_names[i]; + const char *name = input_names[i]; fprintf(f_output, " %s", name); } fprintf(f_output, "\n"); @@ -761,8 +755,7 @@ static bool generate_espresso_file(uint8_t input_count, const char * const * inp return true; } -bool generate_all_lut_espresso_files(void) -{ +bool generate_all_lut_espresso_files(void) { bool any_failures = false; @@ -784,12 +777,12 @@ bool generate_all_lut_espresso_files(void) } if (file != NULL) { current_result = generate_espresso_file( - args->input_count, - args->names, - args->output_name, - args->lut_start, - file - ); + args->input_count, + args->names, + args->output_name, + args->lut_start, + file + ); if (!current_result) { printf("Failed to generate espresso file for %s\n", args->output_name); } @@ -803,8 +796,7 @@ bool generate_all_lut_espresso_files(void) return !any_failures; } -bool verify_espresso_results(void) -{ +bool verify_espresso_results(void) { //generate_all_lut_espresso_files(); bool unused = verify_alternatives(); diff --git a/client/deps/id48/tests/generator/array_size2.h b/client/deps/id48/tests/generator/array_size2.h index 2f9a18e38..951223d3b 100644 --- a/client/deps/id48/tests/generator/array_size2.h +++ b/client/deps/id48/tests/generator/array_size2.h @@ -45,27 +45,25 @@ SOFTWARE. */ #ifndef __has_feature - #define __has_feature(x) 0 /* Compatibility with non-clang compilers. */ +#define __has_feature(x) 0 /* Compatibility with non-clang compilers. */ #endif #if (defined(__cplusplus) && __cplusplus >= 201103L) || /* any compiler claiming C++11 support */ \ (defined(__cplusplus) && _MSC_VER >= 1900 && __cplusplus != 199711L) || /* Visual C++ 2015 or higher */ \ __has_feature(cxx_constexpr) /* CLang versions supporting constexp */ - #include /* required for size_t */ - #if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) - #pragma message( "ARRAY_SIZE2 -- Using C++11 version" ) - #endif +#include /* required for size_t */ +#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) +#pragma message( "ARRAY_SIZE2 -- Using C++11 version" ) +#endif - namespace detail - { - template - constexpr size_t ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(T const (&)[N]) noexcept - { - return N; - } - } /* namespace detail */ - #define ARRAY_SIZE2(arr) detail::ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(arr) +namespace detail { +template +constexpr size_t ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(T const(&)[N]) noexcept { + return N; +} +} /* namespace detail */ +#define ARRAY_SIZE2(arr) detail::ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(arr) #elif defined(__cplusplus) && __cplusplus >= 199711L && ( /* C++ 98 trick */ \ defined(__INTEL_COMPILER) || \ @@ -75,81 +73,81 @@ SOFTWARE. (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ ))) - #include /* required for size_t */ - #if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) - #pragma message "ARRAY_SIZE2 -- Using C++98 version" - #endif - template - char(&_ArraySizeHelperRequiresArray(T(&)[N]))[N]; - #define ARRAY_SIZE2(x) sizeof(_ArraySizeHelperRequiresArray(x)) +#include /* required for size_t */ +#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) +#pragma message "ARRAY_SIZE2 -- Using C++98 version" +#endif +template +char(&_ArraySizeHelperRequiresArray(T(&)[N]))[N]; +#define ARRAY_SIZE2(x) sizeof(_ArraySizeHelperRequiresArray(x)) #elif defined(__cplusplus) /* && ((__cplusplus >= 199711L) || defined(__INTEL_COMPILER) || defined(__clang__)) */ - - #if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) - #pragma message( "ARRAY_SIZE2 -- Using Ivan J. Johnson's C++ version" ) - #endif - /* - Works on older compilers, even Visual C++ 6.... - Created by Ivan J. Johnson, March 06, 2007 - See http://drdobbs.com/cpp/197800525?pgno=1 - Full description is in markdown file array_size2.md - */ - #define ARRAY_SIZE2(arr) ( \ +#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) +#pragma message( "ARRAY_SIZE2 -- Using Ivan J. Johnson's C++ version" ) +#endif +/* + Works on older compilers, even Visual C++ 6.... + Created by Ivan J. Johnson, March 06, 2007 + See http://drdobbs.com/cpp/197800525?pgno=1 + + Full description is in markdown file array_size2.md +*/ +#define ARRAY_SIZE2(arr) ( \ 0 * sizeof(reinterpret_cast(arr)) + /*check1*/ \ 0 * sizeof(::Bad_arg_to_ARRAY_SIZE2::check_type((arr), &(arr))) + /*check2*/ \ sizeof(arr) / sizeof((arr)[0]) /* eval */ \ ) - struct Bad_arg_to_ARRAY_SIZE2 { - class Is_pointer; /* incomplete */ - class Is_array {}; - template - static Is_pointer check_type(T const *, T const * const *); - static Is_array check_type(void const *, void const *); - }; +struct Bad_arg_to_ARRAY_SIZE2 { + class Is_pointer; /* incomplete */ + class Is_array {}; + template + static Is_pointer check_type(T const *, T const * const *); + static Is_array check_type(void const *, void const *); +}; #elif !defined(__cplusplus) && defined(__GNUC__) - #include +#include - /** - Even C can have type-safety for equivalent of ARRAY_SIZE() macro, - when using the following two GCC extensions: - typeof() - __builtin_types_compatible_p() - */ +/** + Even C can have type-safety for equivalent of ARRAY_SIZE() macro, + when using the following two GCC extensions: + typeof() + __builtin_types_compatible_p() +*/ - #if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) - #pragma message( "ARRAY_SIZE2 -- Using GNUC version" ) - #endif +#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) +#pragma message( "ARRAY_SIZE2 -- Using GNUC version" ) +#endif - /** - validated using: - MSP430 gcc 4.5.3 - x86-64 icc 16.0.3 - x86-64 gcc 4.1.2 - x86-64 clang 3.0.0 - AVR gcc 4.5.4 - ARM gcc 4.5.4 - */ +/** + validated using: + MSP430 gcc 4.5.3 + x86-64 icc 16.0.3 + x86-64 gcc 4.1.2 + x86-64 clang 3.0.0 + AVR gcc 4.5.4 + ARM gcc 4.5.4 +*/ - #define __SIMPLEHACKS_COMPATIBLE_TYPES__(a,b) __builtin_types_compatible_p(__typeof__(a), __typeof__(b)) /* GCC extensions */ - #define __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(x) (sizeof(struct { uint8_t q: (-!!(x)*0x1ee7)+1u;})-1u) /* if x is zero, reports "error: negative width in bit-field ''" */ - #define __SIMPLEHACKS_MUST_BE_ARRAY__(x) __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(__SIMPLEHACKS_COMPATIBLE_TYPES__((x), &(*x))) - #define ARRAY_SIZE2(_arr) ( (sizeof(_arr) / sizeof((_arr)[0])) + __SIMPLEHACKS_MUST_BE_ARRAY__(_arr) ) /* compile-time error if not an array */ +#define __SIMPLEHACKS_COMPATIBLE_TYPES__(a,b) __builtin_types_compatible_p(__typeof__(a), __typeof__(b)) /* GCC extensions */ +#define __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(x) (sizeof(struct { uint8_t q: (-!!(x)*0x1ee7)+1u;})-1u) /* if x is zero, reports "error: negative width in bit-field ''" */ +#define __SIMPLEHACKS_MUST_BE_ARRAY__(x) __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(__SIMPLEHACKS_COMPATIBLE_TYPES__((x), &(*x))) +#define ARRAY_SIZE2(_arr) ( (sizeof(_arr) / sizeof((_arr)[0])) + __SIMPLEHACKS_MUST_BE_ARRAY__(_arr) ) /* compile-time error if not an array */ #else - /** - The good news is that all compilers (as of 20202-05-08) - on godbolt.org are fully supported. Therefore, if some - other compiler does not support any of the above method, - it's important to force a compile-time error, to avoid - any suggestion that this provides a safe macro. - */ - - #error "Unable to provide type-safe ARRAY_SIZE2 macro" +/** + The good news is that all compilers (as of 20202-05-08) + on godbolt.org are fully supported. Therefore, if some + other compiler does not support any of the above method, + it's important to force a compile-time error, to avoid + any suggestion that this provides a safe macro. +*/ + +#error "Unable to provide type-safe ARRAY_SIZE2 macro" #endif diff --git a/client/deps/id48/tests/recovery/array_size2.h b/client/deps/id48/tests/recovery/array_size2.h index 2f9a18e38..951223d3b 100644 --- a/client/deps/id48/tests/recovery/array_size2.h +++ b/client/deps/id48/tests/recovery/array_size2.h @@ -45,27 +45,25 @@ SOFTWARE. */ #ifndef __has_feature - #define __has_feature(x) 0 /* Compatibility with non-clang compilers. */ +#define __has_feature(x) 0 /* Compatibility with non-clang compilers. */ #endif #if (defined(__cplusplus) && __cplusplus >= 201103L) || /* any compiler claiming C++11 support */ \ (defined(__cplusplus) && _MSC_VER >= 1900 && __cplusplus != 199711L) || /* Visual C++ 2015 or higher */ \ __has_feature(cxx_constexpr) /* CLang versions supporting constexp */ - #include /* required for size_t */ - #if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) - #pragma message( "ARRAY_SIZE2 -- Using C++11 version" ) - #endif +#include /* required for size_t */ +#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) +#pragma message( "ARRAY_SIZE2 -- Using C++11 version" ) +#endif - namespace detail - { - template - constexpr size_t ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(T const (&)[N]) noexcept - { - return N; - } - } /* namespace detail */ - #define ARRAY_SIZE2(arr) detail::ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(arr) +namespace detail { +template +constexpr size_t ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(T const(&)[N]) noexcept { + return N; +} +} /* namespace detail */ +#define ARRAY_SIZE2(arr) detail::ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(arr) #elif defined(__cplusplus) && __cplusplus >= 199711L && ( /* C++ 98 trick */ \ defined(__INTEL_COMPILER) || \ @@ -75,81 +73,81 @@ SOFTWARE. (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ ))) - #include /* required for size_t */ - #if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) - #pragma message "ARRAY_SIZE2 -- Using C++98 version" - #endif - template - char(&_ArraySizeHelperRequiresArray(T(&)[N]))[N]; - #define ARRAY_SIZE2(x) sizeof(_ArraySizeHelperRequiresArray(x)) +#include /* required for size_t */ +#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) +#pragma message "ARRAY_SIZE2 -- Using C++98 version" +#endif +template +char(&_ArraySizeHelperRequiresArray(T(&)[N]))[N]; +#define ARRAY_SIZE2(x) sizeof(_ArraySizeHelperRequiresArray(x)) #elif defined(__cplusplus) /* && ((__cplusplus >= 199711L) || defined(__INTEL_COMPILER) || defined(__clang__)) */ - - #if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) - #pragma message( "ARRAY_SIZE2 -- Using Ivan J. Johnson's C++ version" ) - #endif - /* - Works on older compilers, even Visual C++ 6.... - Created by Ivan J. Johnson, March 06, 2007 - See http://drdobbs.com/cpp/197800525?pgno=1 - Full description is in markdown file array_size2.md - */ - #define ARRAY_SIZE2(arr) ( \ +#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) +#pragma message( "ARRAY_SIZE2 -- Using Ivan J. Johnson's C++ version" ) +#endif +/* + Works on older compilers, even Visual C++ 6.... + Created by Ivan J. Johnson, March 06, 2007 + See http://drdobbs.com/cpp/197800525?pgno=1 + + Full description is in markdown file array_size2.md +*/ +#define ARRAY_SIZE2(arr) ( \ 0 * sizeof(reinterpret_cast(arr)) + /*check1*/ \ 0 * sizeof(::Bad_arg_to_ARRAY_SIZE2::check_type((arr), &(arr))) + /*check2*/ \ sizeof(arr) / sizeof((arr)[0]) /* eval */ \ ) - struct Bad_arg_to_ARRAY_SIZE2 { - class Is_pointer; /* incomplete */ - class Is_array {}; - template - static Is_pointer check_type(T const *, T const * const *); - static Is_array check_type(void const *, void const *); - }; +struct Bad_arg_to_ARRAY_SIZE2 { + class Is_pointer; /* incomplete */ + class Is_array {}; + template + static Is_pointer check_type(T const *, T const * const *); + static Is_array check_type(void const *, void const *); +}; #elif !defined(__cplusplus) && defined(__GNUC__) - #include +#include - /** - Even C can have type-safety for equivalent of ARRAY_SIZE() macro, - when using the following two GCC extensions: - typeof() - __builtin_types_compatible_p() - */ +/** + Even C can have type-safety for equivalent of ARRAY_SIZE() macro, + when using the following two GCC extensions: + typeof() + __builtin_types_compatible_p() +*/ - #if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) - #pragma message( "ARRAY_SIZE2 -- Using GNUC version" ) - #endif +#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE) +#pragma message( "ARRAY_SIZE2 -- Using GNUC version" ) +#endif - /** - validated using: - MSP430 gcc 4.5.3 - x86-64 icc 16.0.3 - x86-64 gcc 4.1.2 - x86-64 clang 3.0.0 - AVR gcc 4.5.4 - ARM gcc 4.5.4 - */ +/** + validated using: + MSP430 gcc 4.5.3 + x86-64 icc 16.0.3 + x86-64 gcc 4.1.2 + x86-64 clang 3.0.0 + AVR gcc 4.5.4 + ARM gcc 4.5.4 +*/ - #define __SIMPLEHACKS_COMPATIBLE_TYPES__(a,b) __builtin_types_compatible_p(__typeof__(a), __typeof__(b)) /* GCC extensions */ - #define __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(x) (sizeof(struct { uint8_t q: (-!!(x)*0x1ee7)+1u;})-1u) /* if x is zero, reports "error: negative width in bit-field ''" */ - #define __SIMPLEHACKS_MUST_BE_ARRAY__(x) __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(__SIMPLEHACKS_COMPATIBLE_TYPES__((x), &(*x))) - #define ARRAY_SIZE2(_arr) ( (sizeof(_arr) / sizeof((_arr)[0])) + __SIMPLEHACKS_MUST_BE_ARRAY__(_arr) ) /* compile-time error if not an array */ +#define __SIMPLEHACKS_COMPATIBLE_TYPES__(a,b) __builtin_types_compatible_p(__typeof__(a), __typeof__(b)) /* GCC extensions */ +#define __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(x) (sizeof(struct { uint8_t q: (-!!(x)*0x1ee7)+1u;})-1u) /* if x is zero, reports "error: negative width in bit-field ''" */ +#define __SIMPLEHACKS_MUST_BE_ARRAY__(x) __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(__SIMPLEHACKS_COMPATIBLE_TYPES__((x), &(*x))) +#define ARRAY_SIZE2(_arr) ( (sizeof(_arr) / sizeof((_arr)[0])) + __SIMPLEHACKS_MUST_BE_ARRAY__(_arr) ) /* compile-time error if not an array */ #else - /** - The good news is that all compilers (as of 20202-05-08) - on godbolt.org are fully supported. Therefore, if some - other compiler does not support any of the above method, - it's important to force a compile-time error, to avoid - any suggestion that this provides a safe macro. - */ - - #error "Unable to provide type-safe ARRAY_SIZE2 macro" +/** + The good news is that all compilers (as of 20202-05-08) + on godbolt.org are fully supported. Therefore, if some + other compiler does not support any of the above method, + it's important to force a compile-time error, to avoid + any suggestion that this provides a safe macro. +*/ + +#error "Unable to provide type-safe ARRAY_SIZE2 macro" #endif diff --git a/client/deps/id48/tests/recovery/main.c b/client/deps/id48/tests/recovery/main.c index cdcba3157..b52b2e846 100644 --- a/client/deps/id48/tests/recovery/main.c +++ b/client/deps/id48/tests/recovery/main.c @@ -56,36 +56,36 @@ static const TEST_VECTOR_T test_vectors[] = { }; // Comment - /// - /// Initializes to allow iterative recovery - /// of multiple potential keys. After calling - /// this init() function, can repeatedly call - /// the next() function until it returns false - /// to obtain all potential keys. - /// - /// - /// Top 48 bits of the key, such as those discovered - /// using the proxmark3 command `lf em 4x70 brute`. - /// Only k[0..5] are used from this parameter, - /// corresponding to K₉₅..K₄₈. - /// - /// - /// The nonce value. - /// Typically from a sniffed authentication. - /// - /// - /// The challenge sent from the reader (e.g., car) - /// to the tag (e.g., key). - /// Typically from a sniffed authentication. - /// - /// - /// The response sent from the tag (e.g., key) - /// to the car (e.g., car). - /// Typically from a sniffed authentication. - /// - /// - /// Note: In C++, each parameter would be a reference (not pointer). - /// +/// +/// Initializes to allow iterative recovery +/// of multiple potential keys. After calling +/// this init() function, can repeatedly call +/// the next() function until it returns false +/// to obtain all potential keys. +/// +/// +/// Top 48 bits of the key, such as those discovered +/// using the proxmark3 command `lf em 4x70 brute`. +/// Only k[0..5] are used from this parameter, +/// corresponding to K₉₅..K₄₈. +/// +/// +/// The nonce value. +/// Typically from a sniffed authentication. +/// +/// +/// The challenge sent from the reader (e.g., car) +/// to the tag (e.g., key). +/// Typically from a sniffed authentication. +/// +/// +/// The response sent from the tag (e.g., key) +/// to the car (e.g., car). +/// Typically from a sniffed authentication. +/// +/// +/// Note: In C++, each parameter would be a reference (not pointer). +/// // void id48lib_key_recovery_init( // const ID48LIB_KEY *input_partial_key, @@ -95,30 +95,30 @@ static const TEST_VECTOR_T test_vectors[] = { // ); // Comment - /// - /// This can be repeated called (after calling init()) - /// to find the next potential key for the given - /// partial key + nonce + frn + grn values. - /// I've seen combinations that have up to six - /// potential keys available, although typically - /// there are 1-3 results. - /// Each call to this function will return a single - /// value. Call repeatedly until the function returns - /// false to get all potential keys. - /// - /// - /// When the function returns true, this caller-provided - /// value will be filled with the 96-bit key that, when - /// programmed to the tag, should authenticate against - /// the nonce+frn values, with tag returning the grn value. - /// - /// - /// true when another potential key has been found. - /// false if no additional potential keys have been found. - /// - /// - /// Note: In C++, each parameter would be a reference (not pointer). - /// +/// +/// This can be repeated called (after calling init()) +/// to find the next potential key for the given +/// partial key + nonce + frn + grn values. +/// I've seen combinations that have up to six +/// potential keys available, although typically +/// there are 1-3 results. +/// Each call to this function will return a single +/// value. Call repeatedly until the function returns +/// false to get all potential keys. +/// +/// +/// When the function returns true, this caller-provided +/// value will be filled with the 96-bit key that, when +/// programmed to the tag, should authenticate against +/// the nonce+frn values, with tag returning the grn value. +/// +/// +/// true when another potential key has been found. +/// false if no additional potential keys have been found. +/// +/// +/// Note: In C++, each parameter would be a reference (not pointer). +/// // bool id48lib_key_recovery_next( // ID48LIB_KEY *potential_key_output // ); @@ -144,7 +144,7 @@ bool recovery_succeeds(const TEST_VECTOR_T *test_vector, bool zero_partial_key) // just verify that the potential key matches the test vector if (bytes_equal(potential_key.k, test_vector->key.k, sizeof(test_vector->key.k))) { key_found = true; - } + } } return key_found; } diff --git a/client/deps/reveng/bmpbit.c b/client/deps/reveng/bmpbit.c index 522d71ecc..5c4464b41 100644 --- a/client/deps/reveng/bmpbit.c +++ b/client/deps/reveng/bmpbit.c @@ -73,10 +73,10 @@ main(int argc, char *argv[]) { setbmp(); if (BMP_BIT != bmpbit || BMP_SUB != bmpsub) { fprintf(stderr, "reveng: configuration fault. Update " - "reveng/config.h with these definitions and " - "recompile:\n" - "\t#define BMP_BIT %d\n" - "\t#define BMP_SUB %d\n", + "reveng/config.h with these definitions and " + "recompile:\n" + "\t#define BMP_BIT %d\n" + "\t#define BMP_SUB %d\n", bmpbit, bmpsub); exit(EXIT_FAILURE); } @@ -84,8 +84,8 @@ main(int argc, char *argv[]) { /* check the bitmap constant macro */ if (~(bmp_t) 0 != ~BMP_C(0)) { fprintf(stderr, "reveng: configuration fault. Edit " - "the definition of BMP_C() in config.h to " - "match BMP_T and recompile.\n"); + "the definition of BMP_C() in config.h to " + "match BMP_T and recompile.\n"); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); diff --git a/client/deps/reveng/preset.c b/client/deps/reveng/preset.c index 6f41ac9f5..1897ebcee 100644 --- a/client/deps/reveng/preset.c +++ b/client/deps/reveng/preset.c @@ -137,19 +137,19 @@ static const bmp_t b40c[] = { # else /* BMP_BIT */ static const bmp_t b40[] = { BMP_C(0x00048200) << (BMP_BIT - 32) | BMP_C(0x04) >> (39 - BMP_BIT), - BMP_C(0x09) << (BMP_BIT * 2 - 40), + BMP_C(0x09) << (BMP_BIT * 2 - 40), }; static const bmp_t b40a[] = { BMP_C(0xffffffff) << (BMP_BIT - 32) | BMP_C(0x7f) >> (39 - BMP_BIT), - BMP_C(0xff) << (BMP_BIT * 2 - 40), + BMP_C(0xff) << (BMP_BIT * 2 - 40), }; static const bmp_t b40b[] = { BMP_C(0xd4164fc6) << (BMP_BIT - 32) | BMP_C(0x23) >> (39 - BMP_BIT), - BMP_C(0x46) << (BMP_BIT * 2 - 40), + BMP_C(0x46) << (BMP_BIT * 2 - 40), }; static const bmp_t b40c[] = { BMP_C(0xc4ff8071) << (BMP_BIT - 32) | BMP_C(0x7f) >> (39 - BMP_BIT), - BMP_C(0xff) << (BMP_BIT * 2 - 40), + BMP_C(0xff) << (BMP_BIT * 2 - 40), }; # endif /* BMP_BIT */ @@ -187,43 +187,43 @@ static const bmp_t b64i[] = { # else /* BMP_BIT */ static const bmp_t b64[] = { BMP_C(0x00000000) << (BMP_BIT - 32) | BMP_C(0x0000000d) >> (63 - BMP_BIT), - BMP_C(0x0000001b) << (BMP_BIT * 2 - 64), + BMP_C(0x0000001b) << (BMP_BIT * 2 - 64), }; static const bmp_t b64a[] = { BMP_C(0xffffffff) << (BMP_BIT - 32) | BMP_C(0x7fffffff) >> (63 - BMP_BIT), - BMP_C(0xffffffff) << (BMP_BIT * 2 - 64), + BMP_C(0xffffffff) << (BMP_BIT * 2 - 64), }; static const bmp_t b64b[] = { BMP_C(0xb90956c7) << (BMP_BIT - 32) | BMP_C(0x3ad20800) >> (63 - BMP_BIT), - BMP_C(0x75a41001) << (BMP_BIT * 2 - 64), + BMP_C(0x75a41001) << (BMP_BIT * 2 - 64), }; static const bmp_t b64c[] = { BMP_C(0x53000000) << (BMP_BIT - 32) | BMP_C(0x00000000) >> (63 - BMP_BIT), - BMP_C(0x00000000) << (BMP_BIT * 2 - 64), + BMP_C(0x00000000) << (BMP_BIT * 2 - 64), }; static const bmp_t b64d[] = { BMP_C(0x42f0e1eb) << (BMP_BIT - 32) | BMP_C(0x54f51b49) >> (63 - BMP_BIT), - BMP_C(0xa9ea3693) << (BMP_BIT * 2 - 64), + BMP_C(0xa9ea3693) << (BMP_BIT * 2 - 64), }; static const bmp_t b64e[] = { BMP_C(0x6c40df5f) << (BMP_BIT - 32) | BMP_C(0x05a4b9a3) >> (63 - BMP_BIT), - BMP_C(0x0b497347) << (BMP_BIT * 2 - 64), + BMP_C(0x0b497347) << (BMP_BIT * 2 - 64), }; static const bmp_t b64f[] = { BMP_C(0x62ec59e3) << (BMP_BIT - 32) | BMP_C(0x78d27805) >> (63 - BMP_BIT), - BMP_C(0xf1a4f00a) << (BMP_BIT * 2 - 64), + BMP_C(0xf1a4f00a) << (BMP_BIT * 2 - 64), }; static const bmp_t b64g[] = { BMP_C(0xfcacbebd) << (BMP_BIT - 32) | BMP_C(0x2c98d4c9) >> (63 - BMP_BIT), - BMP_C(0x5931a992) << (BMP_BIT * 2 - 64), + BMP_C(0x5931a992) << (BMP_BIT * 2 - 64), }; static const bmp_t b64h[] = { BMP_C(0x995dc9bb) << (BMP_BIT - 32) | BMP_C(0x6f8c9cfd) >> (63 - BMP_BIT), - BMP_C(0xdf1939fa) << (BMP_BIT * 2 - 64), + BMP_C(0xdf1939fa) << (BMP_BIT * 2 - 64), }; static const bmp_t b64i[] = { BMP_C(0x49958c9a) << (BMP_BIT - 32) | BMP_C(0x5ebe9a9f) >> (63 - BMP_BIT), - BMP_C(0xbd7d353f) << (BMP_BIT * 2 - 64), + BMP_C(0xbd7d353f) << (BMP_BIT * 2 - 64), }; # endif /* BMP_BIT */ @@ -237,22 +237,22 @@ static const bmp_t b82a[] = { # elif BMP_BIT >= 41 static const bmp_t b82[] = { BMP_C(0x01846008880) << (BMP_BIT - 41) | BMP_C(0x08a00a20208) >> (81 - BMP_BIT), - BMP_C(0x11401440411) << (BMP_BIT * 2 - 82), + BMP_C(0x11401440411) << (BMP_BIT * 2 - 82), }; static const bmp_t b82a[] = { BMP_C(0x04f541fb128) << (BMP_BIT - 41) | BMP_C(0x011c00feb09) >> (81 - BMP_BIT), - BMP_C(0x023801fd612) << (BMP_BIT * 2 - 82), + BMP_C(0x023801fd612) << (BMP_BIT * 2 - 82), }; # else /* BMP_BIT */ static const bmp_t b82[] = { BMP_C(0x0c230044) << (BMP_BIT - 32) | BMP_C(0x040) >> (40 - BMP_BIT), - BMP_C(0x40450051) << (BMP_BIT * 2 - 64) | BMP_C(0x00104) >> (80 - BMP_BIT * 2), - BMP_C(0x00411) << (BMP_BIT * 3 - 82), + BMP_C(0x40450051) << (BMP_BIT * 2 - 64) | BMP_C(0x00104) >> (80 - BMP_BIT * 2), + BMP_C(0x00411) << (BMP_BIT * 3 - 82), }; static const bmp_t b82a[] = { BMP_C(0x27aa0fd8) << (BMP_BIT - 32) | BMP_C(0x094) >> (40 - BMP_BIT), - BMP_C(0x9408e007) << (BMP_BIT * 2 - 64) | BMP_C(0x0f584) >> (80 - BMP_BIT * 2), - BMP_C(0x3d612) << (BMP_BIT * 3 - 82), + BMP_C(0x9408e007) << (BMP_BIT * 2 - 64) | BMP_C(0x0f584) >> (80 - BMP_BIT * 2), + BMP_C(0x3d612) << (BMP_BIT * 3 - 82), }; # endif /* BMP_BIT */ @@ -262,215 +262,215 @@ static const bmp_t b82a[] = { /* Array of the polynomial bitmaps used in the model table. */ static const bmp_t b32[] = { BMP_C(0x000000af) << (BMP_BIT - 32), /* 0 -- 32,000000af */ - BMP_C(0x00010000) << (BMP_BIT - 32), /* 1 -- 16, 0001 */ - BMP_C(0x00020000) << (BMP_BIT - 32), /* 2 -- 15, 0001 */ - BMP_C(0x00065b00) << (BMP_BIT - 32), /* 3 -- 24, 00065b */ - BMP_C(0x007e0000) << (BMP_BIT - 32), /* 4 -- 16, 007e */ - BMP_C(0x007f0000) << (BMP_BIT - 32), /* 5 -- 16, 007f */ - BMP_C(0x03400000) << (BMP_BIT - 32), /* 6 -- 11, 01a */ - BMP_C(0x0376e6e7) << (BMP_BIT - 32), /* 7 -- 32,0376e6e7 */ - BMP_C(0x04c11db7) << (BMP_BIT - 32), /* 8 -- 32,04c11db7 */ - BMP_C(0x05890000) << (BMP_BIT - 32), /* 9 -- 16, 0589 */ - BMP_C(0x07000000) << (BMP_BIT - 32), /* 10 -- 8, 07 */ - BMP_C(0x080b0000) << (BMP_BIT - 32), /* 11 -- 16, 080b */ - BMP_C(0x09823b6e) << (BMP_BIT - 32), /* 12 -- 31,04c11db7 */ - BMP_C(0x0b3c0000) << (BMP_BIT - 32), /* 13 -- 15, 059e */ - BMP_C(0x0c000000) << (BMP_BIT - 32), /* 14 -- 6, 03 */ - BMP_C(0x0c200000) << (BMP_BIT - 32), /* 15 -- 11, 061 */ - BMP_C(0x0c780000) << (BMP_BIT - 32), /* 16 -- 14, 031e */ - BMP_C(0x0fb30000) << (BMP_BIT - 32), /* 17 -- 16, 0fb3 */ - BMP_C(0x10210000) << (BMP_BIT - 32), /* 18 -- 16, 1021 */ - BMP_C(0x12000000) << (BMP_BIT - 32), /* 19 -- 7, 09 */ - BMP_C(0x130d2afc) << (BMP_BIT - 32), /* 20 -- 30,04c34abf */ - BMP_C(0x144e6300) << (BMP_BIT - 32), /* 21 -- 24, 144e63 */ - BMP_C(0x15000000) << (BMP_BIT - 32), /* 22 -- 8, 15 */ - BMP_C(0x1697d06a) << (BMP_BIT - 32), /* 23 -- 32,1697d06a */ - BMP_C(0x17800000) << (BMP_BIT - 32), /* 24 -- 12, 178 */ - BMP_C(0x18000000) << (BMP_BIT - 32), /* 25 -- 6, 06 */ - BMP_C(0x19d3c8d8) << (BMP_BIT - 32), /* 26 -- 31,0ce9e46c */ - BMP_C(0x1c000000) << (BMP_BIT - 32), /* 27 -- 6, 07 */ - BMP_C(0x1d000000) << (BMP_BIT - 32), /* 28 -- 8, 1d */ - BMP_C(0x1d0f0000) << (BMP_BIT - 32), /* 29 -- 16, 1d0f */ - BMP_C(0x1dcf0000) << (BMP_BIT - 32), /* 30 -- 16, 1dcf */ - BMP_C(0x1edc6f41) << (BMP_BIT - 32), /* 31 -- 32,1edc6f41 */ - BMP_C(0x1f23b800) << (BMP_BIT - 32), /* 32 -- 24, 1f23b8 */ - BMP_C(0x20000000) << (BMP_BIT - 32), /* 33 -- 4, 2 */ - BMP_C(0x200fa500) << (BMP_BIT - 32), /* 34 -- 24, 200fa5 */ - BMP_C(0x20140000) << (BMP_BIT - 32), /* 35 -- 14, 0805 */ - BMP_C(0x20b40000) << (BMP_BIT - 32), /* 36 -- 14, 082d */ - BMP_C(0x20fe0000) << (BMP_BIT - 32), /* 37 -- 16, 20fe */ - BMP_C(0x21890000) << (BMP_BIT - 32), /* 38 -- 16, 2189 */ - BMP_C(0x21cf0200) << (BMP_BIT - 32), /* 39 -- 24, 21cf02 */ - BMP_C(0x23ef5200) << (BMP_BIT - 32), /* 40 -- 24, 23ef52 */ - BMP_C(0x25000000) << (BMP_BIT - 32), /* 41 -- 8, 25 */ - BMP_C(0x26000000) << (BMP_BIT - 32), /* 42 -- 8, 26 */ - BMP_C(0x26b10000) << (BMP_BIT - 32), /* 43 -- 16, 26b1 */ - BMP_C(0x27818000) << (BMP_BIT - 32), /* 44 -- 17, 04f03 */ - BMP_C(0x27d00000) << (BMP_BIT - 32), /* 45 -- 13, 04fa */ - BMP_C(0x28000000) << (BMP_BIT - 32), /* 46 -- 5, 05 */ - BMP_C(0x29b10000) << (BMP_BIT - 32), /* 47 -- 16, 29b1 */ - BMP_C(0x2f000000) << (BMP_BIT - 32), /* 48 -- 8, 2f */ - BMP_C(0x30000000) << (BMP_BIT - 32), /* 49 -- 4, 3/ 5, 6 */ - BMP_C(0x3010bf7f) << (BMP_BIT - 32), /* 50 -- 32,3010bf7f */ - BMP_C(0x31000000) << (BMP_BIT - 32), /* 51 -- 8, 31 */ - BMP_C(0x31800000) << (BMP_BIT - 32), /* 52 -- 10, 0c6 */ - BMP_C(0x31c30000) << (BMP_BIT - 32), /* 53 -- 16, 31c3 */ - BMP_C(0x328b6300) << (BMP_BIT - 32), /* 54 -- 24, 328b63 */ - BMP_C(0x34000000) << (BMP_BIT - 32), /* 55 -- 6, 0d */ - BMP_C(0x340bc6d9) << (BMP_BIT - 32), /* 56 -- 32,340bc6d9 */ - BMP_C(0x37000000) << (BMP_BIT - 32), /* 57 -- 8, 37 */ - BMP_C(0x38000000) << (BMP_BIT - 32), /* 58 -- 5, 07 */ - BMP_C(0x39000000) << (BMP_BIT - 32), /* 59 -- 8, 39 */ - BMP_C(0x3d650000) << (BMP_BIT - 32), /* 60 -- 16, 3d65 */ - BMP_C(0x3e000000) << (BMP_BIT - 32), /* 61 -- 8, 3e */ - BMP_C(0x40000000) << (BMP_BIT - 32), /* 62 -- 3, 2 */ - BMP_C(0x42000000) << (BMP_BIT - 32), /* 63 -- 8, 42 */ - BMP_C(0x44c20000) << (BMP_BIT - 32), /* 64 -- 16, 44c2 */ - BMP_C(0x45270551) << (BMP_BIT - 32), /* 65 -- 32,45270551 */ - BMP_C(0x48000000) << (BMP_BIT - 32), /* 66 -- 5, 09 */ - BMP_C(0x49000000) << (BMP_BIT - 32), /* 67 -- 8, 49 */ - BMP_C(0x4a800000) << (BMP_BIT - 32), /* 68 -- 10, 12a */ - BMP_C(0x4acc0000) << (BMP_BIT - 32), /* 69 -- 15, 2566 */ - BMP_C(0x4b000000) << (BMP_BIT - 32), /* 70 -- 8, 4b */ - BMP_C(0x4b370000) << (BMP_BIT - 32), /* 71 -- 16, 4b37 */ - BMP_C(0x4c000000) << (BMP_BIT - 32), /* 72 -- 6, 13 */ - BMP_C(0x4c060000) << (BMP_BIT - 32), /* 73 -- 16, 4c06 */ - BMP_C(0x53000000) << (BMP_BIT - 32), /* 74 -- 8, 53 */ - BMP_C(0x55000000) << (BMP_BIT - 32), /* 75 -- 8, 55 */ - BMP_C(0x55555500) << (BMP_BIT - 32), /* 76 -- 24, 555555 */ - BMP_C(0x59350000) << (BMP_BIT - 32), /* 77 -- 16, 5935 */ - BMP_C(0x5d380000) << (BMP_BIT - 32), /* 78 -- 16, 5d38 */ - BMP_C(0x5d400000) << (BMP_BIT - 32), /* 79 -- 10, 175 */ - BMP_C(0x5d6dcb00) << (BMP_BIT - 32), /* 80 -- 24, 5d6dcb */ - BMP_C(0x60000000) << (BMP_BIT - 32), /* 81 -- 3, 3 */ - BMP_C(0x60e00000) << (BMP_BIT - 32), /* 82 -- 11, 307 */ - BMP_C(0x63d00000) << (BMP_BIT - 32), /* 83 -- 16, 63d0 */ - BMP_C(0x64000000) << (BMP_BIT - 32), /* 84 -- 6, 19 */ - BMP_C(0x66400000) << (BMP_BIT - 32), /* 85 -- 10, 199 */ - BMP_C(0x66c50000) << (BMP_BIT - 32), /* 86 -- 16, 66c5 */ - BMP_C(0x6f630000) << (BMP_BIT - 32), /* 87 -- 16, 6f63 */ - BMP_C(0x6f910000) << (BMP_BIT - 32), /* 88 -- 16, 6f91 */ - BMP_C(0x70000000) << (BMP_BIT - 32), /* 89 -- 4, 7 */ - BMP_C(0x70a00000) << (BMP_BIT - 32), /* 90 -- 11, 385 */ - BMP_C(0x755b0000) << (BMP_BIT - 32), /* 91 -- 16, 755b */ - BMP_C(0x765e7680) << (BMP_BIT - 32), /* 92 -- 32,765e7680 */ - BMP_C(0x76c20800) << (BMP_BIT - 32), /* 93 -- 32, 0ed841 */ - BMP_C(0x7979bd00) << (BMP_BIT - 32), /* 94 -- 24, 7979bd */ - BMP_C(0x7e000000) << (BMP_BIT - 32), /* 95 -- 8, 7e */ - BMP_C(0x80000000) << (BMP_BIT - 32), /* 96 -- 3, 4 */ - BMP_C(0x80006300) << (BMP_BIT - 32), /* 97 -- 24, 800063 */ - BMP_C(0x80050000) << (BMP_BIT - 32), /* 98 -- 16, 8005 */ - BMP_C(0x800d0000) << (BMP_BIT - 32), /* 99 -- 16, 800d */ - BMP_C(0x800fe300) << (BMP_BIT - 32), /* 100 -- 24, 800fe3 */ - BMP_C(0x80b40000) << (BMP_BIT - 32), /* 101 -- 14, 202d */ - BMP_C(0x80c2e71c) << (BMP_BIT - 32), /* 102 -- 30,2030b9c7 */ - BMP_C(0x80f00000) << (BMP_BIT - 32), /* 103 -- 12, 80f */ - BMP_C(0x814141ab) << (BMP_BIT - 32), /* 104 -- 32,814141ab */ - BMP_C(0x8144c800) << (BMP_BIT - 32), /* 105 -- 21, 102899 */ - BMP_C(0x864cfb00) << (BMP_BIT - 32), /* 106 -- 24, 864cfb */ - BMP_C(0x87315576) << (BMP_BIT - 32), /* 107 -- 32,87315576 */ - BMP_C(0x89ec0000) << (BMP_BIT - 32), /* 108 -- 16, 89ec */ - BMP_C(0x8a000000) << (BMP_BIT - 32), /* 109 -- 7, 45 */ - BMP_C(0x8b320000) << (BMP_BIT - 32), /* 110 -- 15, 4599 */ - BMP_C(0x8bb70000) << (BMP_BIT - 32), /* 111 -- 16, 8bb7 */ - BMP_C(0x8cc00000) << (BMP_BIT - 32), /* 112 -- 10, 233 */ - BMP_C(0x904cddbf) << (BMP_BIT - 32), /* 113 -- 32,904cddbf */ - BMP_C(0x906e0000) << (BMP_BIT - 32), /* 114 -- 16, 906e */ - BMP_C(0x94000000) << (BMP_BIT - 32), /* 115 -- 8, 94 */ - BMP_C(0x97000000) << (BMP_BIT - 32), /* 116 -- 8, 97 */ - BMP_C(0x98000000) << (BMP_BIT - 32), /* 117 -- 6, 26 */ - BMP_C(0x99000000) << (BMP_BIT - 32), /* 118 -- 8, 99 */ - BMP_C(0x9b000000) << (BMP_BIT - 32), /* 119 -- 8, 9b */ - BMP_C(0x9c000000) << (BMP_BIT - 32), /* 120 -- 6, 27 */ - BMP_C(0x9d5e4de2) << (BMP_BIT - 32), /* 121 -- 31,4eaf26f1 */ - BMP_C(0x9e000000) << (BMP_BIT - 32), /* 122 -- 7, 4f */ - BMP_C(0x9ecf0000) << (BMP_BIT - 32), /* 123 -- 16, 9ecf */ - BMP_C(0xa0660000) << (BMP_BIT - 32), /* 124 -- 16, a066 */ - BMP_C(0xa0970000) << (BMP_BIT - 32), /* 125 -- 16, a097 */ - BMP_C(0xa1000000) << (BMP_BIT - 32), /* 126 -- 8, a1 */ - BMP_C(0xa3660000) << (BMP_BIT - 32), /* 127 -- 16, a366 */ - BMP_C(0xa6000000) << (BMP_BIT - 32), /* 128 -- 7, 53 */ - BMP_C(0xa7000000) << (BMP_BIT - 32), /* 129 -- 8, a7 */ - BMP_C(0xa8000000) << (BMP_BIT - 32), /* 130 -- 5, 15 */ - BMP_C(0xa8190000) << (BMP_BIT - 32), /* 131 -- 16, a819 */ - BMP_C(0xa833982b) << (BMP_BIT - 32), /* 132 -- 32,a833982b */ - BMP_C(0xabcdef00) << (BMP_BIT - 32), /* 133 -- 24, abcdef */ - BMP_C(0xac000000) << (BMP_BIT - 32), /* 134 -- 8, ac */ - BMP_C(0xaee70000) << (BMP_BIT - 32), /* 135 -- 16, aee7 */ - BMP_C(0xb0000000) << (BMP_BIT - 32), /* 136 -- 4, b */ - BMP_C(0xb0010000) << (BMP_BIT - 32), /* 137 -- 16, b001 */ - BMP_C(0xb2aa0000) << (BMP_BIT - 32), /* 138 -- 16, b2aa */ - BMP_C(0xb3400000) << (BMP_BIT - 32), /* 139 -- 12, b34 */ - BMP_C(0xb42d8000) << (BMP_BIT - 32), /* 140 -- 17, 1685b */ - BMP_C(0xb4600000) << (BMP_BIT - 32), /* 141 -- 11, 5a3 */ - BMP_C(0xb4c80000) << (BMP_BIT - 32), /* 142 -- 16, b4c8 */ - BMP_C(0xb4f3e600) << (BMP_BIT - 32), /* 143 -- 24, b4f3e6 */ - BMP_C(0xb704ce00) << (BMP_BIT - 32), /* 144 -- 24, b704ce */ - BMP_C(0xb798b438) << (BMP_BIT - 32), /* 145 -- 32,b798b438 */ - BMP_C(0xbb3d0000) << (BMP_BIT - 32), /* 146 -- 16, bb3d */ - BMP_C(0xbc000000) << (BMP_BIT - 32), /* 147 -- 6,2f/ 8,bc */ - BMP_C(0xbd0be338) << (BMP_BIT - 32), /* 148 -- 32,bd0be338 */ - BMP_C(0xbdf40000) << (BMP_BIT - 32), /* 149 -- 16, bdf4 */ - BMP_C(0xbf050000) << (BMP_BIT - 32), /* 150 -- 16, bf05 */ - BMP_C(0xc0000000) << (BMP_BIT - 32), /* 151 -- 3, 6 */ - BMP_C(0xc2000000) << (BMP_BIT - 32), /* 152 -- 7, 61 */ - BMP_C(0xc25a5600) << (BMP_BIT - 32), /* 153 -- 24, c25a56 */ - BMP_C(0xc2b70000) << (BMP_BIT - 32), /* 154 -- 16, c2b7 */ - BMP_C(0xc2b80000) << (BMP_BIT - 32), /* 155 -- 14, 30ae */ - BMP_C(0xc4000000) << (BMP_BIT - 32), /* 156 -- 8, c4 */ - BMP_C(0xc6c60000) << (BMP_BIT - 32), /* 157 -- 16, c6c6 */ - BMP_C(0xc7000000) << (BMP_BIT - 32), /* 158 -- 8, c7 */ - BMP_C(0xc704dd7b) << (BMP_BIT - 32), /* 159 -- 32,c704dd7b */ - BMP_C(0xc8000000) << (BMP_BIT - 32), /* 160 -- 5, 19 */ - BMP_C(0xc8670000) << (BMP_BIT - 32), /* 161 -- 16, c867 */ - BMP_C(0xcbf43926) << (BMP_BIT - 32), /* 162 -- 32,cbf43926 */ - BMP_C(0xcde70300) << (BMP_BIT - 32), /* 163 -- 24, cde703 */ - BMP_C(0xce3c0000) << (BMP_BIT - 32), /* 164 -- 16, ce3c */ - BMP_C(0xd0000000) << (BMP_BIT - 32), /* 165 -- 8, d0 */ - BMP_C(0xd02a0000) << (BMP_BIT - 32), /* 166 -- 15, 6815 */ - BMP_C(0xd0db0000) << (BMP_BIT - 32), /* 167 -- 16, d0db */ - BMP_C(0xd3100000) << (BMP_BIT - 32), /* 168 -- 12, d31 */ - BMP_C(0xd3be9568) << (BMP_BIT - 32), /* 169 -- 30,34efa55a */ - BMP_C(0xd4d00000) << (BMP_BIT - 32), /* 170 -- 12, d4d */ - BMP_C(0xd5000000) << (BMP_BIT - 32), /* 171 -- 8, d5 */ - BMP_C(0xd64e0000) << (BMP_BIT - 32), /* 172 -- 16, d64e */ - BMP_C(0xda000000) << (BMP_BIT - 32), /* 173 -- 8, da */ - BMP_C(0xdaf00000) << (BMP_BIT - 32), /* 174 -- 12, daf */ - BMP_C(0xdebb20e3) << (BMP_BIT - 32), /* 175 -- 32,debb20e3 */ - BMP_C(0xdf000000) << (BMP_BIT - 32), /* 176 -- 8, df */ - BMP_C(0xe0000000) << (BMP_BIT - 32), /* 177 -- 3, 7 */ - BMP_C(0xe3069283) << (BMP_BIT - 32), /* 178 -- 32,e3069283 */ - BMP_C(0xe3940000) << (BMP_BIT - 32), /* 179 -- 16, e394 */ - BMP_C(0xe5cc0000) << (BMP_BIT - 32), /* 180 -- 16, e5cc */ - BMP_C(0xe7a80000) << (BMP_BIT - 32), /* 181 -- 13, 1cf5 */ - BMP_C(0xe8000000) << (BMP_BIT - 32), /* 182 -- 6, 3a */ - BMP_C(0xea000000) << (BMP_BIT - 32), /* 183 -- 7, 75 */ - BMP_C(0xea820000) << (BMP_BIT - 32), /* 184 -- 16, ea82 */ - BMP_C(0xec000000) << (BMP_BIT - 32), /* 185 -- 6, 3b */ - BMP_C(0xf0000000) << (BMP_BIT - 32), /* 186 -- 4, f */ - BMP_C(0xf0b80000) << (BMP_BIT - 32), /* 187 -- 16, f0b8 */ - BMP_C(0xf1300000) << (BMP_BIT - 32), /* 188 -- 12, f13 */ - BMP_C(0xf4000000) << (BMP_BIT - 32), /* 189 -- 8, f4 */ - BMP_C(0xf4acfb13) << (BMP_BIT - 32), /* 190 -- 32,f4acfb13 */ - BMP_C(0xf5b00000) << (BMP_BIT - 32), /* 191 -- 12, f5b */ - BMP_C(0xf6400000) << (BMP_BIT - 32), /* 192 -- 10, 3d9 */ - BMP_C(0xf7000000) << (BMP_BIT - 32), /* 193 -- 8, f7 */ - BMP_C(0xf8000000) << (BMP_BIT - 32), /* 194 -- 5, 1f */ - BMP_C(0xfc000000) << (BMP_BIT - 32), /* 195 -- 6, 3f */ - BMP_C(0xfc891918) << (BMP_BIT - 32), /* 196 -- 32,fc891918 */ - BMP_C(0xfd000000) << (BMP_BIT - 32), /* 197 -- 8, fd */ - BMP_C(0xfe000000) << (BMP_BIT - 32), /* 198 -- 7, 7f */ - BMP_C(0xfedcba00) << (BMP_BIT - 32), /* 199 -- 24, fedcba */ - BMP_C(0xfee80000) << (BMP_BIT - 32), /* 200 -- 16, fee8 */ - BMP_C(0xff000000) << (BMP_BIT - 32), /* 201 -- 8, ff */ - BMP_C(0xffc00000) << (BMP_BIT - 32), /* 202 -- 10, 3ff */ - BMP_C(0xfff00000) << (BMP_BIT - 32), /* 203 -- 12, fff */ - BMP_C(0xfffc0000) << (BMP_BIT - 32), /* 204 -- 14, 3fff */ - BMP_C(0xffff0000) << (BMP_BIT - 32), /* 205 -- 16, ffff */ - BMP_C(0xffffff00) << (BMP_BIT - 32), /* 206 -- 24, ffffff */ - BMP_C(0xfffffffc) << (BMP_BIT - 32), /* 207 -- 30,3fffffff */ - BMP_C(0xfffffffe) << (BMP_BIT - 32), /* 208 -- 31,7fffffff */ - BMP_C(0xffffffff) << (BMP_BIT - 32), /* 209 -- 32,ffffffff */ + BMP_C(0x00010000) << (BMP_BIT - 32), /* 1 -- 16, 0001 */ + BMP_C(0x00020000) << (BMP_BIT - 32), /* 2 -- 15, 0001 */ + BMP_C(0x00065b00) << (BMP_BIT - 32), /* 3 -- 24, 00065b */ + BMP_C(0x007e0000) << (BMP_BIT - 32), /* 4 -- 16, 007e */ + BMP_C(0x007f0000) << (BMP_BIT - 32), /* 5 -- 16, 007f */ + BMP_C(0x03400000) << (BMP_BIT - 32), /* 6 -- 11, 01a */ + BMP_C(0x0376e6e7) << (BMP_BIT - 32), /* 7 -- 32,0376e6e7 */ + BMP_C(0x04c11db7) << (BMP_BIT - 32), /* 8 -- 32,04c11db7 */ + BMP_C(0x05890000) << (BMP_BIT - 32), /* 9 -- 16, 0589 */ + BMP_C(0x07000000) << (BMP_BIT - 32), /* 10 -- 8, 07 */ + BMP_C(0x080b0000) << (BMP_BIT - 32), /* 11 -- 16, 080b */ + BMP_C(0x09823b6e) << (BMP_BIT - 32), /* 12 -- 31,04c11db7 */ + BMP_C(0x0b3c0000) << (BMP_BIT - 32), /* 13 -- 15, 059e */ + BMP_C(0x0c000000) << (BMP_BIT - 32), /* 14 -- 6, 03 */ + BMP_C(0x0c200000) << (BMP_BIT - 32), /* 15 -- 11, 061 */ + BMP_C(0x0c780000) << (BMP_BIT - 32), /* 16 -- 14, 031e */ + BMP_C(0x0fb30000) << (BMP_BIT - 32), /* 17 -- 16, 0fb3 */ + BMP_C(0x10210000) << (BMP_BIT - 32), /* 18 -- 16, 1021 */ + BMP_C(0x12000000) << (BMP_BIT - 32), /* 19 -- 7, 09 */ + BMP_C(0x130d2afc) << (BMP_BIT - 32), /* 20 -- 30,04c34abf */ + BMP_C(0x144e6300) << (BMP_BIT - 32), /* 21 -- 24, 144e63 */ + BMP_C(0x15000000) << (BMP_BIT - 32), /* 22 -- 8, 15 */ + BMP_C(0x1697d06a) << (BMP_BIT - 32), /* 23 -- 32,1697d06a */ + BMP_C(0x17800000) << (BMP_BIT - 32), /* 24 -- 12, 178 */ + BMP_C(0x18000000) << (BMP_BIT - 32), /* 25 -- 6, 06 */ + BMP_C(0x19d3c8d8) << (BMP_BIT - 32), /* 26 -- 31,0ce9e46c */ + BMP_C(0x1c000000) << (BMP_BIT - 32), /* 27 -- 6, 07 */ + BMP_C(0x1d000000) << (BMP_BIT - 32), /* 28 -- 8, 1d */ + BMP_C(0x1d0f0000) << (BMP_BIT - 32), /* 29 -- 16, 1d0f */ + BMP_C(0x1dcf0000) << (BMP_BIT - 32), /* 30 -- 16, 1dcf */ + BMP_C(0x1edc6f41) << (BMP_BIT - 32), /* 31 -- 32,1edc6f41 */ + BMP_C(0x1f23b800) << (BMP_BIT - 32), /* 32 -- 24, 1f23b8 */ + BMP_C(0x20000000) << (BMP_BIT - 32), /* 33 -- 4, 2 */ + BMP_C(0x200fa500) << (BMP_BIT - 32), /* 34 -- 24, 200fa5 */ + BMP_C(0x20140000) << (BMP_BIT - 32), /* 35 -- 14, 0805 */ + BMP_C(0x20b40000) << (BMP_BIT - 32), /* 36 -- 14, 082d */ + BMP_C(0x20fe0000) << (BMP_BIT - 32), /* 37 -- 16, 20fe */ + BMP_C(0x21890000) << (BMP_BIT - 32), /* 38 -- 16, 2189 */ + BMP_C(0x21cf0200) << (BMP_BIT - 32), /* 39 -- 24, 21cf02 */ + BMP_C(0x23ef5200) << (BMP_BIT - 32), /* 40 -- 24, 23ef52 */ + BMP_C(0x25000000) << (BMP_BIT - 32), /* 41 -- 8, 25 */ + BMP_C(0x26000000) << (BMP_BIT - 32), /* 42 -- 8, 26 */ + BMP_C(0x26b10000) << (BMP_BIT - 32), /* 43 -- 16, 26b1 */ + BMP_C(0x27818000) << (BMP_BIT - 32), /* 44 -- 17, 04f03 */ + BMP_C(0x27d00000) << (BMP_BIT - 32), /* 45 -- 13, 04fa */ + BMP_C(0x28000000) << (BMP_BIT - 32), /* 46 -- 5, 05 */ + BMP_C(0x29b10000) << (BMP_BIT - 32), /* 47 -- 16, 29b1 */ + BMP_C(0x2f000000) << (BMP_BIT - 32), /* 48 -- 8, 2f */ + BMP_C(0x30000000) << (BMP_BIT - 32), /* 49 -- 4, 3/ 5, 6 */ + BMP_C(0x3010bf7f) << (BMP_BIT - 32), /* 50 -- 32,3010bf7f */ + BMP_C(0x31000000) << (BMP_BIT - 32), /* 51 -- 8, 31 */ + BMP_C(0x31800000) << (BMP_BIT - 32), /* 52 -- 10, 0c6 */ + BMP_C(0x31c30000) << (BMP_BIT - 32), /* 53 -- 16, 31c3 */ + BMP_C(0x328b6300) << (BMP_BIT - 32), /* 54 -- 24, 328b63 */ + BMP_C(0x34000000) << (BMP_BIT - 32), /* 55 -- 6, 0d */ + BMP_C(0x340bc6d9) << (BMP_BIT - 32), /* 56 -- 32,340bc6d9 */ + BMP_C(0x37000000) << (BMP_BIT - 32), /* 57 -- 8, 37 */ + BMP_C(0x38000000) << (BMP_BIT - 32), /* 58 -- 5, 07 */ + BMP_C(0x39000000) << (BMP_BIT - 32), /* 59 -- 8, 39 */ + BMP_C(0x3d650000) << (BMP_BIT - 32), /* 60 -- 16, 3d65 */ + BMP_C(0x3e000000) << (BMP_BIT - 32), /* 61 -- 8, 3e */ + BMP_C(0x40000000) << (BMP_BIT - 32), /* 62 -- 3, 2 */ + BMP_C(0x42000000) << (BMP_BIT - 32), /* 63 -- 8, 42 */ + BMP_C(0x44c20000) << (BMP_BIT - 32), /* 64 -- 16, 44c2 */ + BMP_C(0x45270551) << (BMP_BIT - 32), /* 65 -- 32,45270551 */ + BMP_C(0x48000000) << (BMP_BIT - 32), /* 66 -- 5, 09 */ + BMP_C(0x49000000) << (BMP_BIT - 32), /* 67 -- 8, 49 */ + BMP_C(0x4a800000) << (BMP_BIT - 32), /* 68 -- 10, 12a */ + BMP_C(0x4acc0000) << (BMP_BIT - 32), /* 69 -- 15, 2566 */ + BMP_C(0x4b000000) << (BMP_BIT - 32), /* 70 -- 8, 4b */ + BMP_C(0x4b370000) << (BMP_BIT - 32), /* 71 -- 16, 4b37 */ + BMP_C(0x4c000000) << (BMP_BIT - 32), /* 72 -- 6, 13 */ + BMP_C(0x4c060000) << (BMP_BIT - 32), /* 73 -- 16, 4c06 */ + BMP_C(0x53000000) << (BMP_BIT - 32), /* 74 -- 8, 53 */ + BMP_C(0x55000000) << (BMP_BIT - 32), /* 75 -- 8, 55 */ + BMP_C(0x55555500) << (BMP_BIT - 32), /* 76 -- 24, 555555 */ + BMP_C(0x59350000) << (BMP_BIT - 32), /* 77 -- 16, 5935 */ + BMP_C(0x5d380000) << (BMP_BIT - 32), /* 78 -- 16, 5d38 */ + BMP_C(0x5d400000) << (BMP_BIT - 32), /* 79 -- 10, 175 */ + BMP_C(0x5d6dcb00) << (BMP_BIT - 32), /* 80 -- 24, 5d6dcb */ + BMP_C(0x60000000) << (BMP_BIT - 32), /* 81 -- 3, 3 */ + BMP_C(0x60e00000) << (BMP_BIT - 32), /* 82 -- 11, 307 */ + BMP_C(0x63d00000) << (BMP_BIT - 32), /* 83 -- 16, 63d0 */ + BMP_C(0x64000000) << (BMP_BIT - 32), /* 84 -- 6, 19 */ + BMP_C(0x66400000) << (BMP_BIT - 32), /* 85 -- 10, 199 */ + BMP_C(0x66c50000) << (BMP_BIT - 32), /* 86 -- 16, 66c5 */ + BMP_C(0x6f630000) << (BMP_BIT - 32), /* 87 -- 16, 6f63 */ + BMP_C(0x6f910000) << (BMP_BIT - 32), /* 88 -- 16, 6f91 */ + BMP_C(0x70000000) << (BMP_BIT - 32), /* 89 -- 4, 7 */ + BMP_C(0x70a00000) << (BMP_BIT - 32), /* 90 -- 11, 385 */ + BMP_C(0x755b0000) << (BMP_BIT - 32), /* 91 -- 16, 755b */ + BMP_C(0x765e7680) << (BMP_BIT - 32), /* 92 -- 32,765e7680 */ + BMP_C(0x76c20800) << (BMP_BIT - 32), /* 93 -- 32, 0ed841 */ + BMP_C(0x7979bd00) << (BMP_BIT - 32), /* 94 -- 24, 7979bd */ + BMP_C(0x7e000000) << (BMP_BIT - 32), /* 95 -- 8, 7e */ + BMP_C(0x80000000) << (BMP_BIT - 32), /* 96 -- 3, 4 */ + BMP_C(0x80006300) << (BMP_BIT - 32), /* 97 -- 24, 800063 */ + BMP_C(0x80050000) << (BMP_BIT - 32), /* 98 -- 16, 8005 */ + BMP_C(0x800d0000) << (BMP_BIT - 32), /* 99 -- 16, 800d */ + BMP_C(0x800fe300) << (BMP_BIT - 32), /* 100 -- 24, 800fe3 */ + BMP_C(0x80b40000) << (BMP_BIT - 32), /* 101 -- 14, 202d */ + BMP_C(0x80c2e71c) << (BMP_BIT - 32), /* 102 -- 30,2030b9c7 */ + BMP_C(0x80f00000) << (BMP_BIT - 32), /* 103 -- 12, 80f */ + BMP_C(0x814141ab) << (BMP_BIT - 32), /* 104 -- 32,814141ab */ + BMP_C(0x8144c800) << (BMP_BIT - 32), /* 105 -- 21, 102899 */ + BMP_C(0x864cfb00) << (BMP_BIT - 32), /* 106 -- 24, 864cfb */ + BMP_C(0x87315576) << (BMP_BIT - 32), /* 107 -- 32,87315576 */ + BMP_C(0x89ec0000) << (BMP_BIT - 32), /* 108 -- 16, 89ec */ + BMP_C(0x8a000000) << (BMP_BIT - 32), /* 109 -- 7, 45 */ + BMP_C(0x8b320000) << (BMP_BIT - 32), /* 110 -- 15, 4599 */ + BMP_C(0x8bb70000) << (BMP_BIT - 32), /* 111 -- 16, 8bb7 */ + BMP_C(0x8cc00000) << (BMP_BIT - 32), /* 112 -- 10, 233 */ + BMP_C(0x904cddbf) << (BMP_BIT - 32), /* 113 -- 32,904cddbf */ + BMP_C(0x906e0000) << (BMP_BIT - 32), /* 114 -- 16, 906e */ + BMP_C(0x94000000) << (BMP_BIT - 32), /* 115 -- 8, 94 */ + BMP_C(0x97000000) << (BMP_BIT - 32), /* 116 -- 8, 97 */ + BMP_C(0x98000000) << (BMP_BIT - 32), /* 117 -- 6, 26 */ + BMP_C(0x99000000) << (BMP_BIT - 32), /* 118 -- 8, 99 */ + BMP_C(0x9b000000) << (BMP_BIT - 32), /* 119 -- 8, 9b */ + BMP_C(0x9c000000) << (BMP_BIT - 32), /* 120 -- 6, 27 */ + BMP_C(0x9d5e4de2) << (BMP_BIT - 32), /* 121 -- 31,4eaf26f1 */ + BMP_C(0x9e000000) << (BMP_BIT - 32), /* 122 -- 7, 4f */ + BMP_C(0x9ecf0000) << (BMP_BIT - 32), /* 123 -- 16, 9ecf */ + BMP_C(0xa0660000) << (BMP_BIT - 32), /* 124 -- 16, a066 */ + BMP_C(0xa0970000) << (BMP_BIT - 32), /* 125 -- 16, a097 */ + BMP_C(0xa1000000) << (BMP_BIT - 32), /* 126 -- 8, a1 */ + BMP_C(0xa3660000) << (BMP_BIT - 32), /* 127 -- 16, a366 */ + BMP_C(0xa6000000) << (BMP_BIT - 32), /* 128 -- 7, 53 */ + BMP_C(0xa7000000) << (BMP_BIT - 32), /* 129 -- 8, a7 */ + BMP_C(0xa8000000) << (BMP_BIT - 32), /* 130 -- 5, 15 */ + BMP_C(0xa8190000) << (BMP_BIT - 32), /* 131 -- 16, a819 */ + BMP_C(0xa833982b) << (BMP_BIT - 32), /* 132 -- 32,a833982b */ + BMP_C(0xabcdef00) << (BMP_BIT - 32), /* 133 -- 24, abcdef */ + BMP_C(0xac000000) << (BMP_BIT - 32), /* 134 -- 8, ac */ + BMP_C(0xaee70000) << (BMP_BIT - 32), /* 135 -- 16, aee7 */ + BMP_C(0xb0000000) << (BMP_BIT - 32), /* 136 -- 4, b */ + BMP_C(0xb0010000) << (BMP_BIT - 32), /* 137 -- 16, b001 */ + BMP_C(0xb2aa0000) << (BMP_BIT - 32), /* 138 -- 16, b2aa */ + BMP_C(0xb3400000) << (BMP_BIT - 32), /* 139 -- 12, b34 */ + BMP_C(0xb42d8000) << (BMP_BIT - 32), /* 140 -- 17, 1685b */ + BMP_C(0xb4600000) << (BMP_BIT - 32), /* 141 -- 11, 5a3 */ + BMP_C(0xb4c80000) << (BMP_BIT - 32), /* 142 -- 16, b4c8 */ + BMP_C(0xb4f3e600) << (BMP_BIT - 32), /* 143 -- 24, b4f3e6 */ + BMP_C(0xb704ce00) << (BMP_BIT - 32), /* 144 -- 24, b704ce */ + BMP_C(0xb798b438) << (BMP_BIT - 32), /* 145 -- 32,b798b438 */ + BMP_C(0xbb3d0000) << (BMP_BIT - 32), /* 146 -- 16, bb3d */ + BMP_C(0xbc000000) << (BMP_BIT - 32), /* 147 -- 6,2f/ 8,bc */ + BMP_C(0xbd0be338) << (BMP_BIT - 32), /* 148 -- 32,bd0be338 */ + BMP_C(0xbdf40000) << (BMP_BIT - 32), /* 149 -- 16, bdf4 */ + BMP_C(0xbf050000) << (BMP_BIT - 32), /* 150 -- 16, bf05 */ + BMP_C(0xc0000000) << (BMP_BIT - 32), /* 151 -- 3, 6 */ + BMP_C(0xc2000000) << (BMP_BIT - 32), /* 152 -- 7, 61 */ + BMP_C(0xc25a5600) << (BMP_BIT - 32), /* 153 -- 24, c25a56 */ + BMP_C(0xc2b70000) << (BMP_BIT - 32), /* 154 -- 16, c2b7 */ + BMP_C(0xc2b80000) << (BMP_BIT - 32), /* 155 -- 14, 30ae */ + BMP_C(0xc4000000) << (BMP_BIT - 32), /* 156 -- 8, c4 */ + BMP_C(0xc6c60000) << (BMP_BIT - 32), /* 157 -- 16, c6c6 */ + BMP_C(0xc7000000) << (BMP_BIT - 32), /* 158 -- 8, c7 */ + BMP_C(0xc704dd7b) << (BMP_BIT - 32), /* 159 -- 32,c704dd7b */ + BMP_C(0xc8000000) << (BMP_BIT - 32), /* 160 -- 5, 19 */ + BMP_C(0xc8670000) << (BMP_BIT - 32), /* 161 -- 16, c867 */ + BMP_C(0xcbf43926) << (BMP_BIT - 32), /* 162 -- 32,cbf43926 */ + BMP_C(0xcde70300) << (BMP_BIT - 32), /* 163 -- 24, cde703 */ + BMP_C(0xce3c0000) << (BMP_BIT - 32), /* 164 -- 16, ce3c */ + BMP_C(0xd0000000) << (BMP_BIT - 32), /* 165 -- 8, d0 */ + BMP_C(0xd02a0000) << (BMP_BIT - 32), /* 166 -- 15, 6815 */ + BMP_C(0xd0db0000) << (BMP_BIT - 32), /* 167 -- 16, d0db */ + BMP_C(0xd3100000) << (BMP_BIT - 32), /* 168 -- 12, d31 */ + BMP_C(0xd3be9568) << (BMP_BIT - 32), /* 169 -- 30,34efa55a */ + BMP_C(0xd4d00000) << (BMP_BIT - 32), /* 170 -- 12, d4d */ + BMP_C(0xd5000000) << (BMP_BIT - 32), /* 171 -- 8, d5 */ + BMP_C(0xd64e0000) << (BMP_BIT - 32), /* 172 -- 16, d64e */ + BMP_C(0xda000000) << (BMP_BIT - 32), /* 173 -- 8, da */ + BMP_C(0xdaf00000) << (BMP_BIT - 32), /* 174 -- 12, daf */ + BMP_C(0xdebb20e3) << (BMP_BIT - 32), /* 175 -- 32,debb20e3 */ + BMP_C(0xdf000000) << (BMP_BIT - 32), /* 176 -- 8, df */ + BMP_C(0xe0000000) << (BMP_BIT - 32), /* 177 -- 3, 7 */ + BMP_C(0xe3069283) << (BMP_BIT - 32), /* 178 -- 32,e3069283 */ + BMP_C(0xe3940000) << (BMP_BIT - 32), /* 179 -- 16, e394 */ + BMP_C(0xe5cc0000) << (BMP_BIT - 32), /* 180 -- 16, e5cc */ + BMP_C(0xe7a80000) << (BMP_BIT - 32), /* 181 -- 13, 1cf5 */ + BMP_C(0xe8000000) << (BMP_BIT - 32), /* 182 -- 6, 3a */ + BMP_C(0xea000000) << (BMP_BIT - 32), /* 183 -- 7, 75 */ + BMP_C(0xea820000) << (BMP_BIT - 32), /* 184 -- 16, ea82 */ + BMP_C(0xec000000) << (BMP_BIT - 32), /* 185 -- 6, 3b */ + BMP_C(0xf0000000) << (BMP_BIT - 32), /* 186 -- 4, f */ + BMP_C(0xf0b80000) << (BMP_BIT - 32), /* 187 -- 16, f0b8 */ + BMP_C(0xf1300000) << (BMP_BIT - 32), /* 188 -- 12, f13 */ + BMP_C(0xf4000000) << (BMP_BIT - 32), /* 189 -- 8, f4 */ + BMP_C(0xf4acfb13) << (BMP_BIT - 32), /* 190 -- 32,f4acfb13 */ + BMP_C(0xf5b00000) << (BMP_BIT - 32), /* 191 -- 12, f5b */ + BMP_C(0xf6400000) << (BMP_BIT - 32), /* 192 -- 10, 3d9 */ + BMP_C(0xf7000000) << (BMP_BIT - 32), /* 193 -- 8, f7 */ + BMP_C(0xf8000000) << (BMP_BIT - 32), /* 194 -- 5, 1f */ + BMP_C(0xfc000000) << (BMP_BIT - 32), /* 195 -- 6, 3f */ + BMP_C(0xfc891918) << (BMP_BIT - 32), /* 196 -- 32,fc891918 */ + BMP_C(0xfd000000) << (BMP_BIT - 32), /* 197 -- 8, fd */ + BMP_C(0xfe000000) << (BMP_BIT - 32), /* 198 -- 7, 7f */ + BMP_C(0xfedcba00) << (BMP_BIT - 32), /* 199 -- 24, fedcba */ + BMP_C(0xfee80000) << (BMP_BIT - 32), /* 200 -- 16, fee8 */ + BMP_C(0xff000000) << (BMP_BIT - 32), /* 201 -- 8, ff */ + BMP_C(0xffc00000) << (BMP_BIT - 32), /* 202 -- 10, 3ff */ + BMP_C(0xfff00000) << (BMP_BIT - 32), /* 203 -- 12, fff */ + BMP_C(0xfffc0000) << (BMP_BIT - 32), /* 204 -- 14, 3fff */ + BMP_C(0xffff0000) << (BMP_BIT - 32), /* 205 -- 16, ffff */ + BMP_C(0xffffff00) << (BMP_BIT - 32), /* 206 -- 24, ffffff */ + BMP_C(0xfffffffc) << (BMP_BIT - 32), /* 207 -- 30,3fffffff */ + BMP_C(0xfffffffe) << (BMP_BIT - 32), /* 208 -- 31,7fffffff */ + BMP_C(0xffffffff) << (BMP_BIT - 32), /* 209 -- 32,ffffffff */ }; static const struct malias aliases[]; diff --git a/client/pyscripts/des_talk.py b/client/pyscripts/des_talk.py index cb62bb177..0a972edc3 100644 --- a/client/pyscripts/des_talk.py +++ b/client/pyscripts/des_talk.py @@ -608,4 +608,4 @@ def delete_file(aid, key_type, key, com_mode, aid_key_type, aid_key): print(response) if __name__ == "__main__": - authenticate_and_menu() + authenticate_and_menu() diff --git a/client/pyscripts/mfulaes_mask_recovery.py b/client/pyscripts/mfulaes_mask_recovery.py index 8ea1630dd..363771b6b 100755 --- a/client/pyscripts/mfulaes_mask_recovery.py +++ b/client/pyscripts/mfulaes_mask_recovery.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # Recover the shared key mask specific to an Ultralight AES card -# +# # Conditions: # * key blocks not locked by LOCK_KEYS # diff --git a/client/src/cmdflashmemspiffs.c b/client/src/cmdflashmemspiffs.c index e2d5417ff..62a85f246 100644 --- a/client/src/cmdflashmemspiffs.c +++ b/client/src/cmdflashmemspiffs.c @@ -467,7 +467,7 @@ static int CmdFlashMemSpiFFSWipe(const char *Cmd) { CLIParserInit(&ctx, "mem spiffs wipe", _RED_("* * * Warning * * *") " \n" _CYAN_("This command wipes all files on the device SPIFFS file system"), - "mem spiffs wipe"); + "mem spiffs wipe"); void *argtable[] = { arg_param_begin, diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 6fc8b0344..14ddfd60f 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -2989,7 +2989,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { int16_t fsci = card.ats[1] & 0x0f; PrintAndLogEx(INFO, " ..." _YELLOW_("%02X") "............ T0 TA1 is%s present, TB1 is%s present, " - "TC1 is%s present, FSCI is %d (FSC = %d)", + "TC1 is%s present, FSCI is %d (FSC = %d)", card.ats[1], (ta1 ? "" : _RED_(" NOT")), (tb1 ? "" : _RED_(" NOT")), @@ -3011,7 +3011,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { if (strlen(ds) != 0) ds[strlen(ds) - 2] = '\0'; if (strlen(dr) != 0) dr[strlen(dr) - 2] = '\0'; PrintAndLogEx(INFO, " ......" _YELLOW_("%02X") "......... TA1 different divisors are%s supported, " - "DR: [%s], DS: [%s]", + "DR: [%s], DS: [%s]", card.ats[pos], ((card.ats[pos] & 0x80) ? _RED_(" NOT") : ""), dr, diff --git a/client/src/cmdhfepa.c b/client/src/cmdhfepa.c index 44386620c..54dcbcc23 100644 --- a/client/src/cmdhfepa.c +++ b/client/src/cmdhfepa.c @@ -86,7 +86,7 @@ static int CmdHFEPACollectPACENonces(const char *Cmd) { PrintAndLogEx(WARNING, "Failed to allocate memory"); return PM3_EMALLOC; } - + // print nonce PrintAndLogEx(SUCCESS, "Length: %zu, Nonce: %s", nonce_length, sprint_hex_inrow(resp.data.asBytes, nonce_length)); free(nonce); diff --git a/client/src/cmdhffelica.c b/client/src/cmdhffelica.c index 0207a4553..bb5d1247b 100644 --- a/client/src/cmdhffelica.c +++ b/client/src/cmdhffelica.c @@ -64,10 +64,10 @@ static void print_status_flag1_interpretation(void) { PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------"); PrintAndLogEx(INFO, " 00 | Indicates the successful completion of a command."); PrintAndLogEx(INFO, " FF | If an error occurs during the processing of a command that includes no list in the command packet, \n" - " | or if an error occurs independently of any list, the card returns a response by setting FFh to Status Flag1."); + " | or if an error occurs independently of any list, the card returns a response by setting FFh to Status Flag1."); PrintAndLogEx(INFO, " XX | If an error occurs while processing a command that includes Service Code List or Block List \n" - " | in the command packet, the card returns a response by setting a number in the list to Status Flag1,\n" - " | indicating the location of the error."); + " | in the command packet, the card returns a response by setting a number in the list to Status Flag1,\n" + " | indicating the location of the error."); PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------"); } @@ -76,28 +76,28 @@ static void print_status_flag2_interpration(void) { PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------"); PrintAndLogEx(INFO, " 00 | Indicates the successful completion of a command."); PrintAndLogEx(INFO, " 01 | The calculated result is either less than zero when the purse data is decremented, or exceeds 4\n" - " | Bytes when the purse data is incremented."); + " | Bytes when the purse data is incremented."); PrintAndLogEx(INFO, " 02 | The specified data exceeds the value of cashback data at cashback of purse."); PrintAndLogEx(INFO, " 70 | Memory error (fatal error)."); PrintAndLogEx(INFO, " 71 | The number of memory rewrites exceeds the upper limit (this is only a warning; data writing is performed as normal).\n" - " | The maximum number of rewrites can differ, depending on the product being used.\n" - " | In addition, Status Flag1 is either 00h or FFh depending on the product being used."); + " | The maximum number of rewrites can differ, depending on the product being used.\n" + " | In addition, Status Flag1 is either 00h or FFh depending on the product being used."); PrintAndLogEx(INFO, " A1 | Illegal Number of Service| Number of Service or Number of Node specified by the command \n" - " | falls outside the range of the prescribed value."); + " | falls outside the range of the prescribed value."); PrintAndLogEx(INFO, " A2 | Illegal command packet (specified Number of Block) : Number of Block specified by the \n" - " | command falls outside the range of the prescribed values for the product."); + " | command falls outside the range of the prescribed values for the product."); PrintAndLogEx(INFO, " A3 | Illegal Block List (specified order of Service) : Service Code List Order specified by \n" - " | Block List Element falls outside the Number of Service specified by the command \n" - " | (or the Number of Service specified at the times of mutual authentication)."); + " | Block List Element falls outside the Number of Service specified by the command \n" + " | (or the Number of Service specified at the times of mutual authentication)."); PrintAndLogEx(INFO, " A4 | Illegal Service type : Area Attribute specified by the command or Service Attribute of Service Code is incorrect."); PrintAndLogEx(INFO, " A5 | Access is not allowed : Area or Service specified by the command cannot be accessed.\n" - " | The parameter specified by the command does not satisfy the conditions for success."); + " | The parameter specified by the command does not satisfy the conditions for success."); PrintAndLogEx(INFO, " A6 | Illegal Service Code List : Target to be accessed, identified by Service Code List Order, specified by Block\n" - " | List Element does not exist. Or, Node specified by Node Code List does not exist."); + " | List Element does not exist. Or, Node specified by Node Code List does not exist."); PrintAndLogEx(INFO, " A7 | Illegal Block List (Access Mode) : Access Mode specified by Block List Element is incorrect."); PrintAndLogEx(INFO, " A8 | Illegal Block Number Block Number (access to the specified data is inhibited) :\n" - " | specified by Block List Element exceeds the number of Blocks assigned to Service."); + " | specified by Block List Element exceeds the number of Blocks assigned to Service."); PrintAndLogEx(INFO, " A9 | Data write failure : This is the error that occurs in issuance commands."); PrintAndLogEx(INFO, " AA | Key-change failure : Key change failed."); PrintAndLogEx(INFO, " AB | Illegal Package Parity or illegal Package MAC : This is the error that occurs in issuance commands."); @@ -105,7 +105,7 @@ static void print_status_flag2_interpration(void) { PrintAndLogEx(INFO, " AD | Service exists already : This is the error that occurs in issuance commands."); PrintAndLogEx(INFO, " AE | Illegal System Code : This is the error that occurs in issuance commands."); PrintAndLogEx(INFO, " AF | Too many simultaneous cyclic write operations : Number of simultaneous write Blocks\n" - " | specified by the command to Cyclic Service exceeds the number of Blocks assigned to Service."); + " | specified by the command to Cyclic Service exceeds the number of Blocks assigned to Service."); PrintAndLogEx(INFO, " C0 | Illegal Package Identifier : This is the error that occurs in issuance commands."); PrintAndLogEx(INFO, " C1 | Discrepancy of parameters inside and outside Package : This is the error that occurs in issuance commands."); PrintAndLogEx(INFO, " C2 | Command is disabled already : This is the error that occurs in issuance commands."); @@ -129,16 +129,16 @@ static void print_number_of_service_constraints(void) { static void print_number_of_block_constraints(void) { PrintAndLogEx(INFO, " - Number of Block: shall be less than or equal to the maximum number of Blocks that can be read simultaneously.\n" - " The maximum number of Blocks that can be read simultaneously can differ, depending on the product being used.\n" - " Use as default 01"); + " The maximum number of Blocks that can be read simultaneously can differ, depending on the product being used.\n" + " Use as default 01"); } static void print_service_code_list_constraints(void) { PrintAndLogEx(INFO, " - Service Code List: For Service Code List, only Service Code existing in the product shall be specified:"); PrintAndLogEx(INFO, " - Even when Service Code exists in the product, Service Code not referenced from Block List shall not \n" - " be specified to Service Code List."); + " be specified to Service Code List."); PrintAndLogEx(INFO, " - For existence or nonexistence of Service in a product, please check using the Request Service \n" - " (or Request Service v2) command."); + " (or Request Service v2) command."); } /* @@ -565,7 +565,7 @@ int send_rd_plain(uint8_t flags, uint16_t datalen, uint8_t *data, bool verbose, return PM3_ERFTRANS; } else { memcpy(rd_noCry_resp, (felica_read_without_encryption_response_t *)resp.data.asBytes, sizeof(felica_read_without_encryption_response_t)); - if (rd_noCry_resp->frame_response.cmd_code[0] != 0x07) { + if (rd_noCry_resp->frame_response.cmd_code[0] != 0x07) { PrintAndLogEx(FAILED, "Bad response cmd 0x%02X @ 0x%04X.", rd_noCry_resp->frame_response.cmd_code[0], 0x00); PrintAndLogEx(INFO, "This is either a normal signal issue, or an issue caused by wrong parameter. Please try again."); diff --git a/client/src/cmdhfgallagher.c b/client/src/cmdhfgallagher.c index 5b018387c..898cd45d9 100644 --- a/client/src/cmdhfgallagher.c +++ b/client/src/cmdhfgallagher.c @@ -373,7 +373,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 @@ -862,11 +862,11 @@ static int hfgal_read_card(uint32_t aid, uint8_t *site_key, bool verbose, bool q PM3_RET_IF_ERR_MAYBE_MSG(res, !quiet, "Failed reading card application credentials"); PrintAndLogEx(SUCCESS, "Gallagher (AID %06X) - region: " _GREEN_("%c") " ( " _GREEN_("%u") " )" - ", facility: " _GREEN_("%u") - ", card number: " _GREEN_("%u") - ", issue level: " _GREEN_("%u"), + ", facility: " _GREEN_("%u") + ", card number: " _GREEN_("%u") + ", issue level: " _GREEN_("%u"), current_aid, - 'A' + creds.region_code, + 'A' + creds.region_code, creds.region_code, creds.facility_code, creds.card_number, @@ -1299,10 +1299,10 @@ static int CmdGallagherDecode(const char *cmd) { gallagher_decode_creds(data_buf, &creds); PrintAndLogEx(SUCCESS, "Gallagher - region: " _GREEN_("%c") " ( " _GREEN_("%u") " )" - ", facility: " _GREEN_("%u") - ", card number: " _GREEN_("%u") - ", issue level: " _GREEN_("%u"), - 'A' + creds.region_code, + ", facility: " _GREEN_("%u") + ", card number: " _GREEN_("%u") + ", issue level: " _GREEN_("%u"), + 'A' + creds.region_code, creds.region_code, creds.facility_code, creds.card_number, diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index d876eddce..e565c9e6b 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -1513,26 +1513,26 @@ static void iclass_decode_credentials(uint8_t *data) { char *pbin = binstr; // Strip leading zeros while (strlen(pbin) && *(++pbin) == '0'); - + size_t binlen = strlen(pbin); - + // Check if we have a sentinel bit (leading '1' that makes length one more than common formats) // Common formats: 26, 30, 33, 34, 35, 36, 37, 46, 48 // If we have 27, 31, 34, 35, 36, 37, 38, 47, 49 bits and it starts with '1', // it's likely a sentinel bit that should be stripped - if (binlen > 0 && pbin[0] == '1' && - (binlen == 27 || binlen == 31 || binlen == 34 || binlen == 35 || - binlen == 36 || binlen == 37 || binlen == 38 || binlen == 47 || binlen == 49)) { + if (binlen > 0 && pbin[0] == '1' && + (binlen == 27 || binlen == 31 || binlen == 34 || binlen == 35 || + binlen == 36 || binlen == 37 || binlen == 38 || binlen == 47 || binlen == 49)) { // Strip the sentinel bit by recreating u96 from binary string without leading '1' char *corrected_bin = pbin + 1; // Skip the leading '1' size_t corrected_len = strlen(corrected_bin); - + // Recreate u96 values from corrected binary string top = 0; mid = 0; bot = 0; binstring_to_u96(&top, &mid, &bot, corrected_bin); - + pbin = corrected_bin; binlen = corrected_len; } @@ -2954,26 +2954,26 @@ static int CmdHFiClass_ReadBlock(const char *Cmd) { char *pbin = binstr; // Strip leading zeros while (strlen(pbin) && *(++pbin) == '0'); - + size_t binlen = strlen(pbin); - + // Check if we have a sentinel bit (leading '1' that makes length one more than common formats) // Common formats: 26, 30, 33, 34, 35, 36, 37, 46, 48 // If we have 27, 31, 34, 35, 36, 37, 38, 47, 49 bits and it starts with '1', // it's likely a sentinel bit that should be stripped - if (binlen > 0 && pbin[0] == '1' && - (binlen == 27 || binlen == 31 || binlen == 34 || binlen == 35 || - binlen == 36 || binlen == 37 || binlen == 38 || binlen == 47 || binlen == 49)) { + if (binlen > 0 && pbin[0] == '1' && + (binlen == 27 || binlen == 31 || binlen == 34 || binlen == 35 || + binlen == 36 || binlen == 37 || binlen == 38 || binlen == 47 || binlen == 49)) { // Strip the sentinel bit by recreating u96 from binary string without leading '1' char *corrected_bin = pbin + 1; // Skip the leading '1' size_t corrected_len = strlen(corrected_bin); - + // Recreate u96 values from corrected binary string top = 0; mid = 0; bot = 0; binstring_to_u96(&top, &mid, &bot, corrected_bin); - + pbin = corrected_bin; binlen = corrected_len; } diff --git a/client/src/cmdhflegic.c b/client/src/cmdhflegic.c index aafe08c2f..003e31f86 100644 --- a/client/src/cmdhflegic.c +++ b/client/src/cmdhflegic.c @@ -262,7 +262,7 @@ static int decode_and_print_memory(uint16_t card_size, const uint8_t *input_buff // for printing the complete segment we need at least wrc + wrp_len + remain_seg_payload_len bytes if ((i + wrc + wrp_len + remain_seg_payload_len) > card_size) { PrintAndLogEx(FAILED, "Cannot read segment body, because the input buffer is too small. " - "Please check that the data is correct and properly aligned. "); + "Please check that the data is correct and properly aligned. "); return_value = PM3_EOUTOFBOUND; goto out; } @@ -346,7 +346,7 @@ static int decode_and_print_memory(uint16_t card_size, const uint8_t *input_buff // for printing the complete segment we need at least wrc + wrp_len + remain_seg_payload_len bytes if ((i + wrc + wrp_len + remain_seg_payload_len) > card_size) { PrintAndLogEx(FAILED, "Cannot read segment body, because the input buffer is too small. " - "Please check that the data is correct and properly aligned. "); + "Please check that the data is correct and properly aligned. "); return_value = PM3_EOUTOFBOUND; goto out; } diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index 140f89ae9..35e91776b 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -2507,7 +2507,7 @@ static int CmdHF14AMfNestedStatic(const char *Cmd) { for (int i = 0; i < 2; i++) { if (e_sector[sectorNo].foundKey[trgKeyType]) continue; - + int16_t isOK = mf_static_nested(blockNo, keyType, key, mfFirstBlockOfSector(sectorNo), trgKeyType, keyBlock, forceDetectDist); switch (isOK) { case PM3_ETIMEOUT : @@ -5030,7 +5030,7 @@ void printKeyTableEx(size_t sectorscnt, sector_t *e_sector, uint8_t start_sector _YELLOW_("H") ":Hardnested / " _YELLOW_("C") ":statiCnested / " _YELLOW_("A") ":keyA " - " )" + " )" ); if (sectorscnt == 18) { PrintAndLogEx(INFO, "( " _MAGENTA_("*") " ) These sectors used for signature. Lays outside of user memory"); diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index 95d94faac..80d7de42a 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -2027,7 +2027,7 @@ static int mfulc_fingerprint(void) { if ((status > 0) && (data[2] == 0x09)) { cmd[1] = 3; status = ul_send_cmd_raw(cmd, sizeof(cmd), data, 4, false); - if ((status > 0) && (data[0] == 0xE1) && (data[1] == 0x10) && (data[2] == 0x12) && (data[3] == 0x00) ) { + if ((status > 0) && (data[0] == 0xE1) && (data[1] == 0x10) && (data[2] == 0x12) && (data[3] == 0x00)) { PrintAndLogEx(INFO, "MIFARE Hospitality (MF0ICU2(H))"); DropField(); return PM3_SUCCESS; @@ -5054,7 +5054,7 @@ static int CmdHF14AMfUCSetUid(const char *Cmd) { } // block 1. - memcpy(packetw.data, uid+3, 4); + memcpy(packetw.data, uid + 3, 4); packetw.block_no = 1; clearCommandBuffer(); SendCommandNG(CMD_HF_MIFAREU_WRITEBL, (uint8_t *)&packetw, sizeof(packetw)); @@ -5065,7 +5065,7 @@ static int CmdHF14AMfUCSetUid(const char *Cmd) { // block 2. packetw.data[0] = uid[3] ^ uid[4] ^ uid[5] ^ uid[6]; - memcpy(packetw.data+1, oldblock2+1, 3); + memcpy(packetw.data + 1, oldblock2 + 1, 3); packetw.block_no = 2; clearCommandBuffer(); SendCommandNG(CMD_HF_MIFAREU_WRITEBL, (uint8_t *)&packetw, sizeof(packetw)); @@ -5469,7 +5469,7 @@ static int CmdHF14AMfuOtpTearoff(const char *Cmd) { if (use_data) { SendCommandNG(CMD_HF_MIFAREU_WRITEBL, (uint8_t *)&packetw, sizeof(packetw)); if ((WaitForResponseTimeout(CMD_HF_MIFAREU_WRITEBL, &resp, 1500) == false) || - (resp.status != PM3_SUCCESS)) { + (resp.status != PM3_SUCCESS)) { PrintAndLogEx(FAILED, "Failed to write block BEFORE"); error_retries++; continue; // try again @@ -5478,8 +5478,8 @@ static int CmdHF14AMfuOtpTearoff(const char *Cmd) { packetr.block_no = blockno; SendCommandNG(CMD_HF_MIFAREU_READBL, (uint8_t *)&packetr, sizeof(packetr)); - if ((WaitForResponseTimeout(CMD_HF_MIFAREU_READBL, &resp, 1500) == false ) || - (resp.status != PM3_SUCCESS)) { + if ((WaitForResponseTimeout(CMD_HF_MIFAREU_READBL, &resp, 1500) == false) || + (resp.status != PM3_SUCCESS)) { PrintAndLogEx(FAILED, "Failed to read block BEFORE"); error_retries++; continue; // try again @@ -5504,8 +5504,8 @@ static int CmdHF14AMfuOtpTearoff(const char *Cmd) { clearCommandBuffer(); SendCommandNG(CMD_HF_MIFAREU_READBL, (uint8_t *)&packetr, sizeof(packetr)); - if ((WaitForResponseTimeout(CMD_HF_MIFAREU_READBL, &resp, 1500) == false ) || - (resp.status != PM3_SUCCESS)) { + if ((WaitForResponseTimeout(CMD_HF_MIFAREU_READBL, &resp, 1500) == false) || + (resp.status != PM3_SUCCESS)) { PrintAndLogEx(FAILED, "Failed to read block BEFORE"); error_retries++; continue; // try again diff --git a/client/src/cmdhfntag424.c b/client/src/cmdhfntag424.c index 92639f864..97108a741 100644 --- a/client/src/cmdhfntag424.c +++ b/client/src/cmdhfntag424.c @@ -723,8 +723,8 @@ static int ntag424_authenticate_ev2_first(uint8_t keyno, uint8_t *key, ntag424_s if (memcmp(response.rnd_a, &rnd_a_clear[1], 15) != 0 || response.rnd_a[15] != rnd_a_clear[0]) { PrintAndLogEx(ERR, "Incorrect response from card\n" - "expected: %s\n" - "got: %s" + "expected: %s\n" + "got: %s" , sprint_hex(rnd_a_clear, 16), sprint_hex(response.rnd_a, 16)); return PM3_ESOFT; diff --git a/client/src/cmdhfsaflok.c b/client/src/cmdhfsaflok.c index 6f034b917..7d7e989d6 100644 --- a/client/src/cmdhfsaflok.c +++ b/client/src/cmdhfsaflok.c @@ -48,8 +48,8 @@ static inline uint8_t get_days_in_month(uint16_t year, uint8_t month) { uint8_t days = _days_in_month_lookup[month]; // Adjust for leap years if ((month == 2u) && - (year % 4u == 0u) && - ((year % 100u != 0u) || (year % 400u == 0u)) + (year % 4u == 0u) && + ((year % 100u != 0u) || (year % 400u == 0u)) ) { days = 29u; } @@ -103,7 +103,8 @@ typedef struct _saflok_test_case_t { } saflok_test_case_t; static const saflok_test_case_t saflok_test_cases[] = { - { // 5A4A845610B6B1DD8F4753872BC0E91095 / F7B08101FFF7FF9E10500072A00023E7C7 + { + // 5A4A845610B6B1DD8F4753872BC0E91095 / F7B08101FFF7FF9E10500072A00023E7C7 // Tests interval that crosses a leap year using days .encoded = {.raw = {0x5A, 0x4A, 0x84, 0x56, 0x10, 0xB6, 0xB1, 0xDD, 0x8F, 0x47, 0x53, 0x87, 0x2B, 0xC0, 0xE9, 0x10, 0x95} }, .decoded = {.raw = {0xF7, 0xB0, 0x81, 0x01, 0xFF, 0xF7, 0xFF, 0x9E, 0x10, 0x50, 0x00, 0x72, 0xA0, 0x00, 0x23, 0xE7, 0xC7} }, @@ -122,7 +123,8 @@ static const saflok_test_case_t saflok_test_cases[] = { .deadbolt_override = true, .checksum = 0xC7, }, - { // 3FB01B9F0100B55A7D423B6166C0E980B9 / B5AD8101FF57EB9400000A82EDF723E7CC + { + // 3FB01B9F0100B55A7D423B6166C0E980B9 / B5AD8101FF57EB9400000A82EDF723E7CC // Tests interval overflow from minutes -> hours -> day -> leap year overflow (2/29 -> 3/1) .encoded = {.raw = {0x3F, 0xB0, 0x1B, 0x9F, 0x01, 0x00, 0xB5, 0x5A, 0x7D, 0x42, 0x3B, 0x61, 0x66, 0xC0, 0xE9, 0x80, 0xB9} }, .decoded = {.raw = {0xB5, 0xAD, 0x81, 0x01, 0xFF, 0x57, 0xEB, 0x94, 0x00, 0x00, 0x0A, 0x82, 0xED, 0xF7, 0x23, 0xE7, 0xCC} }, @@ -141,7 +143,8 @@ static const saflok_test_case_t saflok_test_cases[] = { .deadbolt_override = true, .checksum = 0xCC, }, - { // C2FE64DFE4EBB1CC7D8F6FEBA6E59E5B4D / 338341A3C777557F00080082E000207B4E + { + // C2FE64DFE4EBB1CC7D8F6FEBA6E59E5B4D / 338341A3C777557F00080082E000207B4E // Tests interval overflow into a final leap-day expiration date .encoded = {.raw = {0xC2, 0xFE, 0x64, 0xDF, 0xE4, 0xEB, 0xB1, 0xCC, 0x7D, 0x8F, 0x6F, 0xEB, 0xA6, 0xE5, 0x9E, 0x5B, 0x4D} }, .decoded = {.raw = {0x33, 0x83, 0x41, 0xA3, 0xC7, 0x77, 0x55, 0x7F, 0x00, 0x08, 0x00, 0x82, 0xE0, 0x00, 0x20, 0x7B, 0x4E} }, @@ -173,576 +176,576 @@ static bool set_bitfield(saflok_mfc_data_t *data, size_t start_bit, size_t num_b #if 1 // getters and setters for each bitfield in saflok_mfc_data_t - static inline uint8_t get_saflok_mfc_card_level(const saflok_mfc_data_t *data) { - return (uint8_t)get_bitfield(data, 0, 4); +static inline uint8_t get_saflok_mfc_card_level(const saflok_mfc_data_t *data) { + return (uint8_t)get_bitfield(data, 0, 4); +} +static inline bool set_saflok_mfc_card_level(saflok_mfc_data_t *data, uint32_t card_level) { + if (card_level > 0xFu) { + PrintAndLogEx(ERR, _RED_("ERROR:") " card_level out of range (%08x)", card_level); + return false; } - static inline bool set_saflok_mfc_card_level(saflok_mfc_data_t *data, uint32_t card_level) { - if (card_level > 0xFu) { - PrintAndLogEx(ERR, _RED_("ERROR:") " card_level out of range (%08x)", card_level); - return false; - } - bool success = set_bitfield(data, 0, 4, card_level); - return success; + bool success = set_bitfield(data, 0, 4, card_level); + return success; +} +static inline uint8_t get_saflok_mfc_card_type(const saflok_mfc_data_t *data) { + return (uint8_t)get_bitfield(data, 4, 4); +} +static inline bool set_saflok_mfc_card_type(saflok_mfc_data_t *data, uint32_t card_type) { + if (card_type > 0xFu) { + PrintAndLogEx(ERR, _RED_("ERROR:") " card_type out of range (%08x)", card_type); + return false; } - static inline uint8_t get_saflok_mfc_card_type(const saflok_mfc_data_t *data) { - return (uint8_t)get_bitfield(data, 4, 4); + bool success = set_bitfield(data, 4, 4, card_type); + return success; +} +static inline uint8_t get_saflok_mfc_card_id(const saflok_mfc_data_t *data) { + return (uint8_t)get_bitfield(data, 8, 8); +} +static inline bool set_saflok_mfc_card_id(saflok_mfc_data_t *data, uint32_t card_id) { + if (card_id > 0xFFu) { + PrintAndLogEx(ERR, _RED_("ERROR:") " card_id out of range (%08x)", card_id); + return false; } - static inline bool set_saflok_mfc_card_type(saflok_mfc_data_t *data, uint32_t card_type) { - if (card_type > 0xFu) { - PrintAndLogEx(ERR, _RED_("ERROR:") " card_type out of range (%08x)", card_type); - return false; - } - bool success = set_bitfield(data, 4, 4, card_type); - return success; + bool success = set_bitfield(data, 8, 8, card_id); + return success; +} +static inline uint8_t get_saflok_mfc_opening_key(const saflok_mfc_data_t *data) { + return (uint8_t)get_bitfield(data, 16, 2); +} +static inline bool set_saflok_mfc_opening_key(saflok_mfc_data_t *data, uint32_t opening_key) { + if (opening_key > 0x3u) { + PrintAndLogEx(ERR, _RED_("ERROR:") " opening_key out of range (%08x)", opening_key); + return false; } - static inline uint8_t get_saflok_mfc_card_id(const saflok_mfc_data_t *data) { - return (uint8_t)get_bitfield(data, 8, 8); + bool success = set_bitfield(data, 16, 2, opening_key); + return success; +} +static inline uint16_t get_saflok_mfc_lock_id(const saflok_mfc_data_t *data) { + return (uint16_t)get_bitfield(data, 18, 14); +} +static inline bool set_saflok_mfc_lock_id(saflok_mfc_data_t *data, uint32_t lock_id) { + if (lock_id > 0x3FFFu) { + PrintAndLogEx(ERR, _RED_("ERROR:") " lock_id out of range (%08x)", lock_id); + return false; } - static inline bool set_saflok_mfc_card_id(saflok_mfc_data_t *data, uint32_t card_id) { - if (card_id > 0xFFu) { - PrintAndLogEx(ERR, _RED_("ERROR:") " card_id out of range (%08x)", card_id); - return false; - } - bool success = set_bitfield(data, 8, 8, card_id); - return success; + bool success = set_bitfield(data, 18, 14, lock_id); + return success; +} +static inline uint16_t get_saflok_mfc_pass_number(const saflok_mfc_data_t *data) { + return (uint16_t)get_bitfield(data, 32, 12); +} +static inline bool set_saflok_mfc_pass_number(saflok_mfc_data_t *data, uint32_t pass_number) { + if (pass_number > 0xFFFu) { + PrintAndLogEx(ERR, _RED_("ERROR:") " pass_number out of range (%08x)", pass_number); + return false; } - static inline uint8_t get_saflok_mfc_opening_key(const saflok_mfc_data_t *data) { - return (uint8_t)get_bitfield(data, 16, 2); + bool success = set_bitfield(data, 32, 12, pass_number); + return success; +} +static inline uint16_t get_saflok_mfc_sequence_and_combination(const saflok_mfc_data_t *data) { + return (uint16_t)get_bitfield(data, 44, 12); +} +static inline bool set_saflok_mfc_sequence_and_combination(saflok_mfc_data_t *data, uint32_t sequence_and_combination) { + if (sequence_and_combination > 0xFFFu) { + PrintAndLogEx(ERR, _RED_("ERROR:") " sequence_and_combination out of range (%08x)", sequence_and_combination); + return false; } - static inline bool set_saflok_mfc_opening_key(saflok_mfc_data_t *data, uint32_t opening_key) { - if (opening_key > 0x3u) { - PrintAndLogEx(ERR, _RED_("ERROR:") " opening_key out of range (%08x)", opening_key); - return false; - } - bool success = set_bitfield(data, 16, 2, opening_key); - return success; + bool success = set_bitfield(data, 44, 12, sequence_and_combination); + return success; +} +static inline bool get_saflok_mfc_deadbolt_override(const saflok_mfc_data_t *data) { + uint32_t result = get_bitfield(data, 56, 1); + return (result != 0); +} +static inline bool set_saflok_mfc_deadbolt_override(saflok_mfc_data_t *data, uint32_t deadbolt_override) { + bool success = set_bitfield(data, 56, 1, deadbolt_override ? 0x1 : 0x0); + return success; +} +static inline uint8_t get_saflok_mfc_restricted_days(const saflok_mfc_data_t *data) { + return (uint8_t)get_bitfield(data, 57, 7); +} +static inline bool set_saflok_mfc_restricted_days(saflok_mfc_data_t *data, uint32_t restricted_days) { + if (restricted_days > 0x7Fu) { + PrintAndLogEx(ERR, _RED_("ERROR:") " restricted_days out of range (%08x)", restricted_days); + return false; } - static inline uint16_t get_saflok_mfc_lock_id(const saflok_mfc_data_t *data) { - return (uint16_t)get_bitfield(data, 18, 14); + bool success = set_bitfield(data, 57, 7, restricted_days); + return success; +} +static inline uint32_t get_saflok_mfc_raw_interval(const saflok_mfc_data_t *data) { + return get_bitfield(data, 64, 24); +} +static inline bool set_saflok_mfc_raw_interval(saflok_mfc_data_t *data, uint32_t raw_interval) { + if (raw_interval > 0xFFFFFFu) { + PrintAndLogEx(ERR, _RED_("ERROR:") " raw_interval out of range (%08x)", raw_interval); + return false; } - static inline bool set_saflok_mfc_lock_id(saflok_mfc_data_t *data, uint32_t lock_id) { - if (lock_id > 0x3FFFu) { - PrintAndLogEx(ERR, _RED_("ERROR:") " lock_id out of range (%08x)", lock_id); - return false; - } - bool success = set_bitfield(data, 18, 14, lock_id); - return success; + bool success = set_bitfield(data, 64, 24, raw_interval); + return success; +} +static inline uint32_t get_saflok_mfc_raw_card_creation_date(const saflok_mfc_data_t *data) { + return get_bitfield(data, 88, 28); +} +static inline bool set_saflok_mfc_raw_card_creation_date(saflok_mfc_data_t *data, uint32_t raw_card_creation_date) { + if (raw_card_creation_date > 0x0FFFFFFFu) { + PrintAndLogEx(ERR, _RED_("ERROR:") " raw_card_creation_date out of range (%08x)", raw_card_creation_date); + return false; } - static inline uint16_t get_saflok_mfc_pass_number(const saflok_mfc_data_t *data) { - return (uint16_t)get_bitfield(data, 32, 12); - } - static inline bool set_saflok_mfc_pass_number(saflok_mfc_data_t *data, uint32_t pass_number) { - if (pass_number > 0xFFFu) { - PrintAndLogEx(ERR, _RED_("ERROR:") " pass_number out of range (%08x)", pass_number); - return false; - } - bool success = set_bitfield(data, 32, 12, pass_number); - return success; - } - static inline uint16_t get_saflok_mfc_sequence_and_combination(const saflok_mfc_data_t *data) { - return (uint16_t)get_bitfield(data, 44, 12); - } - static inline bool set_saflok_mfc_sequence_and_combination(saflok_mfc_data_t *data, uint32_t sequence_and_combination) { - if (sequence_and_combination > 0xFFFu) { - PrintAndLogEx(ERR, _RED_("ERROR:") " sequence_and_combination out of range (%08x)", sequence_and_combination); - return false; - } - bool success = set_bitfield(data, 44, 12, sequence_and_combination); - return success; - } - static inline bool get_saflok_mfc_deadbolt_override(const saflok_mfc_data_t *data) { - uint32_t result = get_bitfield(data, 56, 1); - return (result != 0); - } - static inline bool set_saflok_mfc_deadbolt_override(saflok_mfc_data_t *data, uint32_t deadbolt_override) { - bool success = set_bitfield(data, 56, 1, deadbolt_override ? 0x1 : 0x0); - return success; - } - static inline uint8_t get_saflok_mfc_restricted_days(const saflok_mfc_data_t *data) { - return (uint8_t)get_bitfield(data, 57, 7); - } - static inline bool set_saflok_mfc_restricted_days(saflok_mfc_data_t *data, uint32_t restricted_days) { - if (restricted_days > 0x7Fu) { - PrintAndLogEx(ERR, _RED_("ERROR:") " restricted_days out of range (%08x)", restricted_days); - return false; - } - bool success = set_bitfield(data, 57, 7, restricted_days); - return success; - } - static inline uint32_t get_saflok_mfc_raw_interval(const saflok_mfc_data_t *data) { - return get_bitfield(data, 64, 24); - } - static inline bool set_saflok_mfc_raw_interval(saflok_mfc_data_t *data, uint32_t raw_interval) { - if (raw_interval > 0xFFFFFFu) { - PrintAndLogEx(ERR, _RED_("ERROR:") " raw_interval out of range (%08x)", raw_interval); - return false; - } - bool success = set_bitfield(data, 64, 24, raw_interval); - return success; - } - static inline uint32_t get_saflok_mfc_raw_card_creation_date(const saflok_mfc_data_t *data) { - return get_bitfield(data, 88, 28); - } - static inline bool set_saflok_mfc_raw_card_creation_date(saflok_mfc_data_t *data, uint32_t raw_card_creation_date) { - if (raw_card_creation_date > 0x0FFFFFFFu) { - PrintAndLogEx(ERR, _RED_("ERROR:") " raw_card_creation_date out of range (%08x)", raw_card_creation_date); - return false; - } - bool success = set_bitfield(data, 88, 28, raw_card_creation_date); - return success; - } - static inline uint16_t get_saflok_mfc_property_id(const saflok_mfc_data_t *data) { - return get_bitfield(data, 116, 12); - } - static inline bool set_saflok_mfc_property_id(saflok_mfc_data_t *data, uint32_t property_id) { - if (property_id > 0xFFFu) { - PrintAndLogEx(ERR, _RED_("ERROR:") " property_id out of range (%08x)", property_id); - return false; - } - bool success = set_bitfield(data, 116, 12, property_id); - return success; - } - static inline uint8_t get_saflok_mfc_checksum(const saflok_mfc_data_t *data) { - return data->raw[16]; - } - static inline bool set_saflok_mfc_checksum(saflok_mfc_data_t *data, uint8_t checksum) { - data->raw[16] = checksum; - return true; + bool success = set_bitfield(data, 88, 28, raw_card_creation_date); + return success; +} +static inline uint16_t get_saflok_mfc_property_id(const saflok_mfc_data_t *data) { + return get_bitfield(data, 116, 12); +} +static inline bool set_saflok_mfc_property_id(saflok_mfc_data_t *data, uint32_t property_id) { + if (property_id > 0xFFFu) { + PrintAndLogEx(ERR, _RED_("ERROR:") " property_id out of range (%08x)", property_id); + return false; } + bool success = set_bitfield(data, 116, 12, property_id); + return success; +} +static inline uint8_t get_saflok_mfc_checksum(const saflok_mfc_data_t *data) { + return data->raw[16]; +} +static inline bool set_saflok_mfc_checksum(saflok_mfc_data_t *data, uint8_t checksum) { + data->raw[16] = checksum; + return true; +} #endif // getters and setters for each bitfield in saflok_mfc_data_t #if 1 // helpers for get/set_saflok_mfc_card_creation_date() ... do not call these directly as does not validate... - static inline uint16_t _get_saflok_mfc_card_creation_year_impl(const saflok_mfc_data_t *data) { - uint8_t creation_year_bits_high = (data->raw[14] & 0x70u); - uint8_t creation_year_bits_low = (data->raw[11] & 0xF0u) >> 4; - uint8_t creation_year_bits = creation_year_bits_high | creation_year_bits_low; - uint16_t creation_year = 1980u + creation_year_bits; // automatically extends to uint16_t - return creation_year; +static inline uint16_t _get_saflok_mfc_card_creation_year_impl(const saflok_mfc_data_t *data) { + uint8_t creation_year_bits_high = (data->raw[14] & 0x70u); + uint8_t creation_year_bits_low = (data->raw[11] & 0xF0u) >> 4; + uint8_t creation_year_bits = creation_year_bits_high | creation_year_bits_low; + uint16_t creation_year = 1980u + creation_year_bits; // automatically extends to uint16_t + return creation_year; +} +static inline bool _set_saflok_mfc_card_creation_year_impl(saflok_mfc_data_t *data, uint16_t year) { + if (year < 1980u || year > (1980u+0x7Fu)) { + PrintAndLogEx(ERR, _RED_("ERROR:") " year out of range (%u)", year); + return false; } - static inline bool _set_saflok_mfc_card_creation_year_impl(saflok_mfc_data_t *data, uint16_t year) { - if (year < 1980u || year > (1980u+0x7Fu)) { - PrintAndLogEx(ERR, _RED_("ERROR:") " year out of range (%u)", year); - return false; - } - uint16_t year_bits = year - 1980u; - uint8_t creation_year_bits_high = year_bits & 0x70u; - uint8_t creation_year_bits_low = (year_bits & 0x0Fu) << 4; - data->raw[14] = (data->raw[14] & 0x8Fu) | creation_year_bits_high; - data->raw[11] = (data->raw[11] & 0x0Fu) | creation_year_bits_low; - return true; - } - static inline uint8_t _get_saflok_mfc_card_creation_month_impl(const saflok_mfc_data_t *data) { - // should be in range [1..12] ... value of zero is invalid - return (data->raw[11] & 0x0Fu); - } - static inline bool _set_saflok_mfc_card_creation_month_impl(saflok_mfc_data_t *data, uint8_t month) { - if (month < 1 || month > 12) { - PrintAndLogEx(ERR, _RED_("ERROR:") " month out of range (%u)", month); - return false; - } - data->raw[11] = (data->raw[11] & 0xF0u) | (month & 0x0Fu); - return true; - } - static inline uint8_t _get_saflok_mfc_card_creation_day_impl(const saflok_mfc_data_t *data) { - return ((data->raw[12] >> 3) & 0x1Fu); - } - static inline bool _set_saflok_mfc_card_creation_day_impl(saflok_mfc_data_t *data, uint8_t day) { - data->raw[12] = (data->raw[12] & 0x07u) | ((day & 0x1Fu) << 3); - return true; - } - static inline uint8_t _get_saflok_mfc_card_creation_hour_impl(const saflok_mfc_data_t *data) { - // low three bits from raw[12] - // high two bits from raw[13] - return (((data->raw[12] & 0x07u) << 2) | (data->raw[13] >> 6)); - } - static inline bool _set_saflok_mfc_card_creation_hour_impl(saflok_mfc_data_t *data, uint8_t hour) { - data->raw[12] = (data->raw[12] & 0xF8u) | ((hour >> 2) & 0x07u); - data->raw[13] = (data->raw[13] & 0x3Fu) | ((hour & 0x03u) << 6); - return true; - } - static inline uint8_t _get_saflok_mfc_card_creation_minute_impl(const saflok_mfc_data_t *data) { - return (data->raw[13] & 0x3Fu); - } - static inline bool _set_saflok_mfc_card_creation_minute_impl(saflok_mfc_data_t *data, uint8_t minute) { - data->raw[13] = (data->raw[13] & 0xC0u) | (minute & 0x3Fu); - return true; + uint16_t year_bits = year - 1980u; + uint8_t creation_year_bits_high = year_bits & 0x70u; + uint8_t creation_year_bits_low = (year_bits & 0x0Fu) << 4; + data->raw[14] = (data->raw[14] & 0x8Fu) | creation_year_bits_high; + data->raw[11] = (data->raw[11] & 0x0Fu) | creation_year_bits_low; + return true; +} +static inline uint8_t _get_saflok_mfc_card_creation_month_impl(const saflok_mfc_data_t *data) { + // should be in range [1..12] ... value of zero is invalid + return (data->raw[11] & 0x0Fu); +} +static inline bool _set_saflok_mfc_card_creation_month_impl(saflok_mfc_data_t *data, uint8_t month) { + if (month < 1 || month > 12) { + PrintAndLogEx(ERR, _RED_("ERROR:") " month out of range (%u)", month); + return false; } + data->raw[11] = (data->raw[11] & 0xF0u) | (month & 0x0Fu); + return true; +} +static inline uint8_t _get_saflok_mfc_card_creation_day_impl(const saflok_mfc_data_t *data) { + return ((data->raw[12] >> 3) & 0x1Fu); +} +static inline bool _set_saflok_mfc_card_creation_day_impl(saflok_mfc_data_t *data, uint8_t day) { + data->raw[12] = (data->raw[12] & 0x07u) | ((day & 0x1Fu) << 3); + return true; +} +static inline uint8_t _get_saflok_mfc_card_creation_hour_impl(const saflok_mfc_data_t *data) { + // low three bits from raw[12] + // high two bits from raw[13] + return (((data->raw[12] & 0x07u) << 2) | (data->raw[13] >> 6)); +} +static inline bool _set_saflok_mfc_card_creation_hour_impl(saflok_mfc_data_t *data, uint8_t hour) { + data->raw[12] = (data->raw[12] & 0xF8u) | ((hour >> 2) & 0x07u); + data->raw[13] = (data->raw[13] & 0x3Fu) | ((hour & 0x03u) << 6); + return true; +} +static inline uint8_t _get_saflok_mfc_card_creation_minute_impl(const saflok_mfc_data_t *data) { + return (data->raw[13] & 0x3Fu); +} +static inline bool _set_saflok_mfc_card_creation_minute_impl(saflok_mfc_data_t *data, uint8_t minute) { + data->raw[13] = (data->raw[13] & 0xC0u) | (minute & 0x3Fu); + return true; +} #endif // // helpers for get/set_saflok_mfc_card_creation_date() ... do not call these directly as does not validate... #if 1 // getters and setters for creation date - static inline bool is_saflok_mfc_datetime_valid(const saflok_mfc_datetime_t *date) { - bool result = true; - if ((date->year < 1980) || (date->year > (1980u+0xFFu)) ) { - PrintAndLogEx(WARNING, "year out of range (%d)", date->year); - result = false; - } - if ((date->month < 1) || (date->month > 12)) { - PrintAndLogEx(WARNING, "month out of range (%d)", date->month); - result = false; - } - uint8_t max_days = get_days_in_month(date->year, date->month); - if ((date->day < 1u) || (date->day > max_days)) { - PrintAndLogEx(WARNING, "day out of range (%d) for month %d year %d", date->day, date->month, date->year); - result = false; - } - if (date->hour > 23) { - PrintAndLogEx(WARNING, "hour out of range (%d)", date->hour); - result = false; - } - if (date->minute > 59) { - PrintAndLogEx(WARNING, "minute out of range (%d)", date->minute); - result = false; - } - return result; +static inline bool is_saflok_mfc_datetime_valid(const saflok_mfc_datetime_t *date) { + bool result = true; + if ((date->year < 1980) || (date->year > (1980u+0xFFu))) { + PrintAndLogEx(WARNING, "year out of range (%d)", date->year); + result = false; } - static inline saflok_mfc_datetime_t get_saflok_mfc_card_creation_datetime( - const saflok_mfc_data_t *data - ) { - saflok_mfc_datetime_t date = { - .year = _get_saflok_mfc_card_creation_year_impl(data), - .month = _get_saflok_mfc_card_creation_month_impl(data), - .day = _get_saflok_mfc_card_creation_day_impl(data), - .hour = _get_saflok_mfc_card_creation_hour_impl(data), - .minute = _get_saflok_mfc_card_creation_minute_impl(data) - }; - if (!is_saflok_mfc_datetime_valid(&date)) { - PrintAndLogEx(WARNING, "Warning: creation date appears invalid: %04d-%02d-%02dT%02d:%02d", - date.year, date.month, date.day, date.hour, date.minute - ); - } - return date; + if ((date->month < 1) || (date->month > 12)) { + PrintAndLogEx(WARNING, "month out of range (%d)", date->month); + result = false; } - static inline bool set_saflok_mfc_card_creation_datetime(saflok_mfc_data_t * data, const saflok_mfc_datetime_t * date) { - if (!is_saflok_mfc_datetime_valid(date)) { - PrintAndLogEx(ERR, _RED_("ERROR:") " creation date is invalid"); - return false; - } - bool result = - _set_saflok_mfc_card_creation_year_impl(data, date->year) && - _set_saflok_mfc_card_creation_month_impl(data, date->month) && - _set_saflok_mfc_card_creation_day_impl(data, date->day) && - _set_saflok_mfc_card_creation_hour_impl(data, date->hour) && - _set_saflok_mfc_card_creation_minute_impl(data, date->minute); - if (!result) { - PrintAndLogEx(ERR, _RED_("ERROR:") " failed to set creation date of %04d-%02d-%02dT%02d:%02d", - date->year, date->month, date->day, date->hour, date->minute - ); - } - return result; + uint8_t max_days = get_days_in_month(date->year, date->month); + if ((date->day < 1u) || (date->day > max_days)) { + PrintAndLogEx(WARNING, "day out of range (%d) for month %d year %d", date->day, date->month, date->year); + result = false; } + if (date->hour > 23) { + PrintAndLogEx(WARNING, "hour out of range (%d)", date->hour); + result = false; + } + if (date->minute > 59) { + PrintAndLogEx(WARNING, "minute out of range (%d)", date->minute); + result = false; + } + return result; +} +static inline saflok_mfc_datetime_t get_saflok_mfc_card_creation_datetime( + const saflok_mfc_data_t *data +) { + saflok_mfc_datetime_t date = { + .year = _get_saflok_mfc_card_creation_year_impl(data), + .month = _get_saflok_mfc_card_creation_month_impl(data), + .day = _get_saflok_mfc_card_creation_day_impl(data), + .hour = _get_saflok_mfc_card_creation_hour_impl(data), + .minute = _get_saflok_mfc_card_creation_minute_impl(data) + }; + if (!is_saflok_mfc_datetime_valid(&date)) { + PrintAndLogEx(WARNING, "Warning: creation date appears invalid: %04d-%02d-%02dT%02d:%02d", + date.year, date.month, date.day, date.hour, date.minute + ); + } + return date; +} +static inline bool set_saflok_mfc_card_creation_datetime(saflok_mfc_data_t * data, const saflok_mfc_datetime_t * date) { + if (!is_saflok_mfc_datetime_valid(date)) { + PrintAndLogEx(ERR, _RED_("ERROR:") " creation date is invalid"); + return false; + } + bool result = + _set_saflok_mfc_card_creation_year_impl(data, date->year) && + _set_saflok_mfc_card_creation_month_impl(data, date->month) && + _set_saflok_mfc_card_creation_day_impl(data, date->day) && + _set_saflok_mfc_card_creation_hour_impl(data, date->hour) && + _set_saflok_mfc_card_creation_minute_impl(data, date->minute); + if (!result) { + PrintAndLogEx(ERR, _RED_("ERROR:") " failed to set creation date of %04d-%02d-%02dT%02d:%02d", + date->year, date->month, date->day, date->hour, date->minute + ); + } + return result; +} #endif // getters and setters for creation date components #if 1 // helpers for get/set_saflok_mfc_expiration_date() - static inline uint8_t _get_saflok_mfc_interval_years_impl(const saflok_mfc_data_t *data) { - // supports up to 15 year intervals(!) - return (data->raw[8] >> 4); +static inline uint8_t _get_saflok_mfc_interval_years_impl(const saflok_mfc_data_t *data) { + // supports up to 15 year intervals(!) + return (data->raw[8] >> 4); +} +static inline bool _set_saflok_mfc_interval_years_impl(saflok_mfc_data_t *data, uint32_t years) { + if (years > 0xFu) { + PrintAndLogEx(ERR, _RED_("ERROR:") " interval years out of range (%u)", years); + return false; } - static inline bool _set_saflok_mfc_interval_years_impl(saflok_mfc_data_t *data, uint32_t years) { - if (years > 0xFu) { - PrintAndLogEx(ERR, _RED_("ERROR:") " interval years out of range (%u)", years); - return false; - } - data->raw[8] = (data->raw[8] & 0x0Fu) | ((years & 0xFFu) << 4); - return true; + data->raw[8] = (data->raw[8] & 0x0Fu) | ((years & 0xFFu) << 4); + return true; +} +static inline uint8_t _get_saflok_mfc_interval_months_impl(const saflok_mfc_data_t *data) { + uint8_t months = data->raw[8] & 0x0Fu; + if (months >= 12u) { + PrintAndLogEx(WARNING, "Warning: interval months appears invalid (%u)", months); } - static inline uint8_t _get_saflok_mfc_interval_months_impl(const saflok_mfc_data_t *data) { - uint8_t months = data->raw[8] & 0x0Fu; - if (months >= 12u) { - PrintAndLogEx(WARNING, "Warning: interval months appears invalid (%u)", months); - } - return months; + return months; +} +static inline bool _set_saflok_mfc_interval_months_impl(saflok_mfc_data_t *data, uint8_t months) { + if (months >= 12u) { + PrintAndLogEx(ERR, _RED_("ERROR:") " interval months out of range (%u)", months); + return false; } - static inline bool _set_saflok_mfc_interval_months_impl(saflok_mfc_data_t *data, uint8_t months) { - if (months >= 12u) { - PrintAndLogEx(ERR, _RED_("ERROR:") " interval months out of range (%u)", months); - return false; - } - data->raw[8] = (data->raw[8] & 0xF0u) | (months & 0x0Fu); - return true; + data->raw[8] = (data->raw[8] & 0xF0u) | (months & 0x0Fu); + return true; +} +static inline uint8_t _get_saflok_mfc_interval_days_impl(const saflok_mfc_data_t *data) { + uint8_t days = (data->raw[9] >> 3) & 0x1Fu; + if (days > 31u) { + PrintAndLogEx(WARNING, "Warning: interval days appears invalid (%u)", days); } - static inline uint8_t _get_saflok_mfc_interval_days_impl(const saflok_mfc_data_t *data) { - uint8_t days = (data->raw[9] >> 3) & 0x1Fu; - if (days > 31u) { - PrintAndLogEx(WARNING, "Warning: interval days appears invalid (%u)", days); - } - return days; + return days; +} +static inline bool _set_saflok_mfc_interval_days_impl(saflok_mfc_data_t *data, uint8_t days) { + if (days > 31u) { + PrintAndLogEx(ERR, _RED_("ERROR:") " interval days out of range (%u)", days); + return false; } - static inline bool _set_saflok_mfc_interval_days_impl(saflok_mfc_data_t *data, uint8_t days) { - if (days > 31u) { - PrintAndLogEx(ERR, _RED_("ERROR:") " interval days out of range (%u)", days); - return false; - } - data->raw[9] = (data->raw[9] & 0x07u) | ((days & 0x1Fu) << 3); - return true; + data->raw[9] = (data->raw[9] & 0x07u) | ((days & 0x1Fu) << 3); + return true; +} +static inline uint8_t _get_saflok_mfc_interval_hours_impl(const saflok_mfc_data_t *data) { + // low three bits from raw[9] + // top two bits from raw[10] + uint8_t hours = ((data->raw[9] & 0x07u) << 2) | (data->raw[10] >> 6); + if (hours > 23u) { + PrintAndLogEx(WARNING, "Warning: interval hours appears invalid (%u)", hours); } - static inline uint8_t _get_saflok_mfc_interval_hours_impl(const saflok_mfc_data_t *data) { - // low three bits from raw[9] - // top two bits from raw[10] - uint8_t hours = ((data->raw[9] & 0x07u) << 2) | (data->raw[10] >> 6); - if (hours > 23u) { - PrintAndLogEx(WARNING, "Warning: interval hours appears invalid (%u)", hours); - } - return hours; + return hours; +} +static inline bool _set_saflok_mfc_interval_hours_impl(saflok_mfc_data_t *data, uint8_t hours) { + if (hours > 23u) { + PrintAndLogEx(ERR, _RED_("ERROR:") " interval hours out of range (%u)", hours); + return false; } - static inline bool _set_saflok_mfc_interval_hours_impl(saflok_mfc_data_t *data, uint8_t hours) { - if (hours > 23u) { - PrintAndLogEx(ERR, _RED_("ERROR:") " interval hours out of range (%u)", hours); - return false; - } - // five bit value split across two bytes: - // three MSB go into the low three bits from raw[9] - // two LSB go into the top two bits from raw[10] - data->raw[9] = (data->raw[9] & 0xF8u) | ((hours >> 2) & 0x07u); - data->raw[10] = (data->raw[10] & 0x3Fu) | ((hours & 0x03u) << 6); - return true; + // five bit value split across two bytes: + // three MSB go into the low three bits from raw[9] + // two LSB go into the top two bits from raw[10] + data->raw[9] = (data->raw[9] & 0xF8u) | ((hours >> 2) & 0x07u); + data->raw[10] = (data->raw[10] & 0x3Fu) | ((hours & 0x03u) << 6); + return true; +} +static inline uint8_t _get_saflok_mfc_interval_minutes_impl(const saflok_mfc_data_t *data) { + uint8_t minutes = (data->raw[10] & 0x3Fu); + if (minutes > 59u) { + PrintAndLogEx(WARNING, "Warning: interval minutes appears invalid (%u)", minutes); } - static inline uint8_t _get_saflok_mfc_interval_minutes_impl(const saflok_mfc_data_t *data) { - uint8_t minutes = (data->raw[10] & 0x3Fu); - if (minutes > 59u) { - PrintAndLogEx(WARNING, "Warning: interval minutes appears invalid (%u)", minutes); - } - return minutes; - } - static inline bool _set_saflok_mfc_interval_minutes_impl(saflok_mfc_data_t *data, uint8_t minutes) { - if (minutes > 59u) { - PrintAndLogEx(ERR, _RED_("ERROR:") " interval minutes out of range (%u)", minutes); - return false; - } - data->raw[10] = (data->raw[10] & 0xC0u) | (minutes & 0x3Fu); - return true; + return minutes; +} +static inline bool _set_saflok_mfc_interval_minutes_impl(saflok_mfc_data_t *data, uint8_t minutes) { + if (minutes > 59u) { + PrintAndLogEx(ERR, _RED_("ERROR:") " interval minutes out of range (%u)", minutes); + return false; } + data->raw[10] = (data->raw[10] & 0xC0u) | (minutes & 0x3Fu); + return true; +} #endif // getters for interval (expiration) components #if 1 // Setting the interval date is based on the creation date. - static saflok_mfc_datetime_offset_t get_saflok_mfc_interval( - const saflok_mfc_data_t *data - ) { - saflok_mfc_datetime_offset_t offset = { - .years = _get_saflok_mfc_interval_years_impl(data), - .months = _get_saflok_mfc_interval_months_impl(data), - .days = _get_saflok_mfc_interval_days_impl(data), - .hours = _get_saflok_mfc_interval_hours_impl(data), - .minutes = _get_saflok_mfc_interval_minutes_impl(data) - }; - return offset; +static saflok_mfc_datetime_offset_t get_saflok_mfc_interval( + const saflok_mfc_data_t *data +) { + saflok_mfc_datetime_offset_t offset = { + .years = _get_saflok_mfc_interval_years_impl(data), + .months = _get_saflok_mfc_interval_months_impl(data), + .days = _get_saflok_mfc_interval_days_impl(data), + .hours = _get_saflok_mfc_interval_hours_impl(data), + .minutes = _get_saflok_mfc_interval_minutes_impl(data) + }; + return offset; +} +static bool set_saflok_mfc_interval( + saflok_mfc_data_t *data, + saflok_mfc_datetime_offset_t offset +) { + bool result = + _set_saflok_mfc_interval_years_impl(data, offset.years) && + _set_saflok_mfc_interval_months_impl(data, offset.months) && + _set_saflok_mfc_interval_days_impl(data, offset.days) && + _set_saflok_mfc_interval_hours_impl(data, offset.hours) && + _set_saflok_mfc_interval_minutes_impl(data, offset.minutes); + return result; +} +static saflok_mfc_datetime_t add_offset( + const saflok_mfc_datetime_t *base, + const saflok_mfc_datetime_offset_t offset +) { + + static const int MY_DEBUG_LEVEL = DEBUG; + // adding dates is non-trivial. + // luckily, there's already a standard for this... + struct tm tm = { + .tm_year = base->year - 1900, // years since 1900 + .tm_mon = base->month - 1, // range: [0..11] + .tm_mday = base->day, // range: [1..31] + .tm_hour = base->hour, // range: [0..23] + .tm_min = base->minute, // range: [0..59] + .tm_sec = 30, // selecting midpoint to avoid leapseconds changing minute + .tm_isdst = 0, // UTC has no DST + }; + + PrintAndLogEx(MY_DEBUG_LEVEL, "Base date: %04u-%02u-%02uT%02u:%02u", + base->year, base->month, base->day, + base->hour, base->minute + ); + PrintAndLogEx(MY_DEBUG_LEVEL, "As struct tm: %04d-%02d-%02dT%02d:%02d", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min + ); + PrintAndLogEx(MY_DEBUG_LEVEL, "Offset to add: %u years, %u months, %u days, %u hours, %u minutes", + offset.years, offset.months, offset.days, + offset.hours, offset.minutes + ); + + // add the offsets ... and it's OK for them to be out of range + tm.tm_year += offset.years; + tm.tm_mon += offset.months; + tm.tm_mday += offset.days; + tm.tm_hour += offset.hours; + tm.tm_min += offset.minutes; + + PrintAndLogEx(MY_DEBUG_LEVEL, "With Offset (pre-normalization): %04d-%02d-%02dT%02d:%02d", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min + ); + + if (tm.tm_min >= 60) { + tm.tm_hour += tm.tm_min / 60; + tm.tm_min = tm.tm_min % 60; + PrintAndLogEx(MY_DEBUG_LEVEL, "Normalized minutes: %04d-%02d-%02dT%02d:%02d", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min + ); + } - static bool set_saflok_mfc_interval( - saflok_mfc_data_t *data, - saflok_mfc_datetime_offset_t offset - ) { - bool result = - _set_saflok_mfc_interval_years_impl(data, offset.years) && - _set_saflok_mfc_interval_months_impl(data, offset.months) && - _set_saflok_mfc_interval_days_impl(data, offset.days) && - _set_saflok_mfc_interval_hours_impl(data, offset.hours) && - _set_saflok_mfc_interval_minutes_impl(data, offset.minutes); - return result; + if (tm.tm_hour >= 24) { + tm.tm_mday += tm.tm_hour / 24; + tm.tm_hour = tm.tm_hour % 24; + PrintAndLogEx(MY_DEBUG_LEVEL, "Normalized hours: %04d-%02d-%02dT%02d:%02d", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min + ); } - static saflok_mfc_datetime_t add_offset( - const saflok_mfc_datetime_t *base, - const saflok_mfc_datetime_offset_t offset + // variable days per month ... loop is simplest option + for (uint8_t days_in_month = get_days_in_month(tm.tm_year + 1900, tm.tm_mon + 1); + tm.tm_mday > days_in_month; + days_in_month = get_days_in_month(tm.tm_year + 1900, tm.tm_mon + 1) ) { - - static const int MY_DEBUG_LEVEL = DEBUG; - // adding dates is non-trivial. - // luckily, there's already a standard for this... - struct tm tm = { - .tm_year = base->year - 1900, // years since 1900 - .tm_mon = base->month - 1, // range: [0..11] - .tm_mday = base->day, // range: [1..31] - .tm_hour = base->hour, // range: [0..23] - .tm_min = base->minute, // range: [0..59] - .tm_sec = 30, // selecting midpoint to avoid leapseconds changing minute - .tm_isdst = 0, // UTC has no DST - }; - - PrintAndLogEx(MY_DEBUG_LEVEL, "Base date: %04u-%02u-%02uT%02u:%02u", - base->year, base->month, base->day, - base->hour, base->minute - ); - PrintAndLogEx(MY_DEBUG_LEVEL, "As struct tm: %04d-%02d-%02dT%02d:%02d", - tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, - tm.tm_hour, tm.tm_min - ); - PrintAndLogEx(MY_DEBUG_LEVEL, "Offset to add: %u years, %u months, %u days, %u hours, %u minutes", - offset.years, offset.months, offset.days, - offset.hours, offset.minutes - ); - - // add the offsets ... and it's OK for them to be out of range - tm.tm_year += offset.years; - tm.tm_mon += offset.months; - tm.tm_mday += offset.days; - tm.tm_hour += offset.hours; - tm.tm_min += offset.minutes; - - PrintAndLogEx(MY_DEBUG_LEVEL, "With Offset (pre-normalization): %04d-%02d-%02dT%02d:%02d", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min - ); - - if (tm.tm_min >= 60) { - tm.tm_hour += tm.tm_min / 60; - tm.tm_min = tm.tm_min % 60; - PrintAndLogEx(MY_DEBUG_LEVEL, "Normalized minutes: %04d-%02d-%02dT%02d:%02d", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min - ); - - } - if (tm.tm_hour >= 24) { - tm.tm_mday += tm.tm_hour / 24; - tm.tm_hour = tm.tm_hour % 24; - PrintAndLogEx(MY_DEBUG_LEVEL, "Normalized hours: %04d-%02d-%02dT%02d:%02d", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min - ); - } - // variable days per month ... loop is simplest option - for (uint8_t days_in_month = get_days_in_month(tm.tm_year + 1900, tm.tm_mon + 1); - tm.tm_mday > days_in_month; - days_in_month = get_days_in_month(tm.tm_year + 1900, tm.tm_mon + 1) - ) { - tm.tm_mon ++; - tm.tm_mday -= days_in_month; - if (tm.tm_mon >= 12) { - tm.tm_year ++; - tm.tm_mon -= 12; - } - PrintAndLogEx(MY_DEBUG_LEVEL, "Normalized days: %04d-%02d-%02dT%02d:%02d", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min - ); - } + tm.tm_mon ++; + tm.tm_mday -= days_in_month; if (tm.tm_mon >= 12) { - tm.tm_year += tm.tm_mon / 12; - tm.tm_mon = tm.tm_mon % 12; - PrintAndLogEx(MY_DEBUG_LEVEL, "Normalized months: %04d-%02d-%02dT%02d:%02d", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min - ); + tm.tm_year ++; + tm.tm_mon -= 12; } - PrintAndLogEx(MY_DEBUG_LEVEL, "Final normalized date: %04d-%02d-%02dT%02d:%02d", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min - ); + PrintAndLogEx(MY_DEBUG_LEVEL, "Normalized days: %04d-%02d-%02dT%02d:%02d", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min + ); + } + if (tm.tm_mon >= 12) { + tm.tm_year += tm.tm_mon / 12; + tm.tm_mon = tm.tm_mon % 12; + PrintAndLogEx(MY_DEBUG_LEVEL, "Normalized months: %04d-%02d-%02dT%02d:%02d", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min + ); + } + PrintAndLogEx(MY_DEBUG_LEVEL, "Final normalized date: %04d-%02d-%02dT%02d:%02d", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min + ); - // and finally convert back into saflok_mfc_datetime_t - saflok_mfc_datetime_t result = { - .year = tm.tm_year + 1900, - .month = tm.tm_mon + 1, - .day = tm.tm_mday, - .hour = tm.tm_hour, - .minute = tm.tm_min - }; - PrintAndLogEx(MY_DEBUG_LEVEL, "Converted back to saflok_mfc_datetime_t: %04d-%02d-%02dT%02d:%02d", - result.year, result.month, result.day, - result.hour, result.minute - ); + // and finally convert back into saflok_mfc_datetime_t + saflok_mfc_datetime_t result = { + .year = tm.tm_year + 1900, + .month = tm.tm_mon + 1, + .day = tm.tm_mday, + .hour = tm.tm_hour, + .minute = tm.tm_min + }; + PrintAndLogEx(MY_DEBUG_LEVEL, "Converted back to saflok_mfc_datetime_t: %04d-%02d-%02dT%02d:%02d", + result.year, result.month, result.day, + result.hour, result.minute + ); + return result; +} +static saflok_mfc_datetime_offset_t get_datetime_offset( + const saflok_mfc_datetime_t *start, + const saflok_mfc_datetime_t *end +) { + + enum logLevel MYDBG = DEBUG; + saflok_mfc_datetime_offset_t result = {0}; + + if (!is_saflok_mfc_datetime_valid(start)) { + PrintAndLogEx(ERR, _RED_("ERROR:") " start date is invalid"); return result; } - static saflok_mfc_datetime_offset_t get_datetime_offset( - const saflok_mfc_datetime_t *start, - const saflok_mfc_datetime_t *end - ) { - - enum logLevel MYDBG = DEBUG; - saflok_mfc_datetime_offset_t result = {0}; - - if (!is_saflok_mfc_datetime_valid(start)) { - PrintAndLogEx(ERR, _RED_("ERROR:") " start date is invalid"); - return result; - } - if (!is_saflok_mfc_datetime_valid(end)) { - PrintAndLogEx(ERR, _RED_("ERROR:") " end date is invalid"); - return result; - } - - PrintAndLogEx(MYDBG, "Calculating offset from %04u-%02u-%02uT%02u:%02u to %04u-%02u-%02uT%02u:%02u", - start->year, start->month, start->day, start->hour, start->minute, - end->year, end->month, end->day, end->hour, end->minute - ); - // use `struct tm`, which uses signed integers for each part - // and thus allows simpler checks for borrowing - struct tm diff = { - .tm_year = end->year - start->year, - .tm_mon = end->month - start->month, - .tm_mday = end->day - start->day, - .tm_hour = end->hour - start->hour, - .tm_min = end->minute - start->minute, - }; - PrintAndLogEx(MYDBG, "Initial diff: %d years, %d months, %d days, %d hours, %d minutes", - diff.tm_year, diff.tm_mon, diff.tm_mday, diff.tm_hour, diff.tm_min - ); - if (diff.tm_min < 0) { - diff.tm_min += 60; - diff.tm_hour -= 1; - } - if (diff.tm_hour < 0) { - diff.tm_hour += 24; - diff.tm_mday -= 1; - } - if (diff.tm_mday < 0) { - // determine days in previous month - uint16_t tgt_year = end->year - (end->month == 1 ? 1 : 0); - uint8_t tgt_month = (end->month == 1 ? 12 : (end->month - 1)); - uint8_t days_in_prev_month = get_days_in_month(tgt_year, tgt_month); - PrintAndLogEx(MYDBG, "Borrowing days from month %02u of year %04u which has %02u days", - tgt_month, tgt_year, days_in_prev_month - ); - - // borrow from previous month - diff.tm_mon -= 1; - diff.tm_mday += days_in_prev_month; - } - if (diff.tm_mon < 0) { - diff.tm_mon += 12; - diff.tm_year -= 1; - } - - result.years = diff.tm_year; - result.months = diff.tm_mon; - result.days = diff.tm_mday; - result.hours = diff.tm_hour; - result.minutes = diff.tm_min; - PrintAndLogEx(MYDBG, "Final offset: %d years, %d months, %d days, %d hours, %d minutes", - result.years, result.months, result.days, result.hours, result.minutes - ); + if (!is_saflok_mfc_datetime_valid(end)) { + PrintAndLogEx(ERR, _RED_("ERROR:") " end date is invalid"); return result; } - static saflok_mfc_datetime_t get_saflok_mfc_card_expiration_datetime( - const saflok_mfc_data_t *data - ) { - static const int MY_DEBUG_LEVEL = DEBUG; - saflok_mfc_datetime_t creation_date = get_saflok_mfc_card_creation_datetime(data); - saflok_mfc_datetime_offset_t offset = get_saflok_mfc_interval(data); - PrintAndLogEx(MY_DEBUG_LEVEL, "Card Creation Date: %04u-%02u-%02uT%02u:%02u", - creation_date.year, creation_date.month, creation_date.day, - creation_date.hour, creation_date.minute - ); - PrintAndLogEx(MY_DEBUG_LEVEL, "Card Interval Offset: %u years, %u months, %u days, %u hours, %u minutes", - offset.years, offset.months, offset.days, - offset.hours, offset.minutes - ); - saflok_mfc_datetime_t expiration = add_offset(&creation_date, offset); - PrintAndLogEx(MY_DEBUG_LEVEL, "Calculated Expiration Date: %04u-%02u-%02uT%02u:%02u", - expiration.year, expiration.month, expiration.day, - expiration.hour, expiration.minute - ); - return expiration; + + PrintAndLogEx(MYDBG, "Calculating offset from %04u-%02u-%02uT%02u:%02u to %04u-%02u-%02uT%02u:%02u", + start->year, start->month, start->day, start->hour, start->minute, + end->year, end->month, end->day, end->hour, end->minute + ); + // use `struct tm`, which uses signed integers for each part + // and thus allows simpler checks for borrowing + struct tm diff = { + .tm_year = end->year - start->year, + .tm_mon = end->month - start->month, + .tm_mday = end->day - start->day, + .tm_hour = end->hour - start->hour, + .tm_min = end->minute - start->minute, + }; + PrintAndLogEx(MYDBG, "Initial diff: %d years, %d months, %d days, %d hours, %d minutes", + diff.tm_year, diff.tm_mon, diff.tm_mday, diff.tm_hour, diff.tm_min + ); + if (diff.tm_min < 0) { + diff.tm_min += 60; + diff.tm_hour -= 1; } - static bool set_saflok_mfc_card_expiration_datetime( - saflok_mfc_data_t *data, - const saflok_mfc_datetime_t * expiration - ) { - if (!is_saflok_mfc_datetime_valid(expiration)) { - PrintAndLogEx(ERR, _RED_("ERROR:") " expiration date is invalid"); - return false; - } - saflok_mfc_datetime_t creation_datetime = get_saflok_mfc_card_creation_datetime(data); - saflok_mfc_datetime_offset_t offset = get_datetime_offset(&creation_datetime, expiration); - bool result = set_saflok_mfc_interval(data, offset); - return result; + if (diff.tm_hour < 0) { + diff.tm_hour += 24; + diff.tm_mday -= 1; } + if (diff.tm_mday < 0) { + // determine days in previous month + uint16_t tgt_year = end->year - (end->month == 1 ? 1 : 0); + uint8_t tgt_month = (end->month == 1 ? 12 : (end->month - 1)); + uint8_t days_in_prev_month = get_days_in_month(tgt_year, tgt_month); + PrintAndLogEx(MYDBG, "Borrowing days from month %02u of year %04u which has %02u days", + tgt_month, tgt_year, days_in_prev_month + ); + + // borrow from previous month + diff.tm_mon -= 1; + diff.tm_mday += days_in_prev_month; + } + if (diff.tm_mon < 0) { + diff.tm_mon += 12; + diff.tm_year -= 1; + } + + result.years = diff.tm_year; + result.months = diff.tm_mon; + result.days = diff.tm_mday; + result.hours = diff.tm_hour; + result.minutes = diff.tm_min; + PrintAndLogEx(MYDBG, "Final offset: %d years, %d months, %d days, %d hours, %d minutes", + result.years, result.months, result.days, result.hours, result.minutes + ); + return result; +} +static saflok_mfc_datetime_t get_saflok_mfc_card_expiration_datetime( + const saflok_mfc_data_t *data +) { + static const int MY_DEBUG_LEVEL = DEBUG; + saflok_mfc_datetime_t creation_date = get_saflok_mfc_card_creation_datetime(data); + saflok_mfc_datetime_offset_t offset = get_saflok_mfc_interval(data); + PrintAndLogEx(MY_DEBUG_LEVEL, "Card Creation Date: %04u-%02u-%02uT%02u:%02u", + creation_date.year, creation_date.month, creation_date.day, + creation_date.hour, creation_date.minute + ); + PrintAndLogEx(MY_DEBUG_LEVEL, "Card Interval Offset: %u years, %u months, %u days, %u hours, %u minutes", + offset.years, offset.months, offset.days, + offset.hours, offset.minutes + ); + saflok_mfc_datetime_t expiration = add_offset(&creation_date, offset); + PrintAndLogEx(MY_DEBUG_LEVEL, "Calculated Expiration Date: %04u-%02u-%02uT%02u:%02u", + expiration.year, expiration.month, expiration.day, + expiration.hour, expiration.minute + ); + return expiration; +} +static bool set_saflok_mfc_card_expiration_datetime( + saflok_mfc_data_t *data, + const saflok_mfc_datetime_t *expiration +) { + if (!is_saflok_mfc_datetime_valid(expiration)) { + PrintAndLogEx(ERR, _RED_("ERROR:") " expiration date is invalid"); + return false; + } + saflok_mfc_datetime_t creation_datetime = get_saflok_mfc_card_creation_datetime(data); + saflok_mfc_datetime_offset_t offset = get_datetime_offset(&creation_datetime, expiration); + bool result = set_saflok_mfc_interval(data, offset); + return result; +} #endif // Setting the interval date is based on the creation date. static const uint8_t c_aDecode[] = { @@ -1026,7 +1029,7 @@ static void saflok_decode(const saflok_mfc_data_t *data) { uint32_t property_id = get_saflok_mfc_property_id(data); uint32_t checksum = get_saflok_mfc_checksum(data); - PrintAndLogEx(SUCCESS, "---- NEW routines ----" ); + PrintAndLogEx(SUCCESS, "---- NEW routines ----"); PrintAndLogEx(SUCCESS, "Card Level: " _GREEN_("%u (%s)"), card_level, level_names[card_level]); PrintAndLogEx(SUCCESS, "Card Type: " _GREEN_("%u"), card_type); PrintAndLogEx(SUCCESS, "Card ID: " _GREEN_("%u"), card_id); @@ -1070,7 +1073,7 @@ static void saflok_encode( uint32_t property_id, char *dt_expiration, char *dt - ) { +) { set_saflok_mfc_card_level(data, card_level); set_saflok_mfc_card_type(data, card_type); set_saflok_mfc_card_id(data, card_id); @@ -1085,7 +1088,7 @@ static void saflok_encode( set_saflok_mfc_property_id(data, property_id); // Parsing date time string from "YYYY-MM-DDTHH:mm" into `saflok_mfc_datetime_t` - static const char * fmt = "%4u-%2u-%2uT%2u:%2u"; + static const char *fmt = "%4u-%2u-%2uT%2u:%2u"; if (true) { saflok_mfc_datetime_t creation_dt = {0}; @@ -1170,7 +1173,7 @@ static int CmdHFSaflokRead(const char *Cmd) { saflok_read_sector(0, secdata); // 64 bytes - const saflok_mfc_data_t * encrypted = (const saflok_mfc_data_t *)(secdata + 16); + const saflok_mfc_data_t *encrypted = (const saflok_mfc_data_t *)(secdata + 16); saflok_mfc_data_t decrypted = {0}; saflok_decrypt(encrypted, &decrypted); @@ -1824,7 +1827,7 @@ static int CmdHFSaflokSelfTest(const char *Cmd) { int result_test_cases = PM3_SUCCESS; for (size_t i = 0; i < ARRAYLEN(saflok_test_cases); ++i) { - const saflok_test_case_t * tc = &saflok_test_cases[i]; + const saflok_test_case_t *tc = &saflok_test_cases[i]; // encoded -> decoded -> encoded saflok_mfc_data_t tmp = {0}; @@ -1848,11 +1851,11 @@ static int CmdHFSaflokSelfTest(const char *Cmd) { if (memcmp(&tmp_dt, &tc->card_creation_datetime, sizeof(saflok_mfc_datetime_t)) != 0) { PrintAndLogEx(FAILED, "Test case %zu: card creation datetime did not match expected data.", i); PrintAndLogEx(DEBUG, " api result: %4u-%02u-%02u %02u:%02u", - tmp_dt.year, tmp_dt.month, tmp_dt.day, - tmp_dt.hour, tmp_dt.minute); + tmp_dt.year, tmp_dt.month, tmp_dt.day, + tmp_dt.hour, tmp_dt.minute); PrintAndLogEx(DEBUG, " expected result: %4u-%02u-%02u %02u:%02u", - tc->card_creation_datetime.year, tc->card_creation_datetime.month, tc->card_creation_datetime.day, - tc->card_creation_datetime.hour, tc->card_creation_datetime.minute); + tc->card_creation_datetime.year, tc->card_creation_datetime.month, tc->card_creation_datetime.day, + tc->card_creation_datetime.hour, tc->card_creation_datetime.minute); result_test_cases = PM3_EFAILED; continue; } @@ -1860,11 +1863,11 @@ static int CmdHFSaflokSelfTest(const char *Cmd) { if (memcmp(&tmp_dt, &tc->card_expiration_datetime, sizeof(saflok_mfc_datetime_t)) != 0) { PrintAndLogEx(FAILED, "Test case %zu: card expiration datetime did not match expected data.", i); PrintAndLogEx(DEBUG, " api result: %4u-%02u-%02u %02u:%02u", - tmp_dt.year, tmp_dt.month, tmp_dt.day, - tmp_dt.hour, tmp_dt.minute); + tmp_dt.year, tmp_dt.month, tmp_dt.day, + tmp_dt.hour, tmp_dt.minute); PrintAndLogEx(DEBUG, " expected result: %4u-%02u-%02u %02u:%02u", - tc->card_expiration_datetime.year, tc->card_expiration_datetime.month, tc->card_expiration_datetime.day, - tc->card_expiration_datetime.hour, tc->card_expiration_datetime.minute); + tc->card_expiration_datetime.year, tc->card_expiration_datetime.month, tc->card_expiration_datetime.day, + tc->card_expiration_datetime.hour, tc->card_expiration_datetime.minute); result_test_cases = PM3_EFAILED; continue; } @@ -1872,11 +1875,11 @@ static int CmdHFSaflokSelfTest(const char *Cmd) { if (memcmp(&tmp_offset, &tc->card_interval, sizeof(saflok_mfc_datetime_offset_t)) != 0) { PrintAndLogEx(FAILED, "Test case %zu: card interval did not match expected data.", i); PrintAndLogEx(DEBUG, " api result: %u years, %u months, %u days, %u hours, %u minutes", - tmp_offset.years, tmp_offset.months, tmp_offset.days, - tmp_offset.hours, tmp_offset.minutes); + tmp_offset.years, tmp_offset.months, tmp_offset.days, + tmp_offset.hours, tmp_offset.minutes); PrintAndLogEx(DEBUG, " expected result: %u years, %u months, %u days, %u hours, %u minutes", - tc->card_interval.years, tc->card_interval.months, tc->card_interval.days, - tc->card_interval.hours, tc->card_interval.minutes); + tc->card_interval.years, tc->card_interval.months, tc->card_interval.days, + tc->card_interval.hours, tc->card_interval.minutes); result_test_cases = PM3_EFAILED; continue; } @@ -2044,7 +2047,7 @@ static int CmdHFSaflokProvision(const char *Cmd) { } _Static_assert(ARRAYLEN(uid) >= sizeof(saflok_mfc_uid_t), "UID array too small"); - const saflok_mfc_uid_t * saflok_uid = (const saflok_mfc_uid_t *)uid; + const saflok_mfc_uid_t *saflok_uid = (const saflok_mfc_uid_t *)uid; saflok_mfc_key_t keyA = {0}; saflok_kdf(saflok_uid, &keyA); @@ -2136,7 +2139,7 @@ static int CmdHFSaflokInterrogate(const char *Cmd) { } _Static_assert(ARRAYLEN(uid) >= sizeof(saflok_mfc_uid_t), "UID array too small"); - const saflok_mfc_uid_t * saflok_uid = (const saflok_mfc_uid_t *)uid; + const saflok_mfc_uid_t *saflok_uid = (const saflok_mfc_uid_t *)uid; saflok_mfc_key_t key = {0}; saflok_kdf(saflok_uid, &key); diff --git a/client/src/cmdhfseos.c b/client/src/cmdhfseos.c index 553753373..ddd2657a1 100644 --- a/client/src/cmdhfseos.c +++ b/client/src/cmdhfseos.c @@ -159,7 +159,7 @@ static int decrypt_cryptogram(uint8_t *key, uint8_t *input, uint8_t *out, int in static void increment_command_wrapper(uint8_t *input, int input_len) { // Increment the end of the header by 1 - uint8_t* offset = &input[input_len - sizeof(uint32_t)]; + uint8_t *offset = &input[input_len - sizeof(uint32_t)]; uint32_t value = MemBeToUint4byte(offset); value++; Uint4byteToMemBe(offset, value); @@ -192,12 +192,12 @@ static void generate_command_wrapping(uint8_t *command_Header, int command_heade // Command Header is for the APDU Command to be sent int padded_Command_Header_len = command_header_len; - uint8_t padded_Command_Header[padded_Command_Header_len+block_size]; + uint8_t padded_Command_Header[padded_Command_Header_len + block_size]; padToBlockSize(command_Header, &padded_Command_Header_len, block_size, padded_Command_Header); // Unencrypted Command is our actual command data int padded_unencrypted_Command_len = unencrypted_command_len; - uint8_t padded_unencrypted_Command[padded_unencrypted_Command_len+block_size]; + uint8_t padded_unencrypted_Command[padded_unencrypted_Command_len + block_size]; padToBlockSize(unencrypted_Command, &padded_unencrypted_Command_len, block_size, padded_unencrypted_Command); uint8_t padded_encrypted_Command[padded_unencrypted_Command_len]; @@ -216,7 +216,7 @@ static void generate_command_wrapping(uint8_t *command_Header, int command_heade memcpy(toEncrypt + ARRAYLEN(rndCounter) + padded_Command_Header_len + ARRAYLEN(asn1_tag_cryptograph) + ARRAYLEN(padded_encrypted_Command), command_trailer, ARRAYLEN(command_trailer)); int padded_toEncrypt_len = ARRAYLEN(toEncrypt); - uint8_t padded_toEncrypt[padded_toEncrypt_len+block_size]; + uint8_t padded_toEncrypt[padded_toEncrypt_len + block_size]; padToBlockSize(toEncrypt, &padded_toEncrypt_len, block_size, padded_toEncrypt); // Breakdown @@ -286,10 +286,10 @@ static int seos_get_data(uint8_t *rndICC, uint8_t *rndIFD, uint8_t *diversified_ // uint8_t unencrypted_command[4] = {0x5c,0x02,0xff,0x00}; // Modification of the tags 2nd place from 00 can return other data - uint8_t unencrypted_command[data_tag_len+2]; + uint8_t unencrypted_command[data_tag_len + 2]; unencrypted_command[0] = 0x5c; unencrypted_command[1] = data_tag_len; - memcpy(unencrypted_command+2, data_tag, data_tag_len); + memcpy(unencrypted_command + 2, data_tag, data_tag_len); int unencrypted_command_len = ARRAYLEN(unencrypted_command); @@ -402,11 +402,11 @@ static int seos_write_data(uint8_t *rndICC, uint8_t *rndIFD, uint8_t *diversifie // ff 00 [04] 12 34 56 78 // ff 00 = BER-TLV tag of the data object to be written - uint8_t unencrypted_command[write_data_tag_len+1+sio_size]; + uint8_t unencrypted_command[write_data_tag_len + 1 + sio_size]; memcpy(unencrypted_command, write_data_tag, write_data_tag_len); unencrypted_command[write_data_tag_len] = sio_size; - memcpy(unencrypted_command+write_data_tag_len+1, sio, sio_size); + memcpy(unencrypted_command + write_data_tag_len + 1, sio, sio_size); int unencrypted_command_len = ARRAYLEN(unencrypted_command); @@ -650,12 +650,12 @@ static int select_DF_verify(uint8_t *response, uint8_t response_length, uint8_t for (int i = 0; i < response_length - 2;) { // extract MAC if (response[i] == 0x8E) { - if (response[i+1] != MAC_value_len) { + if (response[i + 1] != MAC_value_len) { goto out; } // Ensure there's enough bytes remaining // in the response for the full MAC - if (i+2+MAC_value_len > response_length) { + if (i + 2 + MAC_value_len > response_length) { goto out; } input_len = i; @@ -665,7 +665,7 @@ static int select_DF_verify(uint8_t *response, uint8_t response_length, uint8_t break; } // skip to next tag - i += 2 + response[i+1]; + i += 2 + response[i + 1]; } if (res != PM3_SUCCESS) { goto out; @@ -821,7 +821,7 @@ static int select_ADF_decrypt(const char *selectADFOID, uint8_t *CRYPTOGRAM_encr uint8_t MAC_key[24] = {0x00}; memcpy(MAC_key, keys[key_index].privMacKey, 16); create_cmac(MAC_key, CRYPTOGRAM_encrypted_data_raw, mac, iv_size, sizeof(mac), encryption_algorithm); - if (memcmp(CRYPTOGRAM_encrypted_data_raw+iv_size, mac, iv_size) != 0) { + if (memcmp(CRYPTOGRAM_encrypted_data_raw + iv_size, mac, iv_size) != 0) { PrintAndLogEx(ERR, "Synthesized IV Verification Failed"); PrintAndLogEx(ERR, _YELLOW_("Likely wrong Priv Mac Key")); return PM3_ESOFT; @@ -1234,7 +1234,7 @@ static int seos_pacs_adf_select(char *oid, int oid_len, uint8_t *data_tag, int d return res; } create_mutual_auth_key(KeyIFD, KeyICC, RNDICC, RNDIFD, Diversified_New_EncryptionKey, Diversified_New_MACKey, ALGORITHM_INFO_value1, ALGORITHM_INFO_value2); - + if (write == NULL) { uint8_t sio_buffer_out[PM3_CMD_DATA_SIZE]; int sio_size = 0; @@ -1819,7 +1819,7 @@ static int CmdHfSeosSim(const char *Cmd) { return PM3_EOPABORTED; } } - + return PM3_SUCCESS; } diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c index b07c4e015..fe75af79e 100644 --- a/client/src/cmdlft55xx.c +++ b/client/src/cmdlft55xx.c @@ -948,9 +948,9 @@ static int CmdT55xxReadBlock(const char *Cmd) { _CYAN_("Use of read with password on a tag not configured") "\n" _CYAN_("for a password can damage the tag") "\n" _RED_(" * * * * * * * * * *"), - "lf t55xx read -b 0 --> read data from block 0\n" - "lf t55xx read -b 0 --pwd 01020304 --> read data from block 0, pwd 01020304\n" - "lf t55xx read -b 0 --pwd 01020304 -o --> read data from block 0, pwd 01020304, override\n" + "lf t55xx read -b 0 --> read data from block 0\n" + "lf t55xx read -b 0 --pwd 01020304 --> read data from block 0, pwd 01020304\n" + "lf t55xx read -b 0 --pwd 01020304 -o --> read data from block 0, pwd 01020304, override\n" ); // 1 (help) + 4(four user specified params) + (5 T55XX_DLMODE_SINGLE) diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c index 0f3242345..d0f7aed2b 100644 --- a/client/src/cmdtrace.c +++ b/client/src/cmdtrace.c @@ -1469,7 +1469,7 @@ int CmdTraceList(const char *Cmd) { if (protocol == LEGIC) PrintAndLogEx(INFO, _YELLOW_("LEGIC") " - Reader Mode: Timings are in ticks (1us == 1.5ticks)\n" - " Tag Mode: Timings are in sub carrier periods (1/212 kHz == 4.7us)"); + " Tag Mode: Timings are in sub carrier periods (1/212 kHz == 4.7us)"); if (protocol == ISO_14443B || protocol == PROTO_CRYPTORF) { if (use_us) diff --git a/client/src/flash.c b/client/src/flash.c index 25edb7c0f..584288779 100644 --- a/client/src/flash.c +++ b/client/src/flash.c @@ -124,7 +124,7 @@ static int build_segs_from_phdrs(flash_file_t *ctx, uint32_t flash_size) { offset); if (filesz != memsz) { PrintAndLogEx(ERR, "Error: PHDR file size does not equal memory size\n" - "(DATA+BSS PHDRs do not make sense on ROM platforms!)"); + "(DATA+BSS PHDRs do not make sense on ROM platforms!)"); return PM3_EFILE; } if (paddr < last_end) { diff --git a/client/src/pm3_luawrap.c b/client/src/pm3_luawrap.c index 65798a2e5..0d5753a9d 100644 --- a/client/src/pm3_luawrap.c +++ b/client/src/pm3_luawrap.c @@ -2756,9 +2756,9 @@ static int _wrap_new_pm3(lua_State *L) { } SWIG_Lua_pusherrstring(L, "Wrong arguments for overloaded function 'new_pm3'\n" - " Possible C/C++ prototypes are:\n" - " pm3::pm3()\n" - " pm3::pm3(char *)\n"); + " Possible C/C++ prototypes are:\n" + " pm3::pm3()\n" + " pm3::pm3(char *)\n"); lua_error(L); return 0; } diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index d4291fdde..fd2043d59 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -841,7 +841,7 @@ static int dumpmem_pm3(char *serial_port_name, const char *filename, uint32_t ad PrintAndLogEx(INFO, "Device is running the bootloader."); } else { PrintAndLogEx(ERR, "Device is running the bootloader, but the bootloader" - " doesn't understand the READ MEM command."); + " doesn't understand the READ MEM command."); goto finish2; } } diff --git a/common/bruteforce.h b/common/bruteforce.h index cab98c8c7..4a956801d 100644 --- a/common/bruteforce.h +++ b/common/bruteforce.h @@ -63,8 +63,8 @@ typedef struct { uint64_t current_key; // Use 64 bit and truncate when needed. uint8_t mode; uint8_t charset[ - BF_CHARSET_DIGITS_SIZE - + BF_CHARSET_UPPERCASE_SIZE + BF_CHARSET_DIGITS_SIZE + + BF_CHARSET_UPPERCASE_SIZE ]; uint8_t charset_length; diff --git a/common/iso15693tools.h b/common/iso15693tools.h index a18498a8d..0f9445c4d 100644 --- a/common/iso15693tools.h +++ b/common/iso15693tools.h @@ -73,14 +73,14 @@ static const int Iso15693FrameSOF[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - -1, -1, -1, -1, - -1, -1, -1, -1, - 1, 1, 1, 1, - 1, 1, 1, 1 - }; + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + -1, -1, -1, -1, + -1, -1, -1, -1, + 1, 1, 1, 1, + 1, 1, 1, 1 +}; static const int Iso15693Logic0[] = { 1, 1, 1, 1, 1, 1, 1, 1, @@ -89,10 +89,10 @@ static const int Iso15693Logic0[] = { }; static const int Iso15693Logic1[] = { -1, -1, -1, -1, - -1, -1, -1, -1, - 1, 1, 1, 1, - 1, 1, 1, 1 - }; + -1, -1, -1, -1, + 1, 1, 1, 1, + 1, 1, 1, 1 +}; // EOF defined as // 1) logic '0' (8 pulses of 423.75kHz followed by unmodulated for 18.88us) diff --git a/common/mbedtls/aesni.c b/common/mbedtls/aesni.c index 7a89a298b..7add8c1af 100644 --- a/common/mbedtls/aesni.c +++ b/common/mbedtls/aesni.c @@ -254,7 +254,7 @@ void mbedtls_aesni_inverse_key(unsigned char *invkey, for (fk -= 16, ik += 16; fk > fwdkey; fk -= 16, ik += 16) asm("movdqu (%0), %%xmm0 \n\t" AESIMC xmm0_xmm0 "\n\t" - "movdqu %%xmm0, (%1) \n\t" + "movdqu %%xmm0, (%1) \n\t" : : "r"(fk), "r"(ik) : "memory", "xmm0"); @@ -403,23 +403,23 @@ static void aesni_setkey_enc_256(unsigned char *rk, /* Set xmm2 to stuff:Y:stuff:stuff with Y = subword( r11 ) * and proceed to generate next round key from there */ AESKEYGENA xmm0_xmm2 ",0x00 \n\t" - "pshufd $0xaa, %%xmm2, %%xmm2 \n\t" - "pxor %%xmm1, %%xmm2 \n\t" - "pslldq $4, %%xmm1 \n\t" - "pxor %%xmm1, %%xmm2 \n\t" - "pslldq $4, %%xmm1 \n\t" - "pxor %%xmm1, %%xmm2 \n\t" - "pslldq $4, %%xmm1 \n\t" - "pxor %%xmm2, %%xmm1 \n\t" - "add $16, %0 \n\t" - "movdqu %%xmm1, (%0) \n\t" - "ret \n\t" + "pshufd $0xaa, %%xmm2, %%xmm2 \n\t" + "pxor %%xmm1, %%xmm2 \n\t" + "pslldq $4, %%xmm1 \n\t" + "pxor %%xmm1, %%xmm2 \n\t" + "pslldq $4, %%xmm1 \n\t" + "pxor %%xmm1, %%xmm2 \n\t" + "pslldq $4, %%xmm1 \n\t" + "pxor %%xmm2, %%xmm1 \n\t" + "add $16, %0 \n\t" + "movdqu %%xmm1, (%0) \n\t" + "ret \n\t" /* * Main "loop" - Generating one more key than necessary, * see definition of mbedtls_aes_context.buf */ - "2: \n\t" + "2: \n\t" AESKEYGENA xmm1_xmm2 ",0x01 \n\tcall 1b \n\t" AESKEYGENA xmm1_xmm2 ",0x02 \n\tcall 1b \n\t" AESKEYGENA xmm1_xmm2 ",0x04 \n\tcall 1b \n\t" diff --git a/common/mbedtls/camellia.c b/common/mbedtls/camellia.c index 7b49f9aae..56097c704 100644 --- a/common/mbedtls/camellia.c +++ b/common/mbedtls/camellia.c @@ -215,16 +215,16 @@ static const signed char indexes[2][4][20] = { }, /* KL -> RK */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 - }, /* KR -> RK */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + }, /* KR -> RK */ { 4, 5, 6, 7, 12, 13, 14, 15, 16, 17, 18, 19, -1, 24, 25, -1, 31, 28, 29, 30 }, /* KA -> RK */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 - } /* KB -> RK */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + } /* KB -> RK */ }, { { @@ -233,12 +233,12 @@ static const signed char indexes[2][4][20] = { }, /* KL -> RK */ { -1, -1, -1, -1, 8, 9, 10, 11, 16, 17, - 18, 19, -1, -1, -1, -1, 39, 36, 37, 38 - }, /* KR -> RK */ + 18, 19, -1, -1, -1, -1, 39, 36, 37, 38 + }, /* KR -> RK */ { -1, -1, -1, -1, 12, 13, 14, 15, 58, 59, - 56, 57, 31, 28, 29, 30, -1, -1, -1, -1 - }, /* KA -> RK */ + 56, 57, 31, 28, 29, 30, -1, -1, -1, -1 + }, /* KA -> RK */ { 4, 5, 6, 7, 65, 66, 67, 64, 20, 21, 22, 23, -1, -1, -1, -1, 43, 40, 41, 42 diff --git a/common/mbedtls/ctr_drbg.c b/common/mbedtls/ctr_drbg.c index f5d39d38d..ae42e93b1 100644 --- a/common/mbedtls/ctr_drbg.c +++ b/common/mbedtls/ctr_drbg.c @@ -119,7 +119,7 @@ void mbedtls_ctr_drbg_set_reseed_interval(mbedtls_ctr_drbg_context *ctx, static int block_cipher_df(unsigned char *output, const unsigned char *data, size_t data_len) { unsigned char buf[MBEDTLS_CTR_DRBG_MAX_SEED_INPUT + - MBEDTLS_CTR_DRBG_BLOCKSIZE + 16]; + MBEDTLS_CTR_DRBG_BLOCKSIZE + 16]; unsigned char tmp[MBEDTLS_CTR_DRBG_SEEDLEN]; unsigned char key[MBEDTLS_CTR_DRBG_KEYSIZE]; unsigned char chain[MBEDTLS_CTR_DRBG_BLOCKSIZE]; diff --git a/common/mbedtls/memory_buffer_alloc.c b/common/mbedtls/memory_buffer_alloc.c index a1e9accda..e3c16e74f 100644 --- a/common/mbedtls/memory_buffer_alloc.c +++ b/common/mbedtls/memory_buffer_alloc.c @@ -86,7 +86,7 @@ static void debug_header(memory_header *hdr) { #endif mbedtls_fprintf(stderr, "HDR: PTR(%10zu), PREV(%10zu), NEXT(%10zu), " - "ALLOC(%zu), SIZE(%10zu)\n", + "ALLOC(%zu), SIZE(%10zu)\n", (size_t) hdr, (size_t) hdr->prev, (size_t) hdr->next, hdr->alloc, hdr->size); mbedtls_fprintf(stderr, " FPREV(%10zu), FNEXT(%10zu)\n", @@ -164,7 +164,7 @@ static int verify_chain(void) { if (prv == NULL || verify_header(prv) != 0) { #if defined(MBEDTLS_MEMORY_DEBUG) mbedtls_fprintf(stderr, "FATAL: verification of first header " - "failed\n"); + "failed\n"); #endif return (1); } @@ -172,7 +172,7 @@ static int verify_chain(void) { if (heap.first->prev != NULL) { #if defined(MBEDTLS_MEMORY_DEBUG) mbedtls_fprintf(stderr, "FATAL: verification failed: " - "first->prev != NULL\n"); + "first->prev != NULL\n"); #endif return (1); } @@ -183,7 +183,7 @@ static int verify_chain(void) { if (verify_header(cur) != 0) { #if defined(MBEDTLS_MEMORY_DEBUG) mbedtls_fprintf(stderr, "FATAL: verification of header " - "failed\n"); + "failed\n"); #endif return (1); } @@ -191,7 +191,7 @@ static int verify_chain(void) { if (cur->prev != prv) { #if defined(MBEDTLS_MEMORY_DEBUG) mbedtls_fprintf(stderr, "FATAL: verification failed: " - "cur->prev != prv\n"); + "cur->prev != prv\n"); #endif return (1); } @@ -243,7 +243,7 @@ static void *buffer_alloc_calloc(size_t n, size_t size) { if (cur->alloc != 0) { #if defined(MBEDTLS_MEMORY_DEBUG) mbedtls_fprintf(stderr, "FATAL: block in free_list but allocated " - "data\n"); + "data\n"); #endif mbedtls_exit(1); } @@ -359,7 +359,7 @@ static void buffer_alloc_free(void *ptr) { if (p < heap.buf || p >= heap.buf + heap.len) { #if defined(MBEDTLS_MEMORY_DEBUG) mbedtls_fprintf(stderr, "FATAL: mbedtls_free() outside of managed " - "space\n"); + "space\n"); #endif mbedtls_exit(1); } @@ -373,7 +373,7 @@ static void buffer_alloc_free(void *ptr) { if (hdr->alloc != 1) { #if defined(MBEDTLS_MEMORY_DEBUG) mbedtls_fprintf(stderr, "FATAL: mbedtls_free() on unallocated " - "data\n"); + "data\n"); #endif mbedtls_exit(1); } diff --git a/common/mbedtls/ssl.h b/common/mbedtls/ssl.h index 7c78a698a..3603dc373 100644 --- a/common/mbedtls/ssl.h +++ b/common/mbedtls/ssl.h @@ -445,14 +445,14 @@ union mbedtls_ssl_premaster_secret { #endif #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) unsigned char _pms_dhe_psk[4 + MBEDTLS_MPI_MAX_SIZE - + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 3 */ + + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 3 */ #endif #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) unsigned char _pms_rsa_psk[52 + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 4 */ #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) unsigned char _pms_ecdhe_psk[4 + MBEDTLS_ECP_MAX_BYTES - + MBEDTLS_PSK_MAX_LEN]; /* RFC 5489 2 */ + + MBEDTLS_PSK_MAX_LEN]; /* RFC 5489 2 */ #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) unsigned char _pms_ecjpake[32]; /* Thread spec: SHA-256 output */ diff --git a/common/mbedtls/ssl_cli.c b/common/mbedtls/ssl_cli.c index b41b01167..cb4552a38 100644 --- a/common/mbedtls/ssl_cli.c +++ b/common/mbedtls/ssl_cli.c @@ -804,7 +804,7 @@ static int ssl_write_use_srtp_ext(mbedtls_ssl_context *ssl, */ MBEDTLS_SSL_DEBUG_MSG(3, ("client hello, " - "illegal DTLS-SRTP protection profile %d", + "illegal DTLS-SRTP protection profile %d", ssl->conf->dtls_srtp_profile_list[protection_profiles_index] )); return (MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED); diff --git a/common/mbedtls/ssl_msg.c b/common/mbedtls/ssl_msg.c index d13be766f..8eed325ec 100644 --- a/common/mbedtls/ssl_msg.c +++ b/common/mbedtls/ssl_msg.c @@ -3954,7 +3954,7 @@ static int ssl_buffer_message(mbedtls_ssl_context *ssl) { /* Silently ignore -- message too far in the future */ MBEDTLS_SSL_DEBUG_MSG(2, ("Ignore future HS message with sequence number %u, " - "buffering window %u - %u", + "buffering window %u - %u", recv_msg_seq, ssl->handshake->in_msg_seq, ssl->handshake->in_msg_seq + MBEDTLS_SSL_MAX_BUFFERED_HS - 1)); diff --git a/common/mbedtls/x509_crt.c b/common/mbedtls/x509_crt.c index 850893f0a..2e1cea165 100644 --- a/common/mbedtls/x509_crt.c +++ b/common/mbedtls/x509_crt.c @@ -2101,7 +2101,7 @@ int mbedtls_x509_crt_verify_info(char *buf, size_t size, const char *prefix, if (flags != 0) { ret = mbedtls_snprintf(p, n, "%sUnknown reason " - "(this should not happen)\n", prefix); + "(this should not happen)\n", prefix); MBEDTLS_X509_SAFE_SNPRINTF; } diff --git a/doc/commands.json b/doc/commands.json index b363538a2..60b82b2bd 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -13793,6 +13793,6 @@ "metadata": { "commands_extracted": 790, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2026-02-06T12:06:55" + "extracted_on": "2026-02-06T12:16:10" } } diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h index eb3331ecc..b31a33b8d 100644 --- a/include/pm3_cmd.h +++ b/include/pm3_cmd.h @@ -321,7 +321,7 @@ typedef struct { typedef struct { // 64KB SRAM -> 524288 bits(max sample num) < 2^30 -uint32_t samples : + uint32_t samples : LF_SAMPLES_BITS; bool realtime : 1; bool verbose : 1; diff --git a/include/seos_cmd.h b/include/seos_cmd.h index 05b9a6e0a..7c736c7fc 100644 --- a/include/seos_cmd.h +++ b/include/seos_cmd.h @@ -42,13 +42,13 @@ typedef struct { uint8_t diversifier_len; uint8_t diversifier[16]; - + uint8_t data_tag_len; uint8_t data_tag[8]; - + uint8_t data_len; uint8_t data[128]; - + uint8_t oid_len; uint8_t oid[32]; } PACKED seos_emulate_req_t; diff --git a/tools/deprecated-hid-flasher/flasher/flash.c b/tools/deprecated-hid-flasher/flasher/flash.c index 179693d8b..ebef34397 100644 --- a/tools/deprecated-hid-flasher/flasher/flash.c +++ b/tools/deprecated-hid-flasher/flasher/flash.c @@ -71,7 +71,7 @@ static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs, offset); if (filesz != memsz) { fprintf(stderr, "Error: PHDR file size does not equal memory size\n" - "(DATA+BSS PHDRs do not make sense on ROM platforms!)\n"); + "(DATA+BSS PHDRs do not make sense on ROM platforms!)\n"); return -1; } if (paddr < last_end) { diff --git a/tools/mfulc_des_brute/mfulc_des_brute.c b/tools/mfulc_des_brute/mfulc_des_brute.c index 557fd3c83..cb08af5b8 100644 --- a/tools/mfulc_des_brute/mfulc_des_brute.c +++ b/tools/mfulc_des_brute/mfulc_des_brute.c @@ -234,13 +234,13 @@ static void *worker(void *arg) { static void print_help_and_exit(const char *cmd_name) { fprintf(stderr, - "Usage:\n" - " * Counterfeit key recovery:\n" - " %s -c <3DES base key hex (32 hex digits)> \n" - " * Reader nonce key recovery:\n" - " %s -r <3DES base key hex (32 hex digits)> \n", - cmd_name, - cmd_name); + "Usage:\n" + " * Counterfeit key recovery:\n" + " %s -c <3DES base key hex (32 hex digits)> \n" + " * Reader nonce key recovery:\n" + " %s -r <3DES base key hex (32 hex digits)> \n", + cmd_name, + cmd_name); exit(1); }