mirror of
https://github.com/hashcat/hashcat.git
synced 2025-02-16 17:42:04 +00:00
Move hash_mode specific code which enforce the use of the JiT compiler to modules
This commit is contained in:
parent
c88a837196
commit
5633d6808f
@ -49,6 +49,9 @@ int module_hash_decode_zero_hash (MAYBE_UNUSED const hashconfig_t *ha
|
||||
int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, const char *line_buf, MAYBE_UNUSED const int line_len);
|
||||
int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, char *line_buf, MAYBE_UNUSED const int line_size);
|
||||
|
||||
u64 module_extra_buffer_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param);
|
||||
char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param);
|
||||
|
||||
void module_hook12 (hc_device_param_t *device_param, void *hook_salts_buf, const u32 salt_pos, const u64 pws_cnt);
|
||||
void module_hook23 (hc_device_param_t *device_param, void *hook_salts_buf, const u32 salt_pos, const u64 pws_cnt);
|
||||
|
||||
|
@ -964,6 +964,7 @@ struct hashconfig
|
||||
bool outfile_check_nocomp;
|
||||
bool potfile_disable;
|
||||
bool potfile_keep_all_hashes;
|
||||
bool forced_jit_compile;
|
||||
|
||||
u32 pwdump_column;
|
||||
};
|
||||
@ -1315,10 +1316,10 @@ typedef struct hc_device_param
|
||||
cl_mem d_tmps;
|
||||
cl_mem d_hooks;
|
||||
cl_mem d_result;
|
||||
cl_mem d_scryptV0_buf;
|
||||
cl_mem d_scryptV1_buf;
|
||||
cl_mem d_scryptV2_buf;
|
||||
cl_mem d_scryptV3_buf;
|
||||
cl_mem d_extra0_buf;
|
||||
cl_mem d_extra1_buf;
|
||||
cl_mem d_extra2_buf;
|
||||
cl_mem d_extra3_buf;
|
||||
cl_mem d_root_css_buf;
|
||||
cl_mem d_markov_css_buf;
|
||||
cl_mem d_st_digests_buf;
|
||||
@ -2285,6 +2286,9 @@ typedef struct module_ctx
|
||||
int (*module_hash_decode) (const hashconfig_t *, void *, salt_t *, void *, const char *, const int);
|
||||
int (*module_hash_encode) (const hashconfig_t *, const void *, const salt_t *, const void *, char *, int);
|
||||
|
||||
u64 (*module_extra_buffer_size) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *, const hashes_t *, const hc_device_param_t *);
|
||||
char *(*module_jit_build_options) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *, const hashes_t *, const hc_device_param_t *);
|
||||
|
||||
void (*module_hook12) (hc_device_param_t *, const void *, const u32, const u64);
|
||||
void (*module_hook23) (hc_device_param_t *, const void *, const u32, const u64);
|
||||
|
||||
|
@ -128,6 +128,7 @@ void module_init (module_ctx_t *module_ctx)
|
||||
module_ctx->module_dgst_size = module_dgst_size;
|
||||
module_ctx->module_dictstat_disable = NULL;
|
||||
module_ctx->module_esalt_size = NULL;
|
||||
module_ctx->module_extra_buffer_size = NULL;
|
||||
module_ctx->module_forced_kernel_loops = NULL;
|
||||
module_ctx->module_forced_kernel_threads = NULL;
|
||||
module_ctx->module_forced_outfile_format = NULL;
|
||||
@ -143,6 +144,7 @@ void module_init (module_ctx_t *module_ctx)
|
||||
module_ctx->module_hook23 = NULL;
|
||||
module_ctx->module_hook_salt_size = NULL;
|
||||
module_ctx->module_hook_size = NULL;
|
||||
module_ctx->module_jit_build_options = NULL;
|
||||
module_ctx->module_kern_type = module_kern_type;
|
||||
module_ctx->module_opti_type = module_opti_type;
|
||||
module_ctx->module_opts_type = module_opts_type;
|
||||
|
@ -28549,3 +28549,345 @@ int build_plain_postprocess (const u32 *src_buf, MAYBE_UNUSED const size_t src_s
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
u64 module_size_extra_buffer (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param);
|
||||
{
|
||||
|
||||
// scryptV stuff
|
||||
|
||||
u64 scrypt_tmp_size = 0;
|
||||
u64 scrypt_tmto_final = 0;
|
||||
|
||||
u64 size_scrypt = 4;
|
||||
|
||||
if ((hashconfig->hash_mode == 8900) || (hashconfig->hash_mode == 9300) || (hashconfig->hash_mode == 15700))
|
||||
{
|
||||
// we need to check that all hashes have the same scrypt settings
|
||||
|
||||
const u32 scrypt_N = hashes->salts_buf[0].scrypt_N;
|
||||
const u32 scrypt_r = hashes->salts_buf[0].scrypt_r;
|
||||
const u32 scrypt_p = hashes->salts_buf[0].scrypt_p;
|
||||
|
||||
for (u32 i = 1; i < hashes->salts_cnt; i++)
|
||||
{
|
||||
if ((hashes->salts_buf[i].scrypt_N != scrypt_N)
|
||||
|| (hashes->salts_buf[i].scrypt_r != scrypt_r)
|
||||
|| (hashes->salts_buf[i].scrypt_p != scrypt_p))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Mixed scrypt settings are not supported.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
scrypt_tmp_size = (128 * scrypt_r * scrypt_p);
|
||||
|
||||
hashconfig->tmp_size = scrypt_tmp_size;
|
||||
|
||||
u32 tmto_start = 1;
|
||||
u32 tmto_stop = 6;
|
||||
|
||||
if (user_options->scrypt_tmto)
|
||||
{
|
||||
tmto_start = user_options->scrypt_tmto;
|
||||
tmto_stop = user_options->scrypt_tmto;
|
||||
}
|
||||
|
||||
const u32 scrypt_threads = hashconfig->forced_kernel_threads;
|
||||
|
||||
const u64 kernel_power_max = SCRYPT_MAX_ACCEL * device_processors * scrypt_threads;
|
||||
|
||||
// size_pws
|
||||
|
||||
const u64 size_pws = kernel_power_max * sizeof (pw_t);
|
||||
|
||||
const u64 size_pws_amp = size_pws;
|
||||
|
||||
// size_pws_comp
|
||||
|
||||
const u64 size_pws_comp = kernel_power_max * (sizeof (u32) * 64);
|
||||
|
||||
// size_pws_idx
|
||||
|
||||
const u64 size_pws_idx = (kernel_power_max + 1) * sizeof (pw_idx_t);
|
||||
|
||||
// size_tmps
|
||||
|
||||
const u64 size_tmps = kernel_power_max * hashconfig->tmp_size;
|
||||
|
||||
// size_hooks
|
||||
|
||||
const u64 size_hooks = kernel_power_max * hashconfig->hook_size;
|
||||
|
||||
const u64 scrypt_extra_space
|
||||
= bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ size_bfs
|
||||
+ size_combs
|
||||
+ size_digests
|
||||
+ size_esalts
|
||||
+ size_hooks
|
||||
+ size_markov_css
|
||||
+ size_plains
|
||||
+ size_pws
|
||||
+ size_pws_amp
|
||||
+ size_pws_comp
|
||||
+ size_pws_idx
|
||||
+ size_results
|
||||
+ size_root_css
|
||||
+ size_rules
|
||||
+ size_rules_c
|
||||
+ size_salts
|
||||
+ size_shown
|
||||
+ size_tm
|
||||
+ size_tmps
|
||||
+ size_st_digests
|
||||
+ size_st_salts
|
||||
+ size_st_esalts;
|
||||
|
||||
bool not_enough_memory = true;
|
||||
|
||||
u32 tmto;
|
||||
|
||||
for (tmto = tmto_start; tmto <= tmto_stop; tmto++)
|
||||
{
|
||||
size_scrypt = (128 * scrypt_r) * scrypt_N;
|
||||
|
||||
size_scrypt /= 1u << tmto;
|
||||
|
||||
size_scrypt *= kernel_power_max;
|
||||
|
||||
if ((size_scrypt / 4) > device_param->device_maxmem_alloc)
|
||||
{
|
||||
if (user_options->quiet == false) event_log_warning (hashcat_ctx, "Increasing single-block device memory allocatable for --scrypt-tmto %u.", tmto);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((size_scrypt + scrypt_extra_space) > device_param->device_available_mem)
|
||||
{
|
||||
if (user_options->quiet == false) event_log_warning (hashcat_ctx, "Increasing total device memory allocatable for --scrypt-tmto %u.", tmto);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
for (u32 salts_pos = 0; salts_pos < hashes->salts_cnt; salts_pos++)
|
||||
{
|
||||
scrypt_tmto_final = tmto;
|
||||
}
|
||||
|
||||
not_enough_memory = false;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (not_enough_memory == true)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Cannot allocate enough device memory. Perhaps retry with -n 1.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if defined (DEBUG)
|
||||
if (user_options->quiet == false) event_log_warning (hashcat_ctx, "SCRYPT tmto optimizer value set to: %lu, mem: %lu", scrypt_tmto_final, size_scrypt);
|
||||
if (user_options->quiet == false) event_log_warning (hashcat_ctx, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
u64 size_scrypt4 = size_scrypt / 4;
|
||||
|
||||
return size_scrypt4;
|
||||
}
|
||||
|
||||
|
||||
char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param);
|
||||
{
|
||||
/**
|
||||
* Some algorithm, like descrypt, can benefit from JIT compilation
|
||||
*/
|
||||
|
||||
|
||||
if (hashconfig->hash_mode == 8900)
|
||||
{
|
||||
opencl_ctx->force_jit_compilation = 8900;
|
||||
}
|
||||
else if (hashconfig->hash_mode == 9300)
|
||||
{
|
||||
opencl_ctx->force_jit_compilation = 8900;
|
||||
}
|
||||
else if (hashconfig->hash_mode == 15700)
|
||||
{
|
||||
opencl_ctx->force_jit_compilation = 15700;
|
||||
}
|
||||
else if (hashconfig->hash_mode == 1500 && user_options->attack_mode == ATTACK_MODE_BF && hashes->salts_cnt == 1 && user_options->slow_candidates == false)
|
||||
{
|
||||
opencl_ctx->force_jit_compilation = 1500;
|
||||
}
|
||||
|
||||
// scryptV stuff
|
||||
|
||||
u64 scrypt_tmp_size = 0;
|
||||
u64 scrypt_tmto_final = 0;
|
||||
|
||||
u64 size_scrypt = 4;
|
||||
|
||||
if ((hashconfig->hash_mode == 8900) || (hashconfig->hash_mode == 9300) || (hashconfig->hash_mode == 15700))
|
||||
{
|
||||
// we need to check that all hashes have the same scrypt settings
|
||||
|
||||
const u32 scrypt_N = hashes->salts_buf[0].scrypt_N;
|
||||
const u32 scrypt_r = hashes->salts_buf[0].scrypt_r;
|
||||
const u32 scrypt_p = hashes->salts_buf[0].scrypt_p;
|
||||
|
||||
for (u32 i = 1; i < hashes->salts_cnt; i++)
|
||||
{
|
||||
if ((hashes->salts_buf[i].scrypt_N != scrypt_N)
|
||||
|| (hashes->salts_buf[i].scrypt_r != scrypt_r)
|
||||
|| (hashes->salts_buf[i].scrypt_p != scrypt_p))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Mixed scrypt settings are not supported.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
scrypt_tmp_size = (128 * scrypt_r * scrypt_p);
|
||||
|
||||
hashconfig->tmp_size = scrypt_tmp_size;
|
||||
|
||||
u32 tmto_start = 1;
|
||||
u32 tmto_stop = 6;
|
||||
|
||||
if (user_options->scrypt_tmto)
|
||||
{
|
||||
tmto_start = user_options->scrypt_tmto;
|
||||
tmto_stop = user_options->scrypt_tmto;
|
||||
}
|
||||
|
||||
const u32 scrypt_threads = hashconfig->forced_kernel_threads;
|
||||
|
||||
const u64 kernel_power_max = SCRYPT_MAX_ACCEL * device_processors * scrypt_threads;
|
||||
|
||||
// size_pws
|
||||
|
||||
const u64 size_pws = kernel_power_max * sizeof (pw_t);
|
||||
|
||||
const u64 size_pws_amp = size_pws;
|
||||
|
||||
// size_pws_comp
|
||||
|
||||
const u64 size_pws_comp = kernel_power_max * (sizeof (u32) * 64);
|
||||
|
||||
// size_pws_idx
|
||||
|
||||
const u64 size_pws_idx = (kernel_power_max + 1) * sizeof (pw_idx_t);
|
||||
|
||||
// size_tmps
|
||||
|
||||
const u64 size_tmps = kernel_power_max * hashconfig->tmp_size;
|
||||
|
||||
// size_hooks
|
||||
|
||||
const u64 size_hooks = kernel_power_max * hashconfig->hook_size;
|
||||
|
||||
const u64 scrypt_extra_space
|
||||
= bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ size_bfs
|
||||
+ size_combs
|
||||
+ size_digests
|
||||
+ size_esalts
|
||||
+ size_hooks
|
||||
+ size_markov_css
|
||||
+ size_plains
|
||||
+ size_pws
|
||||
+ size_pws_amp
|
||||
+ size_pws_comp
|
||||
+ size_pws_idx
|
||||
+ size_results
|
||||
+ size_root_css
|
||||
+ size_rules
|
||||
+ size_rules_c
|
||||
+ size_salts
|
||||
+ size_shown
|
||||
+ size_tm
|
||||
+ size_tmps
|
||||
+ size_st_digests
|
||||
+ size_st_salts
|
||||
+ size_st_esalts;
|
||||
|
||||
bool not_enough_memory = true;
|
||||
|
||||
u32 tmto;
|
||||
|
||||
for (tmto = tmto_start; tmto <= tmto_stop; tmto++)
|
||||
{
|
||||
size_scrypt = (128 * scrypt_r) * scrypt_N;
|
||||
|
||||
size_scrypt /= 1u << tmto;
|
||||
|
||||
size_scrypt *= kernel_power_max;
|
||||
|
||||
if ((size_scrypt / 4) > device_param->device_maxmem_alloc)
|
||||
{
|
||||
if (user_options->quiet == false) event_log_warning (hashcat_ctx, "Increasing single-block device memory allocatable for --scrypt-tmto %u.", tmto);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((size_scrypt + scrypt_extra_space) > device_param->device_available_mem)
|
||||
{
|
||||
if (user_options->quiet == false) event_log_warning (hashcat_ctx, "Increasing total device memory allocatable for --scrypt-tmto %u.", tmto);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
for (u32 salts_pos = 0; salts_pos < hashes->salts_cnt; salts_pos++)
|
||||
{
|
||||
scrypt_tmto_final = tmto;
|
||||
}
|
||||
|
||||
not_enough_memory = false;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (not_enough_memory == true)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Cannot allocate enough device memory. Perhaps retry with -n 1.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if defined (DEBUG)
|
||||
if (user_options->quiet == false) event_log_warning (hashcat_ctx, "SCRYPT tmto optimizer value set to: %lu, mem: %lu", scrypt_tmto_final, size_scrypt);
|
||||
if (user_options->quiet == false) event_log_warning (hashcat_ctx, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t size_scrypt4 = size_scrypt / 4;
|
||||
|
||||
|
||||
|
||||
if (opencl_ctx->force_jit_compilation == 1500)
|
||||
{
|
||||
hc_asprintf (&build_opts_update, "%s -DDESCRYPT_SALT=%u", build_opts, hashes->salts_buf[0].salt_buf[0]);
|
||||
}
|
||||
else if ((opencl_ctx->force_jit_compilation == 8900) || (opencl_ctx->force_jit_compilation == 15700))
|
||||
{
|
||||
hc_asprintf (&build_opts_update,"%s -DSCRYPT_N=%u -DSCRYPT_R=%u -DSCRYPT_P=%u -DSCRYPT_TMTO=%u -DSCRYPT_TMP_ELEM=%" PRIu64, build_opts, hashes->salts_buf[0].scrypt_N, hashes->salts_buf[0].scrypt_r, hashes->salts_buf[0].scrypt_p, 1u << scrypt_tmto_final, (u64) scrypt_tmp_size / 16);
|
||||
}
|
||||
|
||||
}
|
||||
|
250
src/opencl.c
250
src/opencl.c
@ -1212,7 +1212,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
if (hashconfig->hash_mode == 2000)
|
||||
if (user_options->stdout_flag == true)
|
||||
{
|
||||
return process_stdout (hashcat_ctx, device_param, pws_cnt);
|
||||
}
|
||||
@ -4301,40 +4301,18 @@ static u32 get_kernel_threads (hashcat_ctx_t *hashcat_ctx, const hc_device_param
|
||||
|
||||
int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx;
|
||||
folder_config_t *folder_config = hashcat_ctx->folder_config;
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
||||
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
const bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx;
|
||||
const folder_config_t *folder_config = hashcat_ctx->folder_config;
|
||||
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
const hashes_t *hashes = hashcat_ctx->hashes;
|
||||
const module_ctx_t *module_ctx = hashcat_ctx->module_ctx;
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
||||
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
if (opencl_ctx->enabled == false) return 0;
|
||||
|
||||
/**
|
||||
* Some algorithm, like descrypt, can benefit from JIT compilation
|
||||
*/
|
||||
|
||||
opencl_ctx->force_jit_compilation = -1;
|
||||
|
||||
if (hashconfig->hash_mode == 8900)
|
||||
{
|
||||
opencl_ctx->force_jit_compilation = 8900;
|
||||
}
|
||||
else if (hashconfig->hash_mode == 9300)
|
||||
{
|
||||
opencl_ctx->force_jit_compilation = 8900;
|
||||
}
|
||||
else if (hashconfig->hash_mode == 15700)
|
||||
{
|
||||
opencl_ctx->force_jit_compilation = 15700;
|
||||
}
|
||||
else if (hashconfig->hash_mode == 1500 && user_options->attack_mode == ATTACK_MODE_BF && hashes->salts_cnt == 1 && user_options->slow_candidates == false)
|
||||
{
|
||||
opencl_ctx->force_jit_compilation = 1500;
|
||||
}
|
||||
|
||||
u32 hardware_power_all = 0;
|
||||
|
||||
for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
|
||||
@ -4701,6 +4679,13 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
device_param->size_st_salts = size_st_salts;
|
||||
device_param->size_st_esalts = size_st_esalts;
|
||||
|
||||
u64 size_extra_buffer = 4;
|
||||
|
||||
if (module_ctx->module_extra_buffer_size)
|
||||
{
|
||||
size_extra_buffer = module_ctx->module_extra_buffer_size (hashconfig, user_options, user_options_extra, hashes, device_param);
|
||||
}
|
||||
|
||||
/**
|
||||
* some algorithms need a fixed kernel-loops count
|
||||
*/
|
||||
@ -4721,155 +4706,6 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
device_param->size_rules = size_rules;
|
||||
device_param->size_rules_c = size_rules_c;
|
||||
|
||||
// scryptV stuff
|
||||
|
||||
u64 scrypt_tmp_size = 0;
|
||||
u64 scrypt_tmto_final = 0;
|
||||
|
||||
u64 size_scrypt = 4;
|
||||
|
||||
if ((hashconfig->hash_mode == 8900) || (hashconfig->hash_mode == 9300) || (hashconfig->hash_mode == 15700))
|
||||
{
|
||||
// we need to check that all hashes have the same scrypt settings
|
||||
|
||||
const u32 scrypt_N = hashes->salts_buf[0].scrypt_N;
|
||||
const u32 scrypt_r = hashes->salts_buf[0].scrypt_r;
|
||||
const u32 scrypt_p = hashes->salts_buf[0].scrypt_p;
|
||||
|
||||
for (u32 i = 1; i < hashes->salts_cnt; i++)
|
||||
{
|
||||
if ((hashes->salts_buf[i].scrypt_N != scrypt_N)
|
||||
|| (hashes->salts_buf[i].scrypt_r != scrypt_r)
|
||||
|| (hashes->salts_buf[i].scrypt_p != scrypt_p))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Mixed scrypt settings are not supported.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
scrypt_tmp_size = (128 * scrypt_r * scrypt_p);
|
||||
|
||||
hashconfig->tmp_size = scrypt_tmp_size;
|
||||
|
||||
u32 tmto_start = 1;
|
||||
u32 tmto_stop = 6;
|
||||
|
||||
if (user_options->scrypt_tmto)
|
||||
{
|
||||
tmto_start = user_options->scrypt_tmto;
|
||||
tmto_stop = user_options->scrypt_tmto;
|
||||
}
|
||||
|
||||
const u32 scrypt_threads = hashconfig->forced_kernel_threads;
|
||||
|
||||
const u64 kernel_power_max = SCRYPT_MAX_ACCEL * device_processors * scrypt_threads;
|
||||
|
||||
// size_pws
|
||||
|
||||
const u64 size_pws = kernel_power_max * sizeof (pw_t);
|
||||
|
||||
const u64 size_pws_amp = size_pws;
|
||||
|
||||
// size_pws_comp
|
||||
|
||||
const u64 size_pws_comp = kernel_power_max * (sizeof (u32) * 64);
|
||||
|
||||
// size_pws_idx
|
||||
|
||||
const u64 size_pws_idx = (kernel_power_max + 1) * sizeof (pw_idx_t);
|
||||
|
||||
// size_tmps
|
||||
|
||||
const u64 size_tmps = kernel_power_max * hashconfig->tmp_size;
|
||||
|
||||
// size_hooks
|
||||
|
||||
const u64 size_hooks = kernel_power_max * hashconfig->hook_size;
|
||||
|
||||
const u64 scrypt_extra_space
|
||||
= bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ bitmap_ctx->bitmap_size
|
||||
+ size_bfs
|
||||
+ size_combs
|
||||
+ size_digests
|
||||
+ size_esalts
|
||||
+ size_hooks
|
||||
+ size_markov_css
|
||||
+ size_plains
|
||||
+ size_pws
|
||||
+ size_pws_amp
|
||||
+ size_pws_comp
|
||||
+ size_pws_idx
|
||||
+ size_results
|
||||
+ size_root_css
|
||||
+ size_rules
|
||||
+ size_rules_c
|
||||
+ size_salts
|
||||
+ size_shown
|
||||
+ size_tm
|
||||
+ size_tmps
|
||||
+ size_st_digests
|
||||
+ size_st_salts
|
||||
+ size_st_esalts;
|
||||
|
||||
bool not_enough_memory = true;
|
||||
|
||||
u32 tmto;
|
||||
|
||||
for (tmto = tmto_start; tmto <= tmto_stop; tmto++)
|
||||
{
|
||||
size_scrypt = (128 * scrypt_r) * scrypt_N;
|
||||
|
||||
size_scrypt /= 1u << tmto;
|
||||
|
||||
size_scrypt *= kernel_power_max;
|
||||
|
||||
if ((size_scrypt / 4) > device_param->device_maxmem_alloc)
|
||||
{
|
||||
if (user_options->quiet == false) event_log_warning (hashcat_ctx, "Increasing single-block device memory allocatable for --scrypt-tmto %u.", tmto);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((size_scrypt + scrypt_extra_space) > device_param->device_available_mem)
|
||||
{
|
||||
if (user_options->quiet == false) event_log_warning (hashcat_ctx, "Increasing total device memory allocatable for --scrypt-tmto %u.", tmto);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
for (u32 salts_pos = 0; salts_pos < hashes->salts_cnt; salts_pos++)
|
||||
{
|
||||
scrypt_tmto_final = tmto;
|
||||
}
|
||||
|
||||
not_enough_memory = false;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (not_enough_memory == true)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Cannot allocate enough device memory. Perhaps retry with -n 1.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if defined (DEBUG)
|
||||
if (user_options->quiet == false) event_log_warning (hashcat_ctx, "SCRYPT tmto optimizer value set to: %lu, mem: %lu", scrypt_tmto_final, size_scrypt);
|
||||
if (user_options->quiet == false) event_log_warning (hashcat_ctx, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t size_scrypt4 = size_scrypt / 4;
|
||||
|
||||
/**
|
||||
* default building options
|
||||
*/
|
||||
@ -5052,7 +4888,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
char **kernel_sources = &kernel_sources_buf;
|
||||
|
||||
if (opencl_ctx->force_jit_compilation == -1)
|
||||
if (module_ctx->module_jit_build_options == NULL)
|
||||
{
|
||||
if (cached == false)
|
||||
{
|
||||
@ -5149,13 +4985,11 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
char *build_opts_update;
|
||||
|
||||
if (opencl_ctx->force_jit_compilation == 1500)
|
||||
if (module_ctx->module_jit_build_options)
|
||||
{
|
||||
hc_asprintf (&build_opts_update, "%s -DDESCRYPT_SALT=%u", build_opts, hashes->salts_buf[0].salt_buf[0]);
|
||||
}
|
||||
else if ((opencl_ctx->force_jit_compilation == 8900) || (opencl_ctx->force_jit_compilation == 15700))
|
||||
{
|
||||
hc_asprintf (&build_opts_update,"%s -DSCRYPT_N=%u -DSCRYPT_R=%u -DSCRYPT_P=%u -DSCRYPT_TMTO=%u -DSCRYPT_TMP_ELEM=%" PRIu64, build_opts, hashes->salts_buf[0].scrypt_N, hashes->salts_buf[0].scrypt_r, hashes->salts_buf[0].scrypt_p, 1u << scrypt_tmto_final, (u64) scrypt_tmp_size / 16);
|
||||
char *jit_build_options = module_ctx->module_jit_build_options (hashconfig, user_options, user_options_extra, hashes, device_param);
|
||||
|
||||
hc_asprintf (&build_opts_update, "%s %s", build_opts, jit_build_options);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -5524,10 +5358,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_shown, NULL, &device_param->d_digests_shown); if (CL_rc == -1) return -1;
|
||||
CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_salts, NULL, &device_param->d_salt_bufs); if (CL_rc == -1) return -1;
|
||||
CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_results, NULL, &device_param->d_result); if (CL_rc == -1) return -1;
|
||||
CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV0_buf); if (CL_rc == -1) return -1;
|
||||
CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV1_buf); if (CL_rc == -1) return -1;
|
||||
CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV2_buf); if (CL_rc == -1) return -1;
|
||||
CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV3_buf); if (CL_rc == -1) return -1;
|
||||
CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_extra_buffer, NULL, &device_param->d_extra0_buf); if (CL_rc == -1) return -1;
|
||||
CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_extra_buffer, NULL, &device_param->d_extra1_buf); if (CL_rc == -1) return -1;
|
||||
CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_extra_buffer, NULL, &device_param->d_extra2_buf); if (CL_rc == -1) return -1;
|
||||
CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_extra_buffer, NULL, &device_param->d_extra3_buf); if (CL_rc == -1) return -1;
|
||||
CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_st_digests, NULL, &device_param->d_st_digests_buf); if (CL_rc == -1) return -1;
|
||||
CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_st_salts, NULL, &device_param->d_st_salts_buf); if (CL_rc == -1) return -1;
|
||||
|
||||
@ -5640,10 +5474,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
device_param->kernel_params[17] = &device_param->d_salt_bufs;
|
||||
device_param->kernel_params[18] = &device_param->d_esalt_bufs;
|
||||
device_param->kernel_params[19] = &device_param->d_result;
|
||||
device_param->kernel_params[20] = &device_param->d_scryptV0_buf;
|
||||
device_param->kernel_params[21] = &device_param->d_scryptV1_buf;
|
||||
device_param->kernel_params[22] = &device_param->d_scryptV2_buf;
|
||||
device_param->kernel_params[23] = &device_param->d_scryptV3_buf;
|
||||
device_param->kernel_params[20] = &device_param->d_extra0_buf;
|
||||
device_param->kernel_params[21] = &device_param->d_extra1_buf;
|
||||
device_param->kernel_params[22] = &device_param->d_extra2_buf;
|
||||
device_param->kernel_params[23] = &device_param->d_extra3_buf;
|
||||
device_param->kernel_params[24] = &device_param->kernel_params_buf32[24];
|
||||
device_param->kernel_params[25] = &device_param->kernel_params_buf32[25];
|
||||
device_param->kernel_params[26] = &device_param->kernel_params_buf32[26];
|
||||
@ -6661,10 +6495,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
+ size_rules
|
||||
+ size_rules_c
|
||||
+ size_salts
|
||||
+ size_scrypt4
|
||||
+ size_scrypt4
|
||||
+ size_scrypt4
|
||||
+ size_scrypt4
|
||||
+ size_extra_buffer
|
||||
+ size_extra_buffer
|
||||
+ size_extra_buffer
|
||||
+ size_extra_buffer
|
||||
+ size_shown
|
||||
+ size_tm
|
||||
+ size_tmps
|
||||
@ -6930,10 +6764,10 @@ void opencl_session_destroy (hashcat_ctx_t *hashcat_ctx)
|
||||
if (device_param->d_tmps) hc_clReleaseMemObject (hashcat_ctx, device_param->d_tmps);
|
||||
if (device_param->d_hooks) hc_clReleaseMemObject (hashcat_ctx, device_param->d_hooks);
|
||||
if (device_param->d_result) hc_clReleaseMemObject (hashcat_ctx, device_param->d_result);
|
||||
if (device_param->d_scryptV0_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV0_buf);
|
||||
if (device_param->d_scryptV1_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV1_buf);
|
||||
if (device_param->d_scryptV2_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV2_buf);
|
||||
if (device_param->d_scryptV3_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV3_buf);
|
||||
if (device_param->d_extra0_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_extra0_buf);
|
||||
if (device_param->d_extra1_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_extra1_buf);
|
||||
if (device_param->d_extra2_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_extra2_buf);
|
||||
if (device_param->d_extra3_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_extra3_buf);
|
||||
if (device_param->d_root_css_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_root_css_buf);
|
||||
if (device_param->d_markov_css_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_markov_css_buf);
|
||||
if (device_param->d_tm_c) hc_clReleaseMemObject (hashcat_ctx, device_param->d_tm_c);
|
||||
@ -7003,10 +6837,10 @@ void opencl_session_destroy (hashcat_ctx_t *hashcat_ctx)
|
||||
device_param->d_tmps = NULL;
|
||||
device_param->d_hooks = NULL;
|
||||
device_param->d_result = NULL;
|
||||
device_param->d_scryptV0_buf = NULL;
|
||||
device_param->d_scryptV1_buf = NULL;
|
||||
device_param->d_scryptV2_buf = NULL;
|
||||
device_param->d_scryptV3_buf = NULL;
|
||||
device_param->d_extra0_buf = NULL;
|
||||
device_param->d_extra1_buf = NULL;
|
||||
device_param->d_extra2_buf = NULL;
|
||||
device_param->d_extra3_buf = NULL;
|
||||
device_param->d_root_css_buf = NULL;
|
||||
device_param->d_markov_css_buf = NULL;
|
||||
device_param->d_tm_c = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user