mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-28 10:57:56 +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 "crapto1/crapto1.h"
|
||||
#include "parity.h"
|
||||
#include "fileutils.h"
|
||||
#include "pm3_cmd.h"
|
||||
|
||||
#define NUM_BRUTE_FORCE_THREADS (num_CPUs())
|
||||
#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_FILENAME "hardnested/bf_bench_data.bin"
|
||||
#define TEST_BENCH_FILENAME "hardnested_bf_bench_data.bin"
|
||||
//#define WRITE_BENCH_FILE
|
||||
|
||||
// debugging options
|
||||
|
@ -265,8 +267,12 @@ 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) {
|
||||
|
||||
printf("Writing brute force benchmark data...");
|
||||
FILE *benchfile = fopen(TEST_BENCH_FILENAME, "wb");
|
||||
PrintAndLogEx(NORMAL, "Writing brute force benchmark data in " RESOURCES_SUBDIR " subdirectory...");
|
||||
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);
|
||||
for (uint32_t i = 0; i < nonces_to_bruteforce; i++) {
|
||||
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);
|
||||
}
|
||||
fclose(benchfile);
|
||||
printf("done.\n");
|
||||
PrintAndLogEx(NORMAL, "Done");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -360,14 +366,17 @@ static bool read_bench_data(statelist_t *test_candidates) {
|
|||
uint32_t num_states = 0;
|
||||
uint32_t states_read = 0;
|
||||
|
||||
char bench_file_path[strlen(get_my_executable_directory()) + strlen(TEST_BENCH_FILENAME) + 1];
|
||||
strcpy(bench_file_path, get_my_executable_directory());
|
||||
strcat(bench_file_path, TEST_BENCH_FILENAME);
|
||||
|
||||
FILE *benchfile = fopen(bench_file_path, "rb");
|
||||
if (benchfile == NULL) {
|
||||
char *path;
|
||||
if (searchFile(&path, RESOURCES_SUBDIR, TEST_BENCH_FILENAME, "") != PM3_SUCCESS) {
|
||||
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);
|
||||
if (bytes_read != sizeof(nonces_to_bruteforce)) {
|
||||
fclose(benchfile);
|
||||
|
|
Loading…
Reference in a new issue