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