diff --git a/crypto1_bs_crack.h b/crypto1_bs_crack.h index 5dec59e..db9e1c7 100644 --- a/crypto1_bs_crack.h +++ b/crypto1_bs_crack.h @@ -5,8 +5,8 @@ #include "craptev1.h" uint64_t crack_states_bitsliced(uint32_t **task); size_t keys_found; -size_t total_states_tested; -size_t total_states; +uint64_t total_states_tested; +uint64_t total_states; // linked from crapto1.c file extern uint8_t lfsr_rollback_byte(uint64_t* s, uint32_t in, int fb); diff --git a/libnfc_crypto1_crack.c b/libnfc_crypto1_crack.c index 1da7259..634345c 100755 --- a/libnfc_crypto1_crack.c +++ b/libnfc_crypto1_crack.c @@ -293,6 +293,7 @@ POSSIBILITY OF SUCH DAMAGES. #include #include "crypto1_bs_crack.h" +#define llu PRIu64 extern uint64_t * crypto1_create(uint64_t key); extern uint32_t crypto1_word(uint64_t *, uint32_t, int); @@ -520,7 +521,7 @@ void notify_status_online(int sig){ if(!total_states){ printf(VT100_cleareol "Collected %zu nonces... ", nonces_collected); } else { - printf(VT100_cleareol "Collected %zu nonces... leftover complexity %zu (~2^%0.2f)", nonces_collected, total_states, log(total_states) / log(2)); + printf(VT100_cleareol "Collected %zu nonces... leftover complexity %"llu" (~2^%0.2f)", nonces_collected, total_states, log(total_states) / log(2)); char c; if(scanf("%c", &c) == 1 || total_states < CUTOFF){ printf(" - initializing brute-force phase...\n"); @@ -690,7 +691,7 @@ int main (int argc, const char * argv[]) { crypto1_bs_bitslice_value32(~(test_parity)<<24, bitsliced_encrypted_parity_bits[tests], 4); } - printf("Starting %zu threads to test %zu states using %u-way bitslicing\n", thread_count, total_states, MAX_BITSLICES); + printf("Starting %zu threads to test %"llu" states using %u-way bitslicing\n", thread_count, total_states, MAX_BITSLICES); total_states_tested = 0; keys_found = 0; signal(SIGALRM, notify_status_offline); @@ -713,7 +714,7 @@ int main (int argc, const char * argv[]) { } else { printf("Found key: %012"PRIx64"\n", found_key); } - printf("Tested %zu states\n", total_states_tested); + printf("Tested %"llu" states\n", total_states_tested); craptev1_destroy_space(space); return 0; diff --git a/solve_bs.c b/solve_bs.c index fc5ef99..44a0515 100644 --- a/solve_bs.c +++ b/solve_bs.c @@ -12,6 +12,7 @@ #define __STDC_FORMAT_MACROS #define llx PRIx64 #define lli PRIi64 +#define llu PRIu64 #define lu PRIu32 // linked from .so / .c files by bla @@ -31,7 +32,7 @@ void* crack_states_thread(void* x){ } else if(keys_found){ break; } else { - printf("Cracking... %6.02f%%\n", (100.0*total_states_tested/(total_states))); + printf("Cracking... %6.02f%%\n", (total_states_tested/(total_states/100.0))); } } return NULL; @@ -82,14 +83,14 @@ int main(int argc, char* argv[]){ total_states_tested = 0; keys_found = 0; - printf("Starting %zu threads to test %zu states\n", thread_count, total_states); + printf("Starting %zu threads to test %"llu" states\n", thread_count, total_states); for(i = 0; i < thread_count; i++){ pthread_create(&threads[i], NULL, crack_states_thread, (void*) i); } for(i = 0; i < thread_count; i++){ pthread_join(threads[i], 0); } - printf("Tested %zu states\n", total_states_tested); + printf("Tested %"llu" states\n", total_states_tested); craptev1_destroy_space(space); return 0; diff --git a/solve_piwi.c b/solve_piwi.c index 1526e09..102cb02 100644 --- a/solve_piwi.c +++ b/solve_piwi.c @@ -9,6 +9,7 @@ #define __STDC_FORMAT_MACROS #define llx PRIx64 #define lli PRIi64 +#define llu PRIu64 #define lu PRIu32 #define rev32(word) (((word & 0xff) << 24) | (((word >> 8) & 0xff) << 16) | (((word >> 16) & 0xff) << 8) | (((word >> 24) & 0xff))) @@ -43,8 +44,8 @@ uint64_t *readnonces(char* fname){ uint32_t **space; size_t thread_count; -size_t states_tested = 0; -size_t total_states; +uint64_t states_tested = 0; +uint64_t total_states; void* crack_states_thread(void* x){ const size_t thread_id = (size_t)x; @@ -80,7 +81,7 @@ int main(int argc, char* argv[]){ space[j] = 0; } pthread_t threads[thread_count]; - printf("Starting %zu threads to test %zu states\n", thread_count, total_states); + printf("Starting %zu threads to test %"llu" states\n", thread_count, total_states); size_t i; states_tested = 0; for(i = 0; i < thread_count; i++){ @@ -89,7 +90,7 @@ int main(int argc, char* argv[]){ for(i = 0; i < thread_count; i++){ pthread_join(threads[i], 0); } - printf("Tested %zu states\n", states_tested); + printf("Tested %"llu" states\n", states_tested); craptev1_destroy_space(space); return 0; diff --git a/solve_piwi_bs.c b/solve_piwi_bs.c index 2bce609..920d4d6 100644 --- a/solve_piwi_bs.c +++ b/solve_piwi_bs.c @@ -12,6 +12,7 @@ #define __STDC_FORMAT_MACROS #define llx PRIx64 #define lli PRIi64 +#define llu PRIu64 #define lu PRIu32 uint64_t split(uint8_t p){ @@ -106,14 +107,14 @@ int main(int argc, char* argv[]){ total_states_tested = 0; keys_found = 0; - printf("Starting %zu threads to test %zu states\n", thread_count, total_states); + printf("Starting %zu threads to test %"llu" states\n", thread_count, total_states); for(i = 0; i < thread_count; i++){ pthread_create(&threads[i], NULL, crack_states_thread, (void*) i); } for(i = 0; i < thread_count; i++){ pthread_join(threads[i], 0); } - printf("Tested %zu states\n", total_states_tested); + printf("Tested %"llu" states\n", total_states_tested); craptev1_destroy_space(space); return 0;