1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-26 08:28:20 +00:00

Unit-Tests: Added missing support for OPTS_TYPE_LOOP_PREPARE, OPTS_TYPE_LOOP_PREPARE2 and salt_repeats in self-test

This commit is contained in:
Jens Steube 2021-06-11 18:36:19 +02:00
parent 388e0a1c7e
commit 51fe320425
2 changed files with 66 additions and 44 deletions

View File

@ -65,6 +65,7 @@
- Modules: Recategorized HASH_CATEGORY option in various modules
- Modules: Added hash categories HASH_CATEGORY_IMS and HASH_CATEGORY_CRYPTOCURRENCY_WALLET
- Modules: Changed hash category of Python passlib from HASH_CATEGORY_GENERIC_KDF to HASH_CATEGORY_FRAMEWORK
- Unit-Tests: Added missing support for OPTS_TYPE_LOOP_PREPARE, OPTS_TYPE_LOOP_PREPARE2 and salt_repeats in self-test
- Unit-Tests: Added missing unit-test for Stargazer Stellar Wallet XLM
* changes v6.2.0 -> v6.2.1

View File

@ -481,55 +481,67 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
}
}
const u32 loop_step = hashconfig->kernel_loops_min + ((hashconfig->kernel_loops_max - hashconfig->kernel_loops_min) / 32);
const u32 salt_pos = 0;
salt_t *salt_buf = &hashes->st_salts_buf[salt_pos];
const u32 loop_step = hashconfig->kernel_loops_min + ((hashconfig->kernel_loops_max - hashconfig->kernel_loops_min) / 32);
const u32 salt_repeats = hashes->salts_buf[salt_pos].salt_repeats;
const u32 iter = salt_buf->salt_iter;
for (u32 loop_pos = 0; loop_pos < iter; loop_pos += loop_step)
for (u32 salt_repeat = 0; salt_repeat <= salt_repeats; salt_repeat++)
{
u32 loop_left = iter - loop_pos;
device_param->kernel_params_buf32[34] = salt_repeat;
loop_left = MIN (loop_left, loop_step);
device_param->kernel_params_buf32[28] = loop_pos;
device_param->kernel_params_buf32[29] = loop_left;
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2, 0, 1, false, 0) == -1) return -1;
if (hashconfig->opts_type & OPTS_TYPE_LOOP_EXTENDED)
if (hashconfig->opts_type & OPTS_TYPE_LOOP_PREPARE)
{
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2E, 0, 1, false, 0) == -1) return -1;
}
}
if (hashconfig->opts_type & OPTS_TYPE_HOOK23)
{
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_23, 0, 1, false, 0) == -1) return -1;
if (device_param->is_cuda == true)
{
if (hc_cuMemcpyDtoH (hashcat_ctx, device_param->hooks_buf, device_param->cuda_d_hooks, device_param->size_hooks) == -1) return -1;
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2P, 0, 1, false, 0) == -1) return -1;
}
if (device_param->is_opencl == true)
const u32 iter = salt_buf->salt_iter;
for (u32 loop_pos = 0; loop_pos < iter; loop_pos += loop_step)
{
if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1;
u32 loop_left = iter - loop_pos;
loop_left = MIN (loop_left, loop_step);
device_param->kernel_params_buf32[28] = loop_pos;
device_param->kernel_params_buf32[29] = loop_left;
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2, 0, 1, false, 0) == -1) return -1;
if (hashconfig->opts_type & OPTS_TYPE_LOOP_EXTENDED)
{
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2E, 0, 1, false, 0) == -1) return -1;
}
}
module_ctx->module_hook23 (device_param, module_ctx->hook_extra_params[0], hashes->st_hook_salts_buf, 0, 0);
if (device_param->is_cuda == true)
if (hashconfig->opts_type & OPTS_TYPE_HOOK23)
{
if (hc_cuMemcpyHtoD (hashcat_ctx, device_param->cuda_d_hooks, device_param->hooks_buf, device_param->size_hooks) == -1) return -1;
}
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_23, 0, 1, false, 0) == -1) return -1;
if (device_param->is_opencl == true)
{
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1;
if (device_param->is_cuda == true)
{
if (hc_cuMemcpyDtoH (hashcat_ctx, device_param->hooks_buf, device_param->cuda_d_hooks, device_param->size_hooks) == -1) return -1;
}
if (device_param->is_opencl == true)
{
if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1;
}
module_ctx->module_hook23 (device_param, module_ctx->hook_extra_params[0], hashes->st_hook_salts_buf, 0, 0);
if (device_param->is_cuda == true)
{
if (hc_cuMemcpyHtoD (hashcat_ctx, device_param->cuda_d_hooks, device_param->hooks_buf, device_param->size_hooks) == -1) return -1;
}
if (device_param->is_opencl == true)
{
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1;
}
}
}
@ -538,20 +550,30 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_INIT2, 0, 1, false, 0) == -1) return -1;
}
if (hashconfig->opts_type & OPTS_TYPE_LOOP2)
for (u32 salt_repeat = 0; salt_repeat <= salt_repeats; salt_repeat++)
{
const u32 iter2 = salt_buf->salt_iter2;
device_param->kernel_params_buf32[34] = salt_repeat;
for (u32 loop_pos = 0; loop_pos < iter2; loop_pos += loop_step)
if (hashconfig->opts_type & OPTS_TYPE_LOOP2_PREPARE)
{
u32 loop_left = iter2 - loop_pos;
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_LOOP2P, 0, 1, false, 0) == -1) return -1;
}
loop_left = MIN (loop_left, loop_step);
if (hashconfig->opts_type & OPTS_TYPE_LOOP2)
{
const u32 iter2 = salt_buf->salt_iter2;
device_param->kernel_params_buf32[28] = loop_pos;
device_param->kernel_params_buf32[29] = loop_left;
for (u32 loop_pos = 0; loop_pos < iter2; loop_pos += loop_step)
{
u32 loop_left = iter2 - loop_pos;
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_LOOP2, 0, 1, false, 0) == -1) return -1;
loop_left = MIN (loop_left, loop_step);
device_param->kernel_params_buf32[28] = loop_pos;
device_param->kernel_params_buf32[29] = loop_left;
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_LOOP2, 0, 1, false, 0) == -1) return -1;
}
}
}
@ -602,14 +624,13 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
// finish : cleanup and restore
device_param->kernel_params_buf32[27] = 0;
device_param->kernel_params_buf32[28] = 0;
device_param->kernel_params_buf32[29] = 0;
device_param->kernel_params_buf32[30] = 0;
device_param->kernel_params_buf32[31] = 0;
device_param->kernel_params_buf32[32] = 0;
device_param->kernel_params_buf32[33] = 0;
device_param->kernel_params_buf64[34] = 0;
device_param->kernel_params_buf32[34] = 0;
if (device_param->is_cuda == true)
{