2016-09-29 15:19:12 +02:00
|
|
|
/**
|
|
|
|
* Author......: See docs/credits.txt
|
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "types.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "cpt.h"
|
|
|
|
|
2016-10-06 10:26:47 +02:00
|
|
|
int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
2016-09-29 15:19:12 +02:00
|
|
|
{
|
2016-10-06 10:26:47 +02:00
|
|
|
cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
|
|
|
|
user_options_t *user_options = hashcat_ctx->user_options;
|
|
|
|
|
2016-09-30 11:48:14 +02:00
|
|
|
cpt_ctx->enabled = false;
|
|
|
|
|
2022-02-13 12:33:11 +01:00
|
|
|
if (user_options->hash_info == true) return 0;
|
|
|
|
if (user_options->keyspace == true) return 0;
|
|
|
|
if (user_options->left == true) return 0;
|
|
|
|
if (user_options->show == true) return 0;
|
|
|
|
if (user_options->usage == true) return 0;
|
|
|
|
if (user_options->version == true) return 0;
|
|
|
|
if (user_options->identify == true) return 0;
|
|
|
|
if (user_options->backend_info > 0) return 0;
|
2016-09-30 11:48:14 +02:00
|
|
|
|
|
|
|
cpt_ctx->enabled = true;
|
|
|
|
|
2016-11-20 22:54:52 +01:00
|
|
|
cpt_ctx->cpt_buf = (cpt_t *) hccalloc (CPT_CACHE, sizeof (cpt_t));
|
2016-09-29 15:19:12 +02:00
|
|
|
|
|
|
|
cpt_ctx->cpt_total = 0;
|
|
|
|
cpt_ctx->cpt_pos = 0;
|
2017-12-09 16:40:45 -08:00
|
|
|
cpt_ctx->cpt_start = time (NULL);
|
2016-09-29 15:19:12 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-10-06 10:26:47 +02:00
|
|
|
void cpt_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
|
2016-09-29 15:19:12 +02:00
|
|
|
{
|
2016-10-06 10:26:47 +02:00
|
|
|
cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
|
|
|
|
|
2016-10-02 00:00:21 +02:00
|
|
|
if (cpt_ctx->enabled == false) return;
|
2016-09-30 11:48:14 +02:00
|
|
|
|
2016-10-10 11:03:11 +02:00
|
|
|
hcfree (cpt_ctx->cpt_buf);
|
2016-09-29 15:19:12 +02:00
|
|
|
|
2016-10-02 00:00:21 +02:00
|
|
|
memset (cpt_ctx, 0, sizeof (cpt_ctx_t));
|
2016-09-29 15:19:12 +02:00
|
|
|
}
|
|
|
|
|
2016-10-06 10:26:47 +02:00
|
|
|
void cpt_ctx_reset (hashcat_ctx_t *hashcat_ctx)
|
2016-09-29 15:19:12 +02:00
|
|
|
{
|
2016-10-06 10:26:47 +02:00
|
|
|
cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
|
|
|
|
|
2016-09-30 11:48:14 +02:00
|
|
|
if (cpt_ctx->enabled == false) return;
|
|
|
|
|
2016-10-25 12:25:53 +02:00
|
|
|
memset (cpt_ctx->cpt_buf, 0, CPT_CACHE * sizeof (cpt_t));
|
2016-09-29 15:19:12 +02:00
|
|
|
|
|
|
|
cpt_ctx->cpt_total = 0;
|
|
|
|
cpt_ctx->cpt_pos = 0;
|
2017-12-09 16:40:45 -08:00
|
|
|
cpt_ctx->cpt_start = time (NULL);
|
2016-09-29 15:19:12 +02:00
|
|
|
}
|