mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-30 03:53:26 +08:00
move bf_bench_data.bin to resources/hardnested_*
This commit is contained in:
parent
0771f0ae95
commit
eba13925e4
2 changed files with 19 additions and 10 deletions
|
@ -65,11 +65,13 @@ THE SOFTWARE.
|
||||||
#include "util_posix.h"
|
#include "util_posix.h"
|
||||||
#include "crapto1/crapto1.h"
|
#include "crapto1/crapto1.h"
|
||||||
#include "parity.h"
|
#include "parity.h"
|
||||||
|
#include "fileutils.h"
|
||||||
|
#include "pm3_cmd.h"
|
||||||
|
|
||||||
#define NUM_BRUTE_FORCE_THREADS (num_CPUs())
|
#define NUM_BRUTE_FORCE_THREADS (num_CPUs())
|
||||||
#define DEFAULT_BRUTE_FORCE_RATE (120000000.0) // if benchmark doesn't succeed
|
#define DEFAULT_BRUTE_FORCE_RATE (120000000.0) // if benchmark doesn't succeed
|
||||||
#define TEST_BENCH_SIZE (6000) // number of odd and even states for brute force benchmark
|
#define TEST_BENCH_SIZE (6000) // number of odd and even states for brute force benchmark
|
||||||
#define TEST_BENCH_FILENAME "hardnested/bf_bench_data.bin"
|
#define TEST_BENCH_FILENAME "hardnested_bf_bench_data.bin"
|
||||||
//#define WRITE_BENCH_FILE
|
//#define WRITE_BENCH_FILE
|
||||||
|
|
||||||
// debugging options
|
// debugging options
|
||||||
|
@ -265,8 +267,12 @@ void prepare_bf_test_nonces(noncelist_t *nonces, uint8_t best_first_byte) {
|
||||||
#if defined (WRITE_BENCH_FILE)
|
#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...");
|
PrintAndLogEx(NORMAL, "Writing brute force benchmark data in " RESOURCES_SUBDIR " subdirectory...");
|
||||||
FILE *benchfile = fopen(TEST_BENCH_FILENAME, "wb");
|
FILE *benchfile = fopen(RESOURCES_SUBDIR TEST_BENCH_FILENAME, "wb");
|
||||||
|
if (benchfile == NULL) {
|
||||||
|
PrintAndLogEx(ERR, "Can't write " RESOURCES_SUBDIR TEST_BENCH_FILENAME", abort!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
fwrite(&nonces_to_bruteforce, 1, sizeof(nonces_to_bruteforce), benchfile);
|
fwrite(&nonces_to_bruteforce, 1, sizeof(nonces_to_bruteforce), benchfile);
|
||||||
for (uint32_t i = 0; i < nonces_to_bruteforce; i++) {
|
for (uint32_t i = 0; i < nonces_to_bruteforce; i++) {
|
||||||
fwrite(&(bf_test_nonce[i]), 1, sizeof(bf_test_nonce[i]), benchfile);
|
fwrite(&(bf_test_nonce[i]), 1, sizeof(bf_test_nonce[i]), benchfile);
|
||||||
|
@ -283,7 +289,7 @@ static void write_benchfile(statelist_t *candidates) {
|
||||||
fwrite(&(candidates->states[ODD_STATE][i]), 1, sizeof(uint32_t), benchfile);
|
fwrite(&(candidates->states[ODD_STATE][i]), 1, sizeof(uint32_t), benchfile);
|
||||||
}
|
}
|
||||||
fclose(benchfile);
|
fclose(benchfile);
|
||||||
printf("done.\n");
|
PrintAndLogEx(NORMAL, "Done");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -360,14 +366,17 @@ static bool read_bench_data(statelist_t *test_candidates) {
|
||||||
uint32_t num_states = 0;
|
uint32_t num_states = 0;
|
||||||
uint32_t states_read = 0;
|
uint32_t states_read = 0;
|
||||||
|
|
||||||
char bench_file_path[strlen(get_my_executable_directory()) + strlen(TEST_BENCH_FILENAME) + 1];
|
char *path;
|
||||||
strcpy(bench_file_path, get_my_executable_directory());
|
if (searchFile(&path, RESOURCES_SUBDIR, TEST_BENCH_FILENAME, "") != PM3_SUCCESS) {
|
||||||
strcat(bench_file_path, TEST_BENCH_FILENAME);
|
|
||||||
|
|
||||||
FILE *benchfile = fopen(bench_file_path, "rb");
|
|
||||||
if (benchfile == NULL) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FILE *benchfile = fopen(path, "rb");
|
||||||
|
if (benchfile == NULL) {
|
||||||
|
free(path);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
free(path);
|
||||||
bytes_read = fread(&nonces_to_bruteforce, 1, sizeof(nonces_to_bruteforce), benchfile);
|
bytes_read = fread(&nonces_to_bruteforce, 1, sizeof(nonces_to_bruteforce), benchfile);
|
||||||
if (bytes_read != sizeof(nonces_to_bruteforce)) {
|
if (bytes_read != sizeof(nonces_to_bruteforce)) {
|
||||||
fclose(benchfile);
|
fclose(benchfile);
|
||||||
|
|
Loading…
Reference in a new issue