mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
changing {} style to match majority of previous style
This commit is contained in:
parent
da6cdf014b
commit
961d929f4d
320 changed files with 5502 additions and 10485 deletions
|
@ -145,8 +145,7 @@ bitslice_test_nonces_t bitslice_test_nonces_dispatch;
|
|||
#define malloc_bitslice(x) __builtin_assume_aligned(_aligned_malloc((x), MAX_BITSLICES/8), MAX_BITSLICES/8)
|
||||
#define free_bitslice(x) _aligned_free(x)
|
||||
#elif defined (__APPLE__)
|
||||
static void *malloc_bitslice(size_t x)
|
||||
{
|
||||
static void *malloc_bitslice(size_t x) {
|
||||
char *allocated_memory;
|
||||
if (posix_memalign((void **)&allocated_memory, MAX_BITSLICES / 8, x)) {
|
||||
return NULL;
|
||||
|
@ -174,8 +173,7 @@ static bitslice_t bs_ones;
|
|||
static bitslice_t bs_zeroes;
|
||||
|
||||
|
||||
void BITSLICE_TEST_NONCES(uint32_t nonces_to_bruteforce, uint32_t *bf_test_nonce, uint8_t *bf_test_nonce_par)
|
||||
{
|
||||
void BITSLICE_TEST_NONCES(uint32_t nonces_to_bruteforce, uint32_t *bf_test_nonce, uint8_t *bf_test_nonce_par) {
|
||||
|
||||
// initialize 1 and 0 vectors
|
||||
memset(bs_ones.bytes, 0xff, VECTOR_SIZE);
|
||||
|
@ -207,8 +205,7 @@ void BITSLICE_TEST_NONCES(uint32_t nonces_to_bruteforce, uint32_t *bf_test_nonce
|
|||
}
|
||||
|
||||
|
||||
const uint64_t CRACK_STATES_BITSLICED(uint32_t cuid, uint8_t *best_first_bytes, statelist_t *p, uint32_t *keys_found, uint64_t *num_keys_tested, uint32_t nonces_to_bruteforce, uint8_t *bf_test_nonce_2nd_byte, noncelist_t *nonces)
|
||||
{
|
||||
const uint64_t CRACK_STATES_BITSLICED(uint32_t cuid, uint8_t *best_first_bytes, statelist_t *p, uint32_t *keys_found, uint64_t *num_keys_tested, uint32_t nonces_to_bruteforce, uint8_t *bf_test_nonce_2nd_byte, noncelist_t *nonces) {
|
||||
|
||||
// Unlike aczid's implementation this doesn't roll back at all when performing bitsliced bruteforce.
|
||||
// We know that the best first byte is already shifted in. Testing with the remaining three bytes of
|
||||
|
@ -432,11 +429,11 @@ const uint64_t CRACK_STATES_BITSLICED(uint32_t cuid, uint8_t *best_first_bytes,
|
|||
// the short-circuiting also helps
|
||||
if (results.bytes64[0] == 0
|
||||
#if MAX_BITSLICES > 64
|
||||
&& results.bytes64[1] == 0
|
||||
&& results.bytes64[1] == 0
|
||||
#endif
|
||||
#if MAX_BITSLICES > 128
|
||||
&& results.bytes64[2] == 0
|
||||
&& results.bytes64[3] == 0
|
||||
&& results.bytes64[2] == 0
|
||||
&& results.bytes64[3] == 0
|
||||
#endif
|
||||
) {
|
||||
#if defined (DEBUG_BRUTE_FORCE)
|
||||
|
@ -551,16 +548,14 @@ bitslice_test_nonces_t *bitslice_test_nonces_function_p = &bitslice_test_nonces_
|
|||
|
||||
static SIMDExecInstr intSIMDInstr = SIMD_AUTO;
|
||||
|
||||
void SetSIMDInstr(SIMDExecInstr instr)
|
||||
{
|
||||
void SetSIMDInstr(SIMDExecInstr instr) {
|
||||
intSIMDInstr = instr;
|
||||
|
||||
crack_states_bitsliced_function_p = &crack_states_bitsliced_dispatch;
|
||||
bitslice_test_nonces_function_p = &bitslice_test_nonces_dispatch;
|
||||
}
|
||||
|
||||
SIMDExecInstr GetSIMDInstr()
|
||||
{
|
||||
SIMDExecInstr GetSIMDInstr() {
|
||||
SIMDExecInstr instr = SIMD_NONE;
|
||||
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
|
@ -582,8 +577,7 @@ SIMDExecInstr GetSIMDInstr()
|
|||
return instr;
|
||||
}
|
||||
|
||||
SIMDExecInstr GetSIMDInstrAuto()
|
||||
{
|
||||
SIMDExecInstr GetSIMDInstrAuto() {
|
||||
SIMDExecInstr instr = intSIMDInstr;
|
||||
if (instr == SIMD_AUTO)
|
||||
return GetSIMDInstr();
|
||||
|
@ -592,8 +586,7 @@ SIMDExecInstr GetSIMDInstrAuto()
|
|||
}
|
||||
|
||||
// determine the available instruction set at runtime and call the correct function
|
||||
const uint64_t crack_states_bitsliced_dispatch(uint32_t cuid, uint8_t *best_first_bytes, statelist_t *p, uint32_t *keys_found, uint64_t *num_keys_tested, uint32_t nonces_to_bruteforce, uint8_t *bf_test_nonce_2nd_byte, noncelist_t *nonces)
|
||||
{
|
||||
const uint64_t crack_states_bitsliced_dispatch(uint32_t cuid, uint8_t *best_first_bytes, statelist_t *p, uint32_t *keys_found, uint64_t *num_keys_tested, uint32_t nonces_to_bruteforce, uint8_t *bf_test_nonce_2nd_byte, noncelist_t *nonces) {
|
||||
switch (GetSIMDInstrAuto()) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
|
@ -625,8 +618,7 @@ const uint64_t crack_states_bitsliced_dispatch(uint32_t cuid, uint8_t *best_firs
|
|||
return (*crack_states_bitsliced_function_p)(cuid, best_first_bytes, p, keys_found, num_keys_tested, nonces_to_bruteforce, bf_test_nonce_2nd_byte, nonces);
|
||||
}
|
||||
|
||||
void bitslice_test_nonces_dispatch(uint32_t nonces_to_bruteforce, uint32_t *bf_test_nonce, uint8_t *bf_test_nonce_par)
|
||||
{
|
||||
void bitslice_test_nonces_dispatch(uint32_t nonces_to_bruteforce, uint32_t *bf_test_nonce, uint8_t *bf_test_nonce_par) {
|
||||
switch (GetSIMDInstrAuto()) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
|
@ -659,13 +651,11 @@ void bitslice_test_nonces_dispatch(uint32_t nonces_to_bruteforce, uint32_t *bf_t
|
|||
}
|
||||
|
||||
// Entries to dispatched function calls
|
||||
const uint64_t crack_states_bitsliced(uint32_t cuid, uint8_t *best_first_bytes, statelist_t *p, uint32_t *keys_found, uint64_t *num_keys_tested, uint32_t nonces_to_bruteforce, uint8_t *bf_test_nonce_2nd_byte, noncelist_t *nonces)
|
||||
{
|
||||
const uint64_t crack_states_bitsliced(uint32_t cuid, uint8_t *best_first_bytes, statelist_t *p, uint32_t *keys_found, uint64_t *num_keys_tested, uint32_t nonces_to_bruteforce, uint8_t *bf_test_nonce_2nd_byte, noncelist_t *nonces) {
|
||||
return (*crack_states_bitsliced_function_p)(cuid, best_first_bytes, p, keys_found, num_keys_tested, nonces_to_bruteforce, bf_test_nonce_2nd_byte, nonces);
|
||||
}
|
||||
|
||||
void bitslice_test_nonces(uint32_t nonces_to_bruteforce, uint32_t *bf_test_nonce, uint8_t *bf_test_nonce_par)
|
||||
{
|
||||
void bitslice_test_nonces(uint32_t nonces_to_bruteforce, uint32_t *bf_test_nonce, uint8_t *bf_test_nonce_par) {
|
||||
(*bitslice_test_nonces_function_p)(nonces_to_bruteforce, bf_test_nonce, bf_test_nonce_par);
|
||||
}
|
||||
|
||||
|
|
|
@ -143,8 +143,7 @@ typedef uint32_t count_bitarray_AND4_t(uint32_t *, uint32_t *, uint32_t *, uint3
|
|||
count_bitarray_AND4_t count_bitarray_AND4_AVX512, count_bitarray_AND4_AVX2, count_bitarray_AND4_AVX, count_bitarray_AND4_SSE2, count_bitarray_AND4_MMX, count_bitarray_AND4_NOSIMD, count_bitarray_AND4_dispatch;
|
||||
|
||||
|
||||
inline uint32_t *MALLOC_BITARRAY(uint32_t x)
|
||||
{
|
||||
inline uint32_t *MALLOC_BITARRAY(uint32_t x) {
|
||||
#if defined (_WIN32)
|
||||
return __builtin_assume_aligned(_aligned_malloc((x), __BIGGEST_ALIGNMENT__), __BIGGEST_ALIGNMENT__);
|
||||
#elif defined (__APPLE__)
|
||||
|
@ -160,8 +159,7 @@ inline uint32_t *MALLOC_BITARRAY(uint32_t x)
|
|||
}
|
||||
|
||||
|
||||
inline void FREE_BITARRAY(uint32_t *x)
|
||||
{
|
||||
inline void FREE_BITARRAY(uint32_t *x) {
|
||||
#ifdef _WIN32
|
||||
_aligned_free(x);
|
||||
#else
|
||||
|
@ -170,14 +168,12 @@ inline void FREE_BITARRAY(uint32_t *x)
|
|||
}
|
||||
|
||||
|
||||
inline uint32_t BITCOUNT(uint32_t a)
|
||||
{
|
||||
inline uint32_t BITCOUNT(uint32_t a) {
|
||||
return __builtin_popcountl(a);
|
||||
}
|
||||
|
||||
|
||||
inline uint32_t COUNT_STATES(uint32_t *A)
|
||||
{
|
||||
inline uint32_t COUNT_STATES(uint32_t *A) {
|
||||
uint32_t count = 0;
|
||||
for (uint32_t i = 0; i < (1 << 19); i++) {
|
||||
count += BITCOUNT(A[i]);
|
||||
|
@ -186,8 +182,7 @@ inline uint32_t COUNT_STATES(uint32_t *A)
|
|||
}
|
||||
|
||||
|
||||
inline void BITARRAY_AND(uint32_t *restrict A, uint32_t *restrict B)
|
||||
{
|
||||
inline void BITARRAY_AND(uint32_t *restrict A, uint32_t *restrict B) {
|
||||
A = __builtin_assume_aligned(A, __BIGGEST_ALIGNMENT__);
|
||||
B = __builtin_assume_aligned(B, __BIGGEST_ALIGNMENT__);
|
||||
for (uint32_t i = 0; i < (1 << 19); i++) {
|
||||
|
@ -196,8 +191,7 @@ inline void BITARRAY_AND(uint32_t *restrict A, uint32_t *restrict B)
|
|||
}
|
||||
|
||||
|
||||
inline void BITARRAY_LOW20_AND(uint32_t *restrict A, uint32_t *restrict B)
|
||||
{
|
||||
inline void BITARRAY_LOW20_AND(uint32_t *restrict A, uint32_t *restrict B) {
|
||||
uint16_t *a = (uint16_t *)__builtin_assume_aligned(A, __BIGGEST_ALIGNMENT__);
|
||||
uint16_t *b = (uint16_t *)__builtin_assume_aligned(B, __BIGGEST_ALIGNMENT__);
|
||||
|
||||
|
@ -209,8 +203,7 @@ inline void BITARRAY_LOW20_AND(uint32_t *restrict A, uint32_t *restrict B)
|
|||
}
|
||||
|
||||
|
||||
inline uint32_t COUNT_BITARRAY_AND(uint32_t *restrict A, uint32_t *restrict B)
|
||||
{
|
||||
inline uint32_t COUNT_BITARRAY_AND(uint32_t *restrict A, uint32_t *restrict B) {
|
||||
A = __builtin_assume_aligned(A, __BIGGEST_ALIGNMENT__);
|
||||
B = __builtin_assume_aligned(B, __BIGGEST_ALIGNMENT__);
|
||||
uint32_t count = 0;
|
||||
|
@ -222,8 +215,7 @@ inline uint32_t COUNT_BITARRAY_AND(uint32_t *restrict A, uint32_t *restrict B)
|
|||
}
|
||||
|
||||
|
||||
inline uint32_t COUNT_BITARRAY_LOW20_AND(uint32_t *restrict A, uint32_t *restrict B)
|
||||
{
|
||||
inline uint32_t COUNT_BITARRAY_LOW20_AND(uint32_t *restrict A, uint32_t *restrict B) {
|
||||
uint16_t *a = (uint16_t *)__builtin_assume_aligned(A, __BIGGEST_ALIGNMENT__);
|
||||
uint16_t *b = (uint16_t *)__builtin_assume_aligned(B, __BIGGEST_ALIGNMENT__);
|
||||
uint32_t count = 0;
|
||||
|
@ -238,8 +230,7 @@ inline uint32_t COUNT_BITARRAY_LOW20_AND(uint32_t *restrict A, uint32_t *restric
|
|||
}
|
||||
|
||||
|
||||
inline void BITARRAY_AND4(uint32_t *restrict A, uint32_t *restrict B, uint32_t *restrict C, uint32_t *restrict D)
|
||||
{
|
||||
inline void BITARRAY_AND4(uint32_t *restrict A, uint32_t *restrict B, uint32_t *restrict C, uint32_t *restrict D) {
|
||||
A = __builtin_assume_aligned(A, __BIGGEST_ALIGNMENT__);
|
||||
B = __builtin_assume_aligned(B, __BIGGEST_ALIGNMENT__);
|
||||
C = __builtin_assume_aligned(C, __BIGGEST_ALIGNMENT__);
|
||||
|
@ -250,8 +241,7 @@ inline void BITARRAY_AND4(uint32_t *restrict A, uint32_t *restrict B, uint32_t *
|
|||
}
|
||||
|
||||
|
||||
inline void BITARRAY_OR(uint32_t *restrict A, uint32_t *restrict B)
|
||||
{
|
||||
inline void BITARRAY_OR(uint32_t *restrict A, uint32_t *restrict B) {
|
||||
A = __builtin_assume_aligned(A, __BIGGEST_ALIGNMENT__);
|
||||
B = __builtin_assume_aligned(B, __BIGGEST_ALIGNMENT__);
|
||||
for (uint32_t i = 0; i < (1 << 19); i++) {
|
||||
|
@ -260,8 +250,7 @@ inline void BITARRAY_OR(uint32_t *restrict A, uint32_t *restrict B)
|
|||
}
|
||||
|
||||
|
||||
inline uint32_t COUNT_BITARRAY_AND2(uint32_t *restrict A, uint32_t *restrict B)
|
||||
{
|
||||
inline uint32_t COUNT_BITARRAY_AND2(uint32_t *restrict A, uint32_t *restrict B) {
|
||||
A = __builtin_assume_aligned(A, __BIGGEST_ALIGNMENT__);
|
||||
B = __builtin_assume_aligned(B, __BIGGEST_ALIGNMENT__);
|
||||
uint32_t count = 0;
|
||||
|
@ -272,8 +261,7 @@ inline uint32_t COUNT_BITARRAY_AND2(uint32_t *restrict A, uint32_t *restrict B)
|
|||
}
|
||||
|
||||
|
||||
inline uint32_t COUNT_BITARRAY_AND3(uint32_t *restrict A, uint32_t *restrict B, uint32_t *restrict C)
|
||||
{
|
||||
inline uint32_t COUNT_BITARRAY_AND3(uint32_t *restrict A, uint32_t *restrict B, uint32_t *restrict C) {
|
||||
A = __builtin_assume_aligned(A, __BIGGEST_ALIGNMENT__);
|
||||
B = __builtin_assume_aligned(B, __BIGGEST_ALIGNMENT__);
|
||||
C = __builtin_assume_aligned(C, __BIGGEST_ALIGNMENT__);
|
||||
|
@ -285,8 +273,7 @@ inline uint32_t COUNT_BITARRAY_AND3(uint32_t *restrict A, uint32_t *restrict B,
|
|||
}
|
||||
|
||||
|
||||
inline uint32_t COUNT_BITARRAY_AND4(uint32_t *restrict A, uint32_t *restrict B, uint32_t *restrict C, uint32_t *restrict D)
|
||||
{
|
||||
inline uint32_t COUNT_BITARRAY_AND4(uint32_t *restrict A, uint32_t *restrict B, uint32_t *restrict C, uint32_t *restrict D) {
|
||||
A = __builtin_assume_aligned(A, __BIGGEST_ALIGNMENT__);
|
||||
B = __builtin_assume_aligned(B, __BIGGEST_ALIGNMENT__);
|
||||
C = __builtin_assume_aligned(C, __BIGGEST_ALIGNMENT__);
|
||||
|
@ -317,8 +304,7 @@ count_bitarray_AND3_t *count_bitarray_AND3_function_p = &count_bitarray_AND3_dis
|
|||
count_bitarray_AND4_t *count_bitarray_AND4_function_p = &count_bitarray_AND4_dispatch;
|
||||
|
||||
// determine the available instruction set at runtime and call the correct function
|
||||
uint32_t *malloc_bitarray_dispatch(uint32_t x)
|
||||
{
|
||||
uint32_t *malloc_bitarray_dispatch(uint32_t x) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
|
||||
|
@ -339,8 +325,7 @@ uint32_t *malloc_bitarray_dispatch(uint32_t x)
|
|||
return (*malloc_bitarray_function_p)(x);
|
||||
}
|
||||
|
||||
void free_bitarray_dispatch(uint32_t *x)
|
||||
{
|
||||
void free_bitarray_dispatch(uint32_t *x) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
|
||||
|
@ -361,8 +346,7 @@ void free_bitarray_dispatch(uint32_t *x)
|
|||
(*free_bitarray_function_p)(x);
|
||||
}
|
||||
|
||||
uint32_t bitcount_dispatch(uint32_t a)
|
||||
{
|
||||
uint32_t bitcount_dispatch(uint32_t a) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
|
||||
|
@ -383,8 +367,7 @@ uint32_t bitcount_dispatch(uint32_t a)
|
|||
return (*bitcount_function_p)(a);
|
||||
}
|
||||
|
||||
uint32_t count_states_dispatch(uint32_t *bitarray)
|
||||
{
|
||||
uint32_t count_states_dispatch(uint32_t *bitarray) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
|
||||
|
@ -405,8 +388,7 @@ uint32_t count_states_dispatch(uint32_t *bitarray)
|
|||
return (*count_states_function_p)(bitarray);
|
||||
}
|
||||
|
||||
void bitarray_AND_dispatch(uint32_t *A, uint32_t *B)
|
||||
{
|
||||
void bitarray_AND_dispatch(uint32_t *A, uint32_t *B) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
|
||||
|
@ -427,8 +409,7 @@ void bitarray_AND_dispatch(uint32_t *A, uint32_t *B)
|
|||
(*bitarray_AND_function_p)(A, B);
|
||||
}
|
||||
|
||||
void bitarray_low20_AND_dispatch(uint32_t *A, uint32_t *B)
|
||||
{
|
||||
void bitarray_low20_AND_dispatch(uint32_t *A, uint32_t *B) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
|
||||
|
@ -449,8 +430,7 @@ void bitarray_low20_AND_dispatch(uint32_t *A, uint32_t *B)
|
|||
(*bitarray_low20_AND_function_p)(A, B);
|
||||
}
|
||||
|
||||
uint32_t count_bitarray_AND_dispatch(uint32_t *A, uint32_t *B)
|
||||
{
|
||||
uint32_t count_bitarray_AND_dispatch(uint32_t *A, uint32_t *B) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
|
||||
|
@ -471,8 +451,7 @@ uint32_t count_bitarray_AND_dispatch(uint32_t *A, uint32_t *B)
|
|||
return (*count_bitarray_AND_function_p)(A, B);
|
||||
}
|
||||
|
||||
uint32_t count_bitarray_low20_AND_dispatch(uint32_t *A, uint32_t *B)
|
||||
{
|
||||
uint32_t count_bitarray_low20_AND_dispatch(uint32_t *A, uint32_t *B) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
|
||||
|
@ -493,8 +472,7 @@ uint32_t count_bitarray_low20_AND_dispatch(uint32_t *A, uint32_t *B)
|
|||
return (*count_bitarray_low20_AND_function_p)(A, B);
|
||||
}
|
||||
|
||||
void bitarray_AND4_dispatch(uint32_t *A, uint32_t *B, uint32_t *C, uint32_t *D)
|
||||
{
|
||||
void bitarray_AND4_dispatch(uint32_t *A, uint32_t *B, uint32_t *C, uint32_t *D) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
|
||||
|
@ -515,8 +493,7 @@ void bitarray_AND4_dispatch(uint32_t *A, uint32_t *B, uint32_t *C, uint32_t *D)
|
|||
(*bitarray_AND4_function_p)(A, B, C, D);
|
||||
}
|
||||
|
||||
void bitarray_OR_dispatch(uint32_t *A, uint32_t *B)
|
||||
{
|
||||
void bitarray_OR_dispatch(uint32_t *A, uint32_t *B) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
|
||||
|
@ -537,8 +514,7 @@ void bitarray_OR_dispatch(uint32_t *A, uint32_t *B)
|
|||
(*bitarray_OR_function_p)(A, B);
|
||||
}
|
||||
|
||||
uint32_t count_bitarray_AND2_dispatch(uint32_t *A, uint32_t *B)
|
||||
{
|
||||
uint32_t count_bitarray_AND2_dispatch(uint32_t *A, uint32_t *B) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
|
||||
|
@ -559,8 +535,7 @@ uint32_t count_bitarray_AND2_dispatch(uint32_t *A, uint32_t *B)
|
|||
return (*count_bitarray_AND2_function_p)(A, B);
|
||||
}
|
||||
|
||||
uint32_t count_bitarray_AND3_dispatch(uint32_t *A, uint32_t *B, uint32_t *C)
|
||||
{
|
||||
uint32_t count_bitarray_AND3_dispatch(uint32_t *A, uint32_t *B, uint32_t *C) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
|
||||
|
@ -581,8 +556,7 @@ uint32_t count_bitarray_AND3_dispatch(uint32_t *A, uint32_t *B, uint32_t *C)
|
|||
return (*count_bitarray_AND3_function_p)(A, B, C);
|
||||
}
|
||||
|
||||
uint32_t count_bitarray_AND4_dispatch(uint32_t *A, uint32_t *B, uint32_t *C, uint32_t *D)
|
||||
{
|
||||
uint32_t count_bitarray_AND4_dispatch(uint32_t *A, uint32_t *B, uint32_t *C, uint32_t *D) {
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
|
||||
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
|
||||
|
@ -607,68 +581,55 @@ uint32_t count_bitarray_AND4_dispatch(uint32_t *A, uint32_t *B, uint32_t *C, uin
|
|||
///////////////////////////////////////////////77
|
||||
// Entries to dispatched function calls
|
||||
|
||||
uint32_t *malloc_bitarray(uint32_t x)
|
||||
{
|
||||
uint32_t *malloc_bitarray(uint32_t x) {
|
||||
return (*malloc_bitarray_function_p)(x);
|
||||
}
|
||||
|
||||
void free_bitarray(uint32_t *x)
|
||||
{
|
||||
void free_bitarray(uint32_t *x) {
|
||||
(*free_bitarray_function_p)(x);
|
||||
}
|
||||
|
||||
uint32_t bitcount(uint32_t a)
|
||||
{
|
||||
uint32_t bitcount(uint32_t a) {
|
||||
return (*bitcount_function_p)(a);
|
||||
}
|
||||
|
||||
uint32_t count_states(uint32_t *bitarray)
|
||||
{
|
||||
uint32_t count_states(uint32_t *bitarray) {
|
||||
return (*count_states_function_p)(bitarray);
|
||||
}
|
||||
|
||||
void bitarray_AND(uint32_t *A, uint32_t *B)
|
||||
{
|
||||
void bitarray_AND(uint32_t *A, uint32_t *B) {
|
||||
(*bitarray_AND_function_p)(A, B);
|
||||
}
|
||||
|
||||
void bitarray_low20_AND(uint32_t *A, uint32_t *B)
|
||||
{
|
||||
void bitarray_low20_AND(uint32_t *A, uint32_t *B) {
|
||||
(*bitarray_low20_AND_function_p)(A, B);
|
||||
}
|
||||
|
||||
uint32_t count_bitarray_AND(uint32_t *A, uint32_t *B)
|
||||
{
|
||||
uint32_t count_bitarray_AND(uint32_t *A, uint32_t *B) {
|
||||
return (*count_bitarray_AND_function_p)(A, B);
|
||||
}
|
||||
|
||||
uint32_t count_bitarray_low20_AND(uint32_t *A, uint32_t *B)
|
||||
{
|
||||
uint32_t count_bitarray_low20_AND(uint32_t *A, uint32_t *B) {
|
||||
return (*count_bitarray_low20_AND_function_p)(A, B);
|
||||
}
|
||||
|
||||
void bitarray_AND4(uint32_t *A, uint32_t *B, uint32_t *C, uint32_t *D)
|
||||
{
|
||||
void bitarray_AND4(uint32_t *A, uint32_t *B, uint32_t *C, uint32_t *D) {
|
||||
(*bitarray_AND4_function_p)(A, B, C, D);
|
||||
}
|
||||
|
||||
void bitarray_OR(uint32_t *A, uint32_t *B)
|
||||
{
|
||||
void bitarray_OR(uint32_t *A, uint32_t *B) {
|
||||
(*bitarray_OR_function_p)(A, B);
|
||||
}
|
||||
|
||||
uint32_t count_bitarray_AND2(uint32_t *A, uint32_t *B)
|
||||
{
|
||||
uint32_t count_bitarray_AND2(uint32_t *A, uint32_t *B) {
|
||||
return (*count_bitarray_AND2_function_p)(A, B);
|
||||
}
|
||||
|
||||
uint32_t count_bitarray_AND3(uint32_t *A, uint32_t *B, uint32_t *C)
|
||||
{
|
||||
uint32_t count_bitarray_AND3(uint32_t *A, uint32_t *B, uint32_t *C) {
|
||||
return (*count_bitarray_AND3_function_p)(A, B, C);
|
||||
}
|
||||
|
||||
uint32_t count_bitarray_AND4(uint32_t *A, uint32_t *B, uint32_t *C, uint32_t *D)
|
||||
{
|
||||
uint32_t count_bitarray_AND4(uint32_t *A, uint32_t *B, uint32_t *C, uint32_t *D) {
|
||||
return (*count_bitarray_AND4_function_p)(A, B, C, D);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,8 +89,7 @@ static uint32_t keys_found = 0;
|
|||
static uint64_t num_keys_tested;
|
||||
static uint64_t found_bs_key = 0;
|
||||
|
||||
inline uint8_t trailing_zeros(uint8_t byte)
|
||||
{
|
||||
inline uint8_t trailing_zeros(uint8_t byte) {
|
||||
static const uint8_t trailing_zeros_LUT[256] = {
|
||||
8, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
||||
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
||||
|
@ -114,8 +113,7 @@ inline uint8_t trailing_zeros(uint8_t byte)
|
|||
}
|
||||
|
||||
|
||||
bool verify_key(uint32_t cuid, noncelist_t *nonces, uint8_t *best_first_bytes, uint32_t odd, uint32_t even)
|
||||
{
|
||||
bool verify_key(uint32_t cuid, noncelist_t *nonces, uint8_t *best_first_bytes, uint32_t odd, uint32_t even) {
|
||||
struct Crypto1State pcs;
|
||||
for (uint16_t test_first_byte = 1; test_first_byte < 256; test_first_byte++) {
|
||||
noncelistentry_t *test_nonce = nonces[best_first_bytes[test_first_byte]].first;
|
||||
|
@ -144,8 +142,7 @@ static void *
|
|||
__attribute__((force_align_arg_pointer))
|
||||
#endif
|
||||
#endif
|
||||
crack_states_thread(void *x)
|
||||
{
|
||||
crack_states_thread(void *x) {
|
||||
struct arg {
|
||||
bool silent;
|
||||
int thread_ID;
|
||||
|
@ -193,8 +190,7 @@ crack_states_thread(void *x)
|
|||
}
|
||||
|
||||
|
||||
void prepare_bf_test_nonces(noncelist_t *nonces, uint8_t best_first_byte)
|
||||
{
|
||||
void prepare_bf_test_nonces(noncelist_t *nonces, uint8_t best_first_byte) {
|
||||
// we do bitsliced brute forcing with best_first_bytes[0] only.
|
||||
// Extract the corresponding 2nd bytes
|
||||
noncelistentry_t *test_nonce = nonces[best_first_byte].first;
|
||||
|
@ -221,13 +217,13 @@ void prepare_bf_test_nonces(noncelist_t *nonces, uint8_t best_first_byte)
|
|||
if (n2 != n1) {
|
||||
for (uint16_t n3 = 0; n3 < nonces_to_bruteforce; n3++) {
|
||||
if ((n3 != n2 && n3 != n1) || nonces_to_bruteforce < 3
|
||||
// && trailing_zeros(bf_test_nonce_2nd_byte[n1] ^ bf_test_nonce_2nd_byte[n2])
|
||||
// > trailing_zeros(bf_test_nonce_2nd_byte[n2] ^ bf_test_nonce_2nd_byte[n3])
|
||||
// && trailing_zeros(bf_test_nonce_2nd_byte[n1] ^ bf_test_nonce_2nd_byte[n2])
|
||||
// > trailing_zeros(bf_test_nonce_2nd_byte[n2] ^ bf_test_nonce_2nd_byte[n3])
|
||||
) {
|
||||
for (uint16_t n4 = 0; n4 < nonces_to_bruteforce; n4++) {
|
||||
if ((n4 != n3 && n4 != n2 && n4 != n1) || nonces_to_bruteforce < 4
|
||||
// && trailing_zeros(bf_test_nonce_2nd_byte[n2] ^ bf_test_nonce_2nd_byte[n3])
|
||||
// > trailing_zeros(bf_test_nonce_2nd_byte[n3] ^ bf_test_nonce_2nd_byte[n4])
|
||||
// && trailing_zeros(bf_test_nonce_2nd_byte[n2] ^ bf_test_nonce_2nd_byte[n3])
|
||||
// > trailing_zeros(bf_test_nonce_2nd_byte[n3] ^ bf_test_nonce_2nd_byte[n4])
|
||||
) {
|
||||
int sum = nonces_to_bruteforce > 1 ? trailing_zeros(bf_test_nonce_2nd_byte[n1] ^ bf_test_nonce_2nd_byte[n2]) : 0.0
|
||||
+ nonces_to_bruteforce > 2 ? trailing_zeros(bf_test_nonce_2nd_byte[n2] ^ bf_test_nonce_2nd_byte[n3]) : 0.0
|
||||
|
@ -265,8 +261,7 @@ void prepare_bf_test_nonces(noncelist_t *nonces, uint8_t best_first_byte)
|
|||
|
||||
|
||||
#if defined (WRITE_BENCH_FILE)
|
||||
static void write_benchfile(statelist_t *candidates)
|
||||
{
|
||||
static void write_benchfile(statelist_t *candidates) {
|
||||
|
||||
printf("Writing brute force benchmark data...");
|
||||
FILE *benchfile = fopen(TEST_BENCH_FILENAME, "wb");
|
||||
|
@ -291,8 +286,7 @@ static void write_benchfile(statelist_t *candidates)
|
|||
#endif
|
||||
|
||||
|
||||
bool brute_force_bs(float *bf_rate, statelist_t *candidates, uint32_t cuid, uint32_t num_acquired_nonces, uint64_t maximum_states, noncelist_t *nonces, uint8_t *best_first_bytes, uint64_t *foundkey)
|
||||
{
|
||||
bool brute_force_bs(float *bf_rate, statelist_t *candidates, uint32_t cuid, uint32_t num_acquired_nonces, uint64_t maximum_states, noncelist_t *nonces, uint8_t *best_first_bytes, uint64_t *foundkey) {
|
||||
#if defined (WRITE_BENCH_FILE)
|
||||
write_benchfile(candidates);
|
||||
#endif
|
||||
|
@ -357,8 +351,7 @@ bool brute_force_bs(float *bf_rate, statelist_t *candidates, uint32_t cuid, uint
|
|||
}
|
||||
|
||||
|
||||
static bool read_bench_data(statelist_t *test_candidates)
|
||||
{
|
||||
static bool read_bench_data(statelist_t *test_candidates) {
|
||||
|
||||
size_t bytes_read = 0;
|
||||
uint32_t temp = 0;
|
||||
|
@ -429,8 +422,7 @@ static bool read_bench_data(statelist_t *test_candidates)
|
|||
}
|
||||
|
||||
|
||||
float brute_force_benchmark()
|
||||
{
|
||||
float brute_force_benchmark() {
|
||||
statelist_t test_candidates[NUM_BRUTE_FORCE_THREADS];
|
||||
|
||||
test_candidates[0].states[ODD_STATE] = malloc((TEST_BENCH_SIZE + 1) * sizeof(uint32_t));
|
||||
|
|
|
@ -38,8 +38,7 @@ typedef enum {
|
|||
} odd_even_t;
|
||||
|
||||
|
||||
static uint16_t PartialSumProperty(uint32_t state, odd_even_t odd_even)
|
||||
{
|
||||
static uint16_t PartialSumProperty(uint32_t state, odd_even_t odd_even) {
|
||||
uint16_t sum = 0;
|
||||
for (uint16_t j = 0; j < 16; j++) {
|
||||
uint32_t st = state;
|
||||
|
@ -68,26 +67,22 @@ static uint16_t PartialSumProperty(uint32_t state, odd_even_t odd_even)
|
|||
#define malloc_bitarray(x) __builtin_assume_aligned(_aligned_malloc(x, __BIGGEST_ALIGNMENT__), __BIGGEST_ALIGNMENT__)
|
||||
#define free_bitarray(x) _aligned_free(x)
|
||||
|
||||
static inline void clear_bitarray24(uint32_t *bitarray)
|
||||
{
|
||||
static inline void clear_bitarray24(uint32_t *bitarray) {
|
||||
memset(bitarray, 0x00, sizeof(uint32_t) * (1 << 19));
|
||||
}
|
||||
|
||||
|
||||
static inline uint32_t test_bit24(uint32_t *bitarray, uint32_t index)
|
||||
{
|
||||
static inline uint32_t test_bit24(uint32_t *bitarray, uint32_t index) {
|
||||
return bitarray[index >> 5] & (0x80000000 >> (index & 0x0000001f));
|
||||
}
|
||||
|
||||
|
||||
static inline void set_bit24(uint32_t *bitarray, uint32_t index)
|
||||
{
|
||||
static inline void set_bit24(uint32_t *bitarray, uint32_t index) {
|
||||
bitarray[index >> 5] |= 0x80000000 >> (index & 0x0000001f);
|
||||
}
|
||||
|
||||
|
||||
static inline uint32_t next_state(uint32_t *bitset, uint32_t state)
|
||||
{
|
||||
static inline uint32_t next_state(uint32_t *bitset, uint32_t state) {
|
||||
if (++state == 1 << 24) return 1 << 24;
|
||||
uint32_t index = state >> 5;
|
||||
uint_fast8_t bit = state & 0x1f;
|
||||
|
@ -120,8 +115,7 @@ static inline uint32_t next_state(uint32_t *bitset, uint32_t state)
|
|||
}
|
||||
|
||||
|
||||
static inline uint32_t next_not_state(uint32_t *bitset, uint32_t state)
|
||||
{
|
||||
static inline uint32_t next_not_state(uint32_t *bitset, uint32_t state) {
|
||||
if (++state == 1 << 24) return 1 << 24;
|
||||
uint32_t index = state >> 5;
|
||||
uint_fast8_t bit = state & 0x1f;
|
||||
|
@ -154,8 +148,7 @@ static inline uint32_t next_not_state(uint32_t *bitset, uint32_t state)
|
|||
}
|
||||
|
||||
|
||||
static inline uint32_t bitcount(uint32_t a)
|
||||
{
|
||||
static inline uint32_t bitcount(uint32_t a) {
|
||||
#if defined __GNUC__
|
||||
return __builtin_popcountl(a);
|
||||
#else
|
||||
|
@ -166,8 +159,7 @@ static inline uint32_t bitcount(uint32_t a)
|
|||
}
|
||||
|
||||
|
||||
static inline uint32_t count_states(uint32_t *bitset)
|
||||
{
|
||||
static inline uint32_t count_states(uint32_t *bitset) {
|
||||
uint32_t count = 0;
|
||||
for (uint32_t i = 0; i < (1 << 19); i++) {
|
||||
count += bitcount(bitset[i]);
|
||||
|
@ -176,8 +168,7 @@ static inline uint32_t count_states(uint32_t *bitset)
|
|||
}
|
||||
|
||||
|
||||
static void write_bitflips_file(odd_even_t odd_even, uint16_t bitflip, int sum_a0, uint32_t *bitset, uint32_t count)
|
||||
{
|
||||
static void write_bitflips_file(odd_even_t odd_even, uint16_t bitflip, int sum_a0, uint32_t *bitset, uint32_t count) {
|
||||
char filename[80];
|
||||
sprintf(filename, "bitflip_%d_%03" PRIx16 "_sum%d_states.bin", odd_even, bitflip, sum_a0);
|
||||
FILE *outfile = fopen(filename, "wb");
|
||||
|
@ -189,8 +180,7 @@ static void write_bitflips_file(odd_even_t odd_even, uint16_t bitflip, int sum_a
|
|||
|
||||
uint32_t *restrict part_sum_a0_bitarrays[2][NUM_PART_SUMS];
|
||||
|
||||
static void init_part_sum_bitarrays(void)
|
||||
{
|
||||
static void init_part_sum_bitarrays(void) {
|
||||
printf("init_part_sum_bitarrays()...");
|
||||
for (odd_even_t odd_even = EVEN_STATE; odd_even <= ODD_STATE; odd_even++) {
|
||||
for (uint16_t part_sum_a0 = 0; part_sum_a0 < NUM_PART_SUMS; part_sum_a0++) {
|
||||
|
@ -215,8 +205,7 @@ static void init_part_sum_bitarrays(void)
|
|||
}
|
||||
|
||||
|
||||
static void free_part_sum_bitarrays(void)
|
||||
{
|
||||
static void free_part_sum_bitarrays(void) {
|
||||
printf("free_part_sum_bitarrays()...");
|
||||
for (int16_t part_sum_a0 = (NUM_PART_SUMS - 1); part_sum_a0 >= 0; part_sum_a0--) {
|
||||
free_bitarray(part_sum_a0_bitarrays[ODD_STATE][part_sum_a0]);
|
||||
|
@ -229,8 +218,7 @@ static void free_part_sum_bitarrays(void)
|
|||
|
||||
uint32_t *restrict sum_a0_bitarray[2];
|
||||
|
||||
void init_sum_bitarray(uint16_t sum_a0)
|
||||
{
|
||||
void init_sum_bitarray(uint16_t sum_a0) {
|
||||
printf("init_sum_bitarray()...\n");
|
||||
for (odd_even_t odd_even = EVEN_STATE; odd_even <= ODD_STATE; odd_even++) {
|
||||
sum_a0_bitarray[odd_even] = (uint32_t *)malloc_bitarray(sizeof(uint32_t) * (1 << 19));
|
||||
|
@ -258,8 +246,7 @@ void init_sum_bitarray(uint16_t sum_a0)
|
|||
}
|
||||
|
||||
|
||||
static void free_sum_bitarray(void)
|
||||
{
|
||||
static void free_sum_bitarray(void) {
|
||||
printf("free_sum_bitarray()...");
|
||||
free_bitarray(sum_a0_bitarray[ODD_STATE]);
|
||||
free_bitarray(sum_a0_bitarray[EVEN_STATE]);
|
||||
|
@ -267,8 +254,7 @@ static void free_sum_bitarray(void)
|
|||
}
|
||||
|
||||
|
||||
static void precalculate_bit0_bitflip_bitarrays(uint8_t const bitflip, uint16_t const sum_a0)
|
||||
{
|
||||
static void precalculate_bit0_bitflip_bitarrays(uint8_t const bitflip, uint16_t const sum_a0) {
|
||||
// #define TEST_RUN
|
||||
#ifdef TEST_RUN
|
||||
#define NUM_TEST_STATES (1<<10)
|
||||
|
@ -529,8 +515,7 @@ static void precalculate_bit0_bitflip_bitarrays(uint8_t const bitflip, uint16_t
|
|||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
unsigned int bitflip_in;
|
||||
int sum_a0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue