diff --git a/include/cpt.h b/include/cpt.h index 1211924a7..bdc22a24e 100644 --- a/include/cpt.h +++ b/include/cpt.h @@ -10,8 +10,8 @@ #include #include -int cpt_ctx_init (cpt_ctx_t *cpt_ctx, const user_options_t *user_options); -void cpt_ctx_destroy (cpt_ctx_t *cpt_ctx); -void cpt_ctx_reset (cpt_ctx_t *cpt_ctx); +int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx); +void cpt_ctx_destroy (hashcat_ctx_t *hashcat_ctx); +void cpt_ctx_reset (hashcat_ctx_t *hashcat_ctx); #endif // _CPT_H diff --git a/src/cpt.c b/src/cpt.c index 0b6f5b688..58938b528 100644 --- a/src/cpt.c +++ b/src/cpt.c @@ -9,8 +9,11 @@ #include "logging.h" #include "cpt.h" -int cpt_ctx_init (cpt_ctx_t *cpt_ctx, const user_options_t *user_options) +int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx) { + cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; + user_options_t *user_options = hashcat_ctx->user_options; + cpt_ctx->enabled = false; if (user_options->keyspace == true) return 0; @@ -32,8 +35,10 @@ int cpt_ctx_init (cpt_ctx_t *cpt_ctx, const user_options_t *user_options) return 0; } -void cpt_ctx_destroy (cpt_ctx_t *cpt_ctx) +void cpt_ctx_destroy (hashcat_ctx_t *hashcat_ctx) { + cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; + if (cpt_ctx->enabled == false) return; myfree (cpt_ctx->cpt_buf); @@ -41,8 +46,10 @@ void cpt_ctx_destroy (cpt_ctx_t *cpt_ctx) memset (cpt_ctx, 0, sizeof (cpt_ctx_t)); } -void cpt_ctx_reset (cpt_ctx_t *cpt_ctx) +void cpt_ctx_reset (hashcat_ctx_t *hashcat_ctx) { + cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; + if (cpt_ctx->enabled == false) return; memset (cpt_ctx->cpt_buf, 0, CPT_BUF * sizeof (cpt_t)); diff --git a/src/hashcat.c b/src/hashcat.c index 394bd0a9e..9b23fffe2 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -117,7 +117,6 @@ void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx) static int inner2_loop (hashcat_ctx_t *hashcat_ctx) { combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; - cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx; hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; @@ -169,7 +168,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) opencl_session_reset (opencl_ctx); - cpt_ctx_reset (cpt_ctx); + cpt_ctx_reset (hashcat_ctx); // figure out wordlist based workload @@ -760,7 +759,6 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) static int outer_loop (hashcat_ctx_t *hashcat_ctx) { bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx; - cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; folder_config_t *folder_config = hashcat_ctx->folder_config; hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; @@ -913,7 +911,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) * cracks-per-time allocate buffer */ - cpt_ctx_init (cpt_ctx, user_options); + cpt_ctx_init (hashcat_ctx); /** * Wordlist allocate buffer @@ -1232,7 +1230,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) wl_data_destroy (wl_data); - cpt_ctx_destroy (cpt_ctx); + cpt_ctx_destroy (hashcat_ctx); return 0; }