mirror of
https://github.com/hashcat/hashcat.git
synced 2025-07-25 16:08:39 +00:00
Merge pull request #4274 from matrix/selftest_splitted
Selftest: rename selftest function to process_selftest and splitting into 3 smaller functions
This commit is contained in:
commit
57c8ac4b54
@ -141,6 +141,7 @@
|
|||||||
- Modules: Updated module_unstable_warning
|
- Modules: Updated module_unstable_warning
|
||||||
- Open Document Format: Added support for small documents with content length < 1024
|
- Open Document Format: Added support for small documents with content length < 1024
|
||||||
- OpenCL Backend: added workaround to set device_available_memory from CUDA/HIP alias device
|
- OpenCL Backend: added workaround to set device_available_memory from CUDA/HIP alias device
|
||||||
|
- Selftest: rename selftest function to process_selftest and splitting into 3 smaller functions
|
||||||
- Status Code: Add specific return code for self-test fail (-11)
|
- Status Code: Add specific return code for self-test fail (-11)
|
||||||
- Scrypt: Increase buffer sizes in module for hash mode 8900 to allow longer scrypt digests
|
- Scrypt: Increase buffer sizes in module for hash mode 8900 to allow longer scrypt digests
|
||||||
- Unicode: Update UTF-8 to UTF-16 conversion to match RFC 3629
|
- Unicode: Update UTF-8 to UTF-16 conversion to match RFC 3629
|
||||||
|
@ -12,18 +12,14 @@
|
|||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "selftest.h"
|
#include "selftest.h"
|
||||||
|
|
||||||
static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
static int selftest_init (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, u32 *highest_pw_len)
|
||||||
{
|
{
|
||||||
bridge_ctx_t *bridge_ctx = hashcat_ctx->bridge_ctx;
|
|
||||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
|
||||||
hashes_t *hashes = hashcat_ctx->hashes;
|
hashes_t *hashes = hashcat_ctx->hashes;
|
||||||
module_ctx_t *module_ctx = hashcat_ctx->module_ctx;
|
module_ctx_t *module_ctx = hashcat_ctx->module_ctx;
|
||||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||||
user_options_t *user_options = hashcat_ctx->user_options;
|
user_options_t *user_options = hashcat_ctx->user_options;
|
||||||
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||||
|
|
||||||
if (hashconfig->st_hash == NULL) return 0;
|
|
||||||
|
|
||||||
// init : replace hashes with selftest hash
|
// init : replace hashes with selftest hash
|
||||||
|
|
||||||
if (device_param->is_cuda == true)
|
if (device_param->is_cuda == true)
|
||||||
@ -86,8 +82,6 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
|
|||||||
pw_t comb;
|
pw_t comb;
|
||||||
bf_t bf;
|
bf_t bf;
|
||||||
|
|
||||||
u32 highest_pw_len = 0;
|
|
||||||
|
|
||||||
if (user_options->slow_candidates == true)
|
if (user_options->slow_candidates == true)
|
||||||
{
|
{
|
||||||
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
|
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
|
||||||
@ -460,7 +454,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
|
|||||||
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_pws_buf, CL_FALSE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL) == -1) return -1;
|
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_pws_buf, CL_FALSE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL) == -1) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
highest_pw_len = pw.pw_len;
|
*highest_pw_len = pw.pw_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -500,6 +494,16 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int selftest_run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, u32 highest_pw_len)
|
||||||
|
{
|
||||||
|
bridge_ctx_t *bridge_ctx = hashcat_ctx->bridge_ctx;
|
||||||
|
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||||
|
hashes_t *hashes = hashcat_ctx->hashes;
|
||||||
|
module_ctx_t *module_ctx = hashcat_ctx->module_ctx;
|
||||||
|
|
||||||
// main : run the kernel
|
// main : run the kernel
|
||||||
|
|
||||||
const u32 kernel_threads_sav = device_param->kernel_threads;
|
const u32 kernel_threads_sav = device_param->kernel_threads;
|
||||||
@ -933,22 +937,28 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
|
|||||||
|
|
||||||
device_param->kernel_threads = kernel_threads_sav;
|
device_param->kernel_threads = kernel_threads_sav;
|
||||||
|
|
||||||
// check : check if cracked
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
u32 num_cracked = 0;
|
static int selftest_cleanup (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, u32 *num_cracked)
|
||||||
|
{
|
||||||
|
user_options_t *user_options = hashcat_ctx->user_options;
|
||||||
|
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||||
|
|
||||||
|
// check : check if cracked
|
||||||
|
|
||||||
cl_event opencl_event;
|
cl_event opencl_event;
|
||||||
|
|
||||||
if (device_param->is_cuda == true)
|
if (device_param->is_cuda == true)
|
||||||
{
|
{
|
||||||
if (hc_cuMemcpyDtoHAsync (hashcat_ctx, &num_cracked, device_param->cuda_d_result, sizeof (u32), device_param->cuda_stream) == -1) return -1;
|
if (hc_cuMemcpyDtoHAsync (hashcat_ctx, num_cracked, device_param->cuda_d_result, sizeof (u32), device_param->cuda_stream) == -1) return -1;
|
||||||
|
|
||||||
if (hc_cuEventRecord (hashcat_ctx, device_param->cuda_event3, device_param->cuda_stream) == -1) return -1;
|
if (hc_cuEventRecord (hashcat_ctx, device_param->cuda_event3, device_param->cuda_stream) == -1) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device_param->is_hip == true)
|
if (device_param->is_hip == true)
|
||||||
{
|
{
|
||||||
if (hc_hipMemcpyDtoHAsync (hashcat_ctx, &num_cracked, device_param->hip_d_result, sizeof (u32), device_param->hip_stream) == -1) return -1;
|
if (hc_hipMemcpyDtoHAsync (hashcat_ctx, num_cracked, device_param->hip_d_result, sizeof (u32), device_param->hip_stream) == -1) return -1;
|
||||||
|
|
||||||
if (hc_hipEventRecord (hashcat_ctx, device_param->hip_event3, device_param->hip_stream) == -1) return -1;
|
if (hc_hipEventRecord (hashcat_ctx, device_param->hip_event3, device_param->hip_stream) == -1) return -1;
|
||||||
}
|
}
|
||||||
@ -956,13 +966,13 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
|
|||||||
#if defined (__APPLE__)
|
#if defined (__APPLE__)
|
||||||
if (device_param->is_metal == true)
|
if (device_param->is_metal == true)
|
||||||
{
|
{
|
||||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, &num_cracked, device_param->metal_d_result, 0, sizeof (u32)) == -1) return -1;
|
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, num_cracked, device_param->metal_d_result, 0, sizeof (u32)) == -1) return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (device_param->is_opencl == true)
|
if (device_param->is_opencl == true)
|
||||||
{
|
{
|
||||||
if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_result, CL_FALSE, 0, sizeof (u32), &num_cracked, 0, NULL, &opencl_event) == -1) return -1;
|
if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_result, CL_FALSE, 0, sizeof (u32), num_cracked, 0, NULL, &opencl_event) == -1) return -1;
|
||||||
|
|
||||||
if (hc_clFlush (hashcat_ctx, device_param->opencl_command_queue) == -1) return -1;
|
if (hc_clFlush (hashcat_ctx, device_param->opencl_command_queue) == -1) return -1;
|
||||||
}
|
}
|
||||||
@ -1154,7 +1164,27 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
|
|||||||
if (hc_clReleaseEvent (hashcat_ctx, opencl_event) == -1) return -1;
|
if (hc_clReleaseEvent (hashcat_ctx, opencl_event) == -1) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int process_selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||||
|
{
|
||||||
|
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||||
|
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||||
|
|
||||||
|
if (hashconfig->st_hash == NULL) return 0;
|
||||||
|
|
||||||
|
u32 highest_pw_len = 0;
|
||||||
|
u32 num_cracked = 0;
|
||||||
|
|
||||||
|
if (selftest_init (hashcat_ctx, device_param, &highest_pw_len) == -1) return -1;
|
||||||
|
|
||||||
|
if (selftest_run_kernel (hashcat_ctx, device_param, highest_pw_len) == -1) return -1;
|
||||||
|
|
||||||
|
if (selftest_cleanup (hashcat_ctx, device_param, &num_cracked) == -1) return -1;
|
||||||
|
|
||||||
// check return
|
// check return
|
||||||
|
|
||||||
if (num_cracked == 0)
|
if (num_cracked == 0)
|
||||||
{
|
{
|
||||||
hc_thread_mutex_lock (status_ctx->mux_display);
|
hc_thread_mutex_lock (status_ctx->mux_display);
|
||||||
@ -1169,20 +1199,22 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
|
|||||||
event_log_error (hashcat_ctx, "* Device #%u: ATTENTION! HIP kernel self-test failed.", device_param->device_id + 1);
|
event_log_error (hashcat_ctx, "* Device #%u: ATTENTION! HIP kernel self-test failed.", device_param->device_id + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined (__APPLE__)
|
|
||||||
if (device_param->is_metal == true)
|
if (device_param->is_metal == true)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "* Device #%u: ATTENTION! Metal kernel self-test failed.", device_param->device_id + 1);
|
event_log_error (hashcat_ctx, "* Device #%u: ATTENTION! Metal kernel self-test failed.", device_param->device_id + 1);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (device_param->is_opencl == true)
|
if (device_param->is_opencl == true)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "* Device #%u: ATTENTION! OpenCL kernel self-test failed.", device_param->device_id + 1);
|
event_log_error (hashcat_ctx, "* Device #%u: ATTENTION! OpenCL kernel self-test failed.", device_param->device_id + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
event_log_warning (hashcat_ctx, "Your device driver installation is probably broken.");
|
if (device_param->is_metal == false)
|
||||||
event_log_warning (hashcat_ctx, "See also: https://hashcat.net/faq/wrongdriver");
|
{
|
||||||
|
event_log_warning (hashcat_ctx, "Your device driver installation is probably broken.");
|
||||||
|
event_log_warning (hashcat_ctx, "See also: https://hashcat.net/faq/wrongdriver");
|
||||||
|
}
|
||||||
|
|
||||||
event_log_warning (hashcat_ctx, NULL);
|
event_log_warning (hashcat_ctx, NULL);
|
||||||
|
|
||||||
hc_thread_mutex_unlock (status_ctx->mux_display);
|
hc_thread_mutex_unlock (status_ctx->mux_display);
|
||||||
@ -1232,7 +1264,7 @@ HC_API_CALL void *thread_selftest (void *p)
|
|||||||
if (hc_hipCtxPushCurrent (hashcat_ctx, device_param->hip_context) == -1) return NULL;
|
if (hc_hipCtxPushCurrent (hashcat_ctx, device_param->hip_context) == -1) return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int rc_selftest = selftest (hashcat_ctx, device_param);
|
const int rc_selftest = process_selftest (hashcat_ctx, device_param);
|
||||||
|
|
||||||
if (user_options->benchmark == true)
|
if (user_options->benchmark == true)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user