- time(&end);
- unsigned long elapsed_time = difftime(end, start);
- PrintAndLog("Tested %"PRIu32" states, found %u keys after %u seconds", total_states_tested, keys_found, elapsed_time);
- if(!keys_found){
- assert(total_states_tested == maximum_states);
- }
- // reset this counter for the next call
- nonces_to_bruteforce = 0;
+ pthread_t threads[thread_count];
+
+ // enumerate states using all hardware threads, each thread handles one bucket
+ PrintAndLog("Starting %u cracking threads to search %u buckets containing a total of %"PRIu64" states...", thread_count, bucket_count, maximum_states);
+
+ for(size_t i = 0; i < thread_count; i++){
+ pthread_create(&threads[i], NULL, crack_states_thread, (void*) i);
+ }
+ for(size_t i = 0; i < thread_count; i++){
+ pthread_join(threads[i], 0);
+ }
+
+ time(&end);
+ unsigned long elapsed_time = difftime(end, start);
+
+ if (keys_found && TestIfKeyExists(foundkey)) {
+ PrintAndLog("Success! Tested %"PRIu32" states, found %u keys after %u seconds", total_states_tested, keys_found, elapsed_time);
+ PrintAndLog("\nFound key: %012"PRIx64"\n", foundkey);
+ ret = true;
+ } else {
+ PrintAndLog("Fail! Tested %"PRIu32" states, in %u seconds", total_states_tested, elapsed_time);
+ }
+
+ // reset this counter for the next call
+ nonces_to_bruteforce = 0;