1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-26 00:18:36 +00:00

Use a different cache hash for amp and mp kernel

This commit is contained in:
jsteube 2017-07-23 13:55:25 +02:00
parent 4c71bc984e
commit f6f22f6616

View File

@ -402,15 +402,15 @@ void generate_source_kernel_mp_filename (const u32 opti_type, const u64 opts_typ
} }
} }
void generate_cached_kernel_mp_filename (const u32 opti_type, const u64 opts_type, char *profile_dir, const char *device_name_chksum, char *cached_file) void generate_cached_kernel_mp_filename (const u32 opti_type, const u64 opts_type, char *profile_dir, const char *device_name_chksum_amp_mp, char *cached_file)
{ {
if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE)) if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
{ {
snprintf (cached_file, 255, "%s/kernels/markov_be.%s.kernel", profile_dir, device_name_chksum); snprintf (cached_file, 255, "%s/kernels/markov_be.%s.kernel", profile_dir, device_name_chksum_amp_mp);
} }
else else
{ {
snprintf (cached_file, 255, "%s/kernels/markov_le.%s.kernel", profile_dir, device_name_chksum); snprintf (cached_file, 255, "%s/kernels/markov_le.%s.kernel", profile_dir, device_name_chksum_amp_mp);
} }
} }
@ -419,9 +419,9 @@ void generate_source_kernel_amp_filename (const u32 attack_kern, char *shared_di
snprintf (source_file, 255, "%s/OpenCL/amp_a%u.cl", shared_dir, attack_kern); snprintf (source_file, 255, "%s/OpenCL/amp_a%u.cl", shared_dir, attack_kern);
} }
void generate_cached_kernel_amp_filename (const u32 attack_kern, char *profile_dir, const char *device_name_chksum, char *cached_file) void generate_cached_kernel_amp_filename (const u32 attack_kern, char *profile_dir, const char *device_name_chksum_amp_mp, char *cached_file)
{ {
snprintf (cached_file, 255, "%s/kernels/amp_a%u.%s.kernel", profile_dir, attack_kern, device_name_chksum); snprintf (cached_file, 255, "%s/kernels/amp_a%u.%s.kernel", profile_dir, attack_kern, device_name_chksum_amp_mp);
} }
int ocl_init (hashcat_ctx_t *hashcat_ctx) int ocl_init (hashcat_ctx_t *hashcat_ctx)
@ -4237,11 +4237,14 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
*/ */
char *device_name_chksum = (char *) hcmalloc (HCBUFSIZ_TINY); char *device_name_chksum = (char *) hcmalloc (HCBUFSIZ_TINY);
char *device_name_chksum_amp_mp = (char *) hcmalloc (HCBUFSIZ_TINY);
#if defined (__x86_64__) #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); 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);
const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY - 1, "%d-%u-%s-%s-%s-%d", 64, device_param->platform_vendor_id, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime);
#else #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); 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);
const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY - 1, "%d-%u-%s-%s-%s-%d", 32, device_param->platform_vendor_id, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime);
#endif #endif
u32 device_name_digest[4] = { 0 }; u32 device_name_digest[4] = { 0 };
@ -4253,6 +4256,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%08x", device_name_digest[0]); snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%08x", device_name_digest[0]);
u32 device_name_digest_amp_mp[4] = { 0 };
for (size_t i = 0; i < dnclen_amp_mp; i += 64)
{
md5_64 ((u32 *) (device_name_chksum_amp_mp + i), device_name_digest_amp_mp);
}
snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY - 1, "%08x", device_name_digest_amp_mp[0]);
/** /**
* main kernel * main kernel
*/ */
@ -4482,7 +4494,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
char cached_file[256] = { 0 }; char cached_file[256] = { 0 };
generate_cached_kernel_mp_filename (hashconfig->opti_type, hashconfig->opts_type, folder_config->profile_dir, device_name_chksum, cached_file); generate_cached_kernel_mp_filename (hashconfig->opti_type, hashconfig->opts_type, folder_config->profile_dir, device_name_chksum_amp_mp, cached_file);
bool cached = true; bool cached = true;
@ -4623,7 +4635,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
char cached_file[256] = { 0 }; char cached_file[256] = { 0 };
generate_cached_kernel_amp_filename (user_options_extra->attack_kern, folder_config->profile_dir, device_name_chksum, cached_file); generate_cached_kernel_amp_filename (user_options_extra->attack_kern, folder_config->profile_dir, device_name_chksum_amp_mp, cached_file);
bool cached = true; bool cached = true;
@ -4734,6 +4746,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
} }
hcfree (device_name_chksum); hcfree (device_name_chksum);
hcfree (device_name_chksum_amp_mp);
// return back to the folder we came from initially (workaround) // return back to the folder we came from initially (workaround)