1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-23 07:08:19 +00:00

Fix calculation of device_name_chksum; should be done for each iteration

This commit is contained in:
jsteube 2017-07-22 18:46:12 +02:00
parent c289fcb2b0
commit b847bbb274
2 changed files with 28 additions and 25 deletions

View File

@ -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;

View File

@ -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)