1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-13 19:28:56 +00:00
hashcat/src/cpt.c

61 lines
1.4 KiB
C
Raw Normal View History

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"
#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;
cpt_ctx->enabled = false;
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;
cpt_ctx->enabled = true;
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;
cpt_ctx->cpt_start = hc_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;
if (cpt_ctx->enabled == false) return;
hcfree (cpt_ctx->cpt_buf);
2016-09-29 13:19:12 +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;
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;
cpt_ctx->cpt_start = hc_time (NULL);
2016-09-29 13:19:12 +00:00
}