Merge pull request #345 from suut/fix_windows_build

Fix Windows build
This commit is contained in:
GameTec-live
2026-02-03 05:54:03 +01:00
committed by GitHub
3 changed files with 17 additions and 9 deletions
+1 -1
View File
@@ -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)
+6 -4
View File
@@ -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})
+10 -4
View File
@@ -10,6 +10,12 @@
#include <pthread.h>
#include <openssl/des.h>
#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