diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e8caaaf..289814e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Fix the issue where some reader cause CU to enter a strange state (@xianglin1998) - The transmission performance of USB has been improved (@xianglin1998) - Added cmd for set mf1 config 'field_off_do_reset' (@xianglin1998) - + - Fix Windows build (@suut) ## [v2.1.0][2025-09-02] - Added UV, formatter and linter. Contribution guidelines. (@GameTec-live) diff --git a/software/src/CMakeLists.txt b/software/src/CMakeLists.txt index f33c8d6c..d1372518 100644 --- a/software/src/CMakeLists.txt +++ b/software/src/CMakeLists.txt @@ -221,16 +221,18 @@ endif() add_executable(mfulc_des_brute mfulc_des_brute.c) target_include_directories(mfulc_des_brute PRIVATE ${SRC_DIR}) target_link_libraries(mfulc_des_brute PRIVATE ${LIBTHREAD} OpenSSL::Crypto) -target_compile_options(mfulc_des_brute PRIVATE -Wno-deprecated-declarations) +if (MSVC) + target_compile_options(mfulc_des_brute PRIVATE /wd4996) # disable "deprecated declaration" warning +else() + target_compile_options(mfulc_des_brute PRIVATE -Wno-deprecated-declarations) +endif() if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Android" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") target_compile_definitions(mfulc_des_brute PRIVATE _GNU_SOURCE) - find_package(OpenSSL REQUIRED) endif() if (CMAKE_SYSTEM_NAME MATCHES "Windows") target_compile_definitions(mfulc_des_brute PRIVATE HAVE_STRUCT_TIMESPEC) - find_package(OpenSSL REQUIRED) endif() - +find_package(OpenSSL REQUIRED) # --- hardnested Executable --- add_executable(hardnested ${COMMON_FILES} ${HARDNESTED_SOURCES}) diff --git a/software/src/mfulc_des_brute.c b/software/src/mfulc_des_brute.c index 7d7b3076..1357c106 100644 --- a/software/src/mfulc_des_brute.c +++ b/software/src/mfulc_des_brute.c @@ -10,6 +10,12 @@ #include #include +#ifdef _MSC_VER +# define bswap64 _byteswap_uint64 +#else +# define bswap64 __builtin_bswap64 +#endif + #define BLOCK_SIZE 8 // DES (and 3DES) block size in bytes #define KEY_SIZE 16 // Full 2TDEA key size (K1 || K2) #define BENCHMARK_FULL_KEYSPACE 0 @@ -57,7 +63,7 @@ static void print_hex(const unsigned char *buf, size_t len) { } static bool valid_lfsr_ulcg(uint64_t x64) { - x64 = __builtin_bswap64(x64); + x64 = bswap64(x64); uint16_t x16 = x64 >> 48; x16 = x16 << 15 | ((x16 >> 1) ^ ((x16 >> 3 ^ x16 >> 4 ^ x16 >> 6) & 1)); if (x16 != ((x64 >> 32) & 0xFFFF)) return false; @@ -69,7 +75,7 @@ static bool valid_lfsr_ulcg(uint64_t x64) { } static bool valid_lfsr_uscuidul(uint64_t x64) { - x64 = __builtin_bswap64(x64); + x64 = bswap64(x64); uint16_t x16 = x64 & 0xFFFF; for (int i = 0; i < 16; i++) x16 = x16 >> 1 | (x16 ^ x16 >> 2 ^ x16 >> 3 ^ x16 >> 5) << 15; if (x16 != ((x64 >> 16) & 0xFFFF)) return false; @@ -193,9 +199,9 @@ static void *worker(void *arg) { // Check if out is 8-bit (1-byte) left rotated version of init_out // Need to convert to big-endian for byte rotation, then back to little-endian - uint64_t init_be = __builtin_bswap64(init_out); + uint64_t init_be = bswap64(init_out); uint64_t rotated_be = (init_be << 8) | (init_be >> 56); - uint64_t rotated = __builtin_bswap64(rotated_be); + uint64_t rotated = bswap64(rotated_be); match = (out == rotated); } else { // In counterfeit mode, check the resulting plaintext against LFSR