Skip to content

Commit

Permalink
Armory format: Free the tests' memory allocation before actual cracking
Browse files Browse the repository at this point in the history
  • Loading branch information
solardiz committed Jan 12, 2024
1 parent 286c020 commit 1d7397a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
8 changes: 3 additions & 5 deletions doc/README-Armory
Expand Up @@ -60,8 +60,6 @@ target wallet's settings.
Since our built-in test vectors currently include 32 MiB test wallet data
extracts, the self-test at startup will potentially (depending on number
of threads and SIMD) consume a lot of memory (and take much time, too).
That memory currently remains allocated further during the run even if
your actual target wallet's data extract needs less memory. If this is
a problem (perhaps if you're on a system supporting a lot of hardware
threads, but having little RAM), you may remove some test vectors from
the "tests" array in armory_fmt_plug.c and re-run "make".
If this is a problem (perhaps if you're on a system supporting a lot of
hardware threads, but having little RAM), you may remove some test
vectors from the "tests" array in armory_fmt_plug.c and re-run "make".
20 changes: 19 additions & 1 deletion src/armory_fmt_plug.c
Expand Up @@ -141,6 +141,24 @@ static void done(void)
secp256k1_context_destroy(secp256k1_ctx);
}

/*
* Free the tests' memory allocation before actual cracking, so that it doesn't
* affect long-term memory usage in case the actual targets need less memory
* than the tests. However, don't do this when proceeding from self-test to
* benchmark, so that memory (de)allocation time doesn't affect the speeds.
*/
void reset(struct db_main *db)
{
if (benchmark_running)
return;

int i;
for (i = 0; i < max_threads; i++) {
free_region_t(&memory[i]);
init_region_t(&memory[i]);
}
}

static void *get_salt(char *ciphertext)
{
uint8_t decoded[BINARY_SIZE + SALT_SIZE];
Expand Down Expand Up @@ -486,7 +504,7 @@ struct fmt_main fmt_armory = {
}, {
init,
done,
fmt_default_reset,
reset,
fmt_default_prepare,
valid,
fmt_default_split,
Expand Down

0 comments on commit 1d7397a

Please sign in to comment.