From b847bbb2743f9e117e1db0f0288c8e427a36cd9e Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 22 Jul 2017 18:46:12 +0200 Subject: [PATCH] Fix calculation of device_name_chksum; should be done for each iteration --- include/types.h | 3 ++- src/opencl.c | 50 +++++++++++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/include/types.h b/include/types.h index 07d1095ee..36a83a073 100644 --- a/include/types.h +++ b/include/types.h @@ -1008,7 +1008,6 @@ typedef struct hc_device_param char *device_name; char *device_vendor; - char *device_name_chksum; char *device_version; char *driver_version; char *device_opencl_version; @@ -1142,6 +1141,8 @@ typedef struct opencl_ctx bool need_xnvctrl; bool need_sysfs; + int comptime; + int force_jit_compilation; } opencl_ctx_t; diff --git a/src/opencl.c b/src/opencl.c index 3fa5d0280..13648276a 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -3121,27 +3121,6 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) device_param->driver_version = driver_version; - // device_name_chksum - - char *device_name_chksum = (char *) hcmalloc (HCBUFSIZ_TINY); - - #if defined (__x86_64__) - const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%d-%u-%u-%s-%s-%s-%d-%u-%u", 64, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, comptime, user_options->opencl_vector_width, user_options->hash_mode); - #else - const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%d-%u-%u-%s-%s-%s-%d-%u-%u", 32, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, comptime, user_options->opencl_vector_width, user_options->hash_mode); - #endif - - u32 device_name_digest[4] = { 0 }; - - for (size_t i = 0; i < dnclen; i += 64) - { - md5_64 ((u32 *) (device_name_chksum + i), device_name_digest); - } - - snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%08x", device_name_digest[0]); - - device_param->device_name_chksum = device_name_chksum; - // vendor specific if (device_param->device_type & CL_DEVICE_TYPE_GPU) @@ -3436,6 +3415,8 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) opencl_ctx->need_xnvctrl = need_xnvctrl; opencl_ctx->need_sysfs = need_sysfs; + opencl_ctx->comptime = comptime; + return 0; } @@ -3459,7 +3440,6 @@ void opencl_ctx_devices_destroy (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped == true) continue; hcfree (device_param->device_name); - hcfree (device_param->device_name_chksum); hcfree (device_param->device_version); hcfree (device_param->driver_version); hcfree (device_param->device_opencl_version); @@ -3810,8 +3790,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * device properties */ - const char *device_name_chksum = device_param->device_name_chksum; - const u32 device_processors = device_param->device_processors; + const u32 device_processors = device_param->device_processors; /** * create context for each device @@ -4253,6 +4232,27 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: build_opts '%s'", device_id + 1, build_opts); #endif + /** + * device_name_chksum + */ + + char *device_name_chksum = (char *) hcmalloc (HCBUFSIZ_TINY); + + #if defined (__x86_64__) + const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%d-%u-%u-%s-%s-%s-%d-%u-%u", 64, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime, user_options->opencl_vector_width, user_options->hash_mode); + #else + const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%d-%u-%u-%s-%s-%s-%d-%u-%u", 32, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime, user_options->opencl_vector_width, user_options->hash_mode); + #endif + + u32 device_name_digest[4] = { 0 }; + + for (size_t i = 0; i < dnclen; i += 64) + { + md5_64 ((u32 *) (device_name_chksum + i), device_name_digest); + } + + snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%08x", device_name_digest[0]); + /** * main kernel */ @@ -4733,6 +4733,8 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) hcfree (kernel_sources[0]); } + hcfree (device_name_chksum); + // return back to the folder we came from initially (workaround) if (chdir (folder_config->cwd) == -1)