1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-22 22:58:30 +00:00

Move all bitmap related host code into bitmap.c

This commit is contained in:
jsteube 2016-09-22 16:23:36 +02:00
parent 095dfdc730
commit b6f966970b
9 changed files with 187 additions and 147 deletions

View File

@ -10,6 +10,7 @@
int sort_by_bitmap (const void *s1, const void *s2);
uint generate_bitmaps (const uint digests_cnt, const uint dgst_size, const uint dgst_shifts, char *digests_buf_ptr, const uint dgst_pos0, const uint dgst_pos1, const uint dgst_pos2, const uint dgst_pos3, const uint bitmap_mask, const uint bitmap_size, uint *bitmap_a, uint *bitmap_b, uint *bitmap_c, uint *bitmap_d, const u64 collisions_max);
void bitmap_ctx_init (bitmap_ctx_t *bitmap_ctx, const user_options_t *user_options, const hashconfig_t *hashconfig, const hashes_t *hashes);
void bitmap_ctx_destroy (bitmap_ctx_t *bitmap_ctx);
#endif // _BITMAP_H

View File

@ -91,7 +91,7 @@ void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx);
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const tuning_db_t *tuning_db, const user_options_t *user_options, const uint algorithm_pos);
void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx);
int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const session_ctx_t *session_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config);
int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const session_ctx_t *session_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const bitmap_ctx_t *bitmap_ctx);
int opencl_session_destroy (opencl_ctx_t *opencl_ctx);
#endif // _OPENCL_H

View File

@ -6,7 +6,7 @@
#ifndef _SESSION_H
#define _SESSION_H
void session_ctx_init (session_ctx_t *session_ctx, const u32 kernel_rules_cnt, kernel_rule_t *kernel_rules_buf, const u32 bitmap_size, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, u32 *bitmap_s1_a, u32 *bitmap_s1_b, u32 *bitmap_s1_c, u32 *bitmap_s1_d, u32 *bitmap_s2_a, u32 *bitmap_s2_b, u32 *bitmap_s2_c, u32 *bitmap_s2_d);
void session_ctx_init (session_ctx_t *session_ctx, const u32 kernel_rules_cnt, kernel_rule_t *kernel_rules_buf);
void session_ctx_destroy (session_ctx_t *session_ctx);

View File

@ -859,6 +859,12 @@ typedef struct
u32 kernel_rules_cnt;
kernel_rule_t *kernel_rules_buf;
} session_ctx_t;
typedef struct
{
u32 bitmap_bits;
u32 bitmap_nums;
u32 bitmap_size;
u32 bitmap_mask;
u32 bitmap_shift1;
@ -873,7 +879,7 @@ typedef struct
u32 *bitmap_s2_c;
u32 *bitmap_s2_d;
} session_ctx_t;
} bitmap_ctx_t;
typedef struct
{
@ -974,6 +980,7 @@ typedef struct
loopback_ctx_t *loopback_ctx;
debugfile_ctx_t *debugfile_ctx;
session_ctx_t *session_ctx;
bitmap_ctx_t *bitmap_ctx;
/**
* used for restore

View File

@ -5,6 +5,8 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "bitmap.h"
int sort_by_bitmap (const void *p1, const void *p2)
@ -15,7 +17,7 @@ int sort_by_bitmap (const void *p1, const void *p2)
return b1->collisions - b2->collisions;
}
uint generate_bitmaps (const uint digests_cnt, const uint dgst_size, const uint dgst_shifts, char *digests_buf_ptr, const uint dgst_pos0, const uint dgst_pos1, const uint dgst_pos2, const uint dgst_pos3, const uint bitmap_mask, const uint bitmap_size, uint *bitmap_a, uint *bitmap_b, uint *bitmap_c, uint *bitmap_d, const u64 collisions_max)
static u32 generate_bitmaps (const u32 digests_cnt, const u32 dgst_size, const u32 dgst_shifts, char *digests_buf_ptr, const u32 dgst_pos0, const u32 dgst_pos1, const u32 dgst_pos2, const u32 dgst_pos3, const u32 bitmap_mask, const u32 bitmap_size, u32 *bitmap_a, u32 *bitmap_b, u32 *bitmap_c, u32 *bitmap_d, const u64 collisions_max)
{
u64 collisions = 0;
@ -24,21 +26,21 @@ uint generate_bitmaps (const uint digests_cnt, const uint dgst_size, const uint
memset (bitmap_c, 0, bitmap_size);
memset (bitmap_d, 0, bitmap_size);
for (uint i = 0; i < digests_cnt; i++)
for (u32 i = 0; i < digests_cnt; i++)
{
uint *digest_ptr = (uint *) digests_buf_ptr;
u32 *digest_ptr = (u32 *) digests_buf_ptr;
digests_buf_ptr += dgst_size;
const uint val0 = 1u << (digest_ptr[dgst_pos0] & 0x1f);
const uint val1 = 1u << (digest_ptr[dgst_pos1] & 0x1f);
const uint val2 = 1u << (digest_ptr[dgst_pos2] & 0x1f);
const uint val3 = 1u << (digest_ptr[dgst_pos3] & 0x1f);
const u32 val0 = 1u << (digest_ptr[dgst_pos0] & 0x1f);
const u32 val1 = 1u << (digest_ptr[dgst_pos1] & 0x1f);
const u32 val2 = 1u << (digest_ptr[dgst_pos2] & 0x1f);
const u32 val3 = 1u << (digest_ptr[dgst_pos3] & 0x1f);
const uint idx0 = (digest_ptr[dgst_pos0] >> dgst_shifts) & bitmap_mask;
const uint idx1 = (digest_ptr[dgst_pos1] >> dgst_shifts) & bitmap_mask;
const uint idx2 = (digest_ptr[dgst_pos2] >> dgst_shifts) & bitmap_mask;
const uint idx3 = (digest_ptr[dgst_pos3] >> dgst_shifts) & bitmap_mask;
const u32 idx0 = (digest_ptr[dgst_pos0] >> dgst_shifts) & bitmap_mask;
const u32 idx1 = (digest_ptr[dgst_pos1] >> dgst_shifts) & bitmap_mask;
const u32 idx2 = (digest_ptr[dgst_pos2] >> dgst_shifts) & bitmap_mask;
const u32 idx3 = (digest_ptr[dgst_pos3] >> dgst_shifts) & bitmap_mask;
if (bitmap_a[idx0] & val0) collisions++;
if (bitmap_b[idx1] & val1) collisions++;
@ -55,3 +57,101 @@ uint generate_bitmaps (const uint digests_cnt, const uint dgst_size, const uint
return collisions;
}
void bitmap_ctx_init (bitmap_ctx_t *bitmap_ctx, const user_options_t *user_options, const hashconfig_t *hashconfig, const hashes_t *hashes)
{
/**
* generate bitmap tables
*/
const u32 bitmap_shift1 = 5;
const u32 bitmap_shift2 = 13;
const u32 bitmap_min = user_options->bitmap_min;
const u32 bitmap_max = user_options->bitmap_max;
u32 *bitmap_s1_a = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s1_b = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s1_c = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s1_d = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s2_a = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s2_b = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s2_c = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s2_d = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 bitmap_bits;
u32 bitmap_nums;
u32 bitmap_mask;
u32 bitmap_size;
for (bitmap_bits = bitmap_min; bitmap_bits < bitmap_max; bitmap_bits++)
{
if (user_options->quiet == false) log_info_nn ("Generating bitmap tables with %u bits...", bitmap_bits);
bitmap_nums = 1u << bitmap_bits;
bitmap_mask = bitmap_nums - 1;
bitmap_size = bitmap_nums * sizeof (u32);
if ((hashes->digests_cnt & bitmap_mask) == hashes->digests_cnt) break;
if (generate_bitmaps (hashes->digests_cnt, hashconfig->dgst_size, bitmap_shift1, (char *) hashes->digests_buf, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, bitmap_mask, bitmap_size, bitmap_s1_a, bitmap_s1_b, bitmap_s1_c, bitmap_s1_d, hashes->digests_cnt / 2) == 0x7fffffff) continue;
if (generate_bitmaps (hashes->digests_cnt, hashconfig->dgst_size, bitmap_shift2, (char *) hashes->digests_buf, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, bitmap_mask, bitmap_size, bitmap_s1_a, bitmap_s1_b, bitmap_s1_c, bitmap_s1_d, hashes->digests_cnt / 2) == 0x7fffffff) continue;
break;
}
bitmap_nums = 1u << bitmap_bits;
bitmap_mask = bitmap_nums - 1;
bitmap_size = bitmap_nums * sizeof (u32);
generate_bitmaps (hashes->digests_cnt, hashconfig->dgst_size, bitmap_shift1, (char *) hashes->digests_buf, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, bitmap_mask, bitmap_size, bitmap_s1_a, bitmap_s1_b, bitmap_s1_c, bitmap_s1_d, -1ul);
generate_bitmaps (hashes->digests_cnt, hashconfig->dgst_size, bitmap_shift2, (char *) hashes->digests_buf, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, bitmap_mask, bitmap_size, bitmap_s2_a, bitmap_s2_b, bitmap_s2_c, bitmap_s2_d, -1ul);
bitmap_ctx->bitmap_bits = bitmap_bits;
bitmap_ctx->bitmap_nums = bitmap_nums;
bitmap_ctx->bitmap_size = bitmap_size;
bitmap_ctx->bitmap_mask = bitmap_mask;
bitmap_ctx->bitmap_shift1 = bitmap_shift1;
bitmap_ctx->bitmap_shift2 = bitmap_shift2;
bitmap_ctx->bitmap_s1_a = bitmap_s1_a;
bitmap_ctx->bitmap_s1_b = bitmap_s1_b;
bitmap_ctx->bitmap_s1_c = bitmap_s1_c;
bitmap_ctx->bitmap_s1_d = bitmap_s1_d;
bitmap_ctx->bitmap_s2_a = bitmap_s2_a;
bitmap_ctx->bitmap_s2_b = bitmap_s2_b;
bitmap_ctx->bitmap_s2_c = bitmap_s2_c;
bitmap_ctx->bitmap_s2_d = bitmap_s2_d;
}
void bitmap_ctx_destroy (bitmap_ctx_t *bitmap_ctx)
{
bitmap_ctx->bitmap_size = 0;
bitmap_ctx->bitmap_mask = 0;
bitmap_ctx->bitmap_shift1 = 0;
bitmap_ctx->bitmap_shift2 = 0;
myfree (bitmap_ctx->bitmap_s1_a);
myfree (bitmap_ctx->bitmap_s1_b);
myfree (bitmap_ctx->bitmap_s1_c);
myfree (bitmap_ctx->bitmap_s1_d);
myfree (bitmap_ctx->bitmap_s2_a);
myfree (bitmap_ctx->bitmap_s2_b);
myfree (bitmap_ctx->bitmap_s2_c);
myfree (bitmap_ctx->bitmap_s2_d);
bitmap_ctx->bitmap_s1_a = NULL;
bitmap_ctx->bitmap_s1_b = NULL;
bitmap_ctx->bitmap_s1_c = NULL;
bitmap_ctx->bitmap_s1_d = NULL;
bitmap_ctx->bitmap_s2_a = NULL;
bitmap_ctx->bitmap_s2_b = NULL;
bitmap_ctx->bitmap_s2_c = NULL;
bitmap_ctx->bitmap_s2_d = NULL;
myfree (bitmap_ctx);
}

View File

@ -806,6 +806,16 @@ int main (int argc, char **argv)
}
}
/**
* bitmaps
*/
bitmap_ctx_t *bitmap_ctx = (bitmap_ctx_t *) mymalloc (sizeof (bitmap_ctx_t));
data.bitmap_ctx = bitmap_ctx;
bitmap_ctx_init (bitmap_ctx, user_options, hashconfig, hashes);
/**
* dictstat
*/
@ -879,56 +889,6 @@ int main (int argc, char **argv)
opencl_ctx->force_jit_compilation = 1500;
}
/**
* generate bitmap tables
*/
const uint bitmap_shift1 = 5;
const uint bitmap_shift2 = 13;
if (user_options->bitmap_max < user_options->bitmap_min) user_options->bitmap_max = user_options->bitmap_min;
uint *bitmap_s1_a = (uint *) mymalloc ((1u << user_options->bitmap_max) * sizeof (uint));
uint *bitmap_s1_b = (uint *) mymalloc ((1u << user_options->bitmap_max) * sizeof (uint));
uint *bitmap_s1_c = (uint *) mymalloc ((1u << user_options->bitmap_max) * sizeof (uint));
uint *bitmap_s1_d = (uint *) mymalloc ((1u << user_options->bitmap_max) * sizeof (uint));
uint *bitmap_s2_a = (uint *) mymalloc ((1u << user_options->bitmap_max) * sizeof (uint));
uint *bitmap_s2_b = (uint *) mymalloc ((1u << user_options->bitmap_max) * sizeof (uint));
uint *bitmap_s2_c = (uint *) mymalloc ((1u << user_options->bitmap_max) * sizeof (uint));
uint *bitmap_s2_d = (uint *) mymalloc ((1u << user_options->bitmap_max) * sizeof (uint));
uint bitmap_bits;
uint bitmap_nums;
uint bitmap_mask;
uint bitmap_size;
for (bitmap_bits = user_options->bitmap_min; bitmap_bits < user_options->bitmap_max; bitmap_bits++)
{
if (user_options->quiet == false) log_info_nn ("Generating bitmap tables with %u bits...", bitmap_bits);
bitmap_nums = 1u << bitmap_bits;
bitmap_mask = bitmap_nums - 1;
bitmap_size = bitmap_nums * sizeof (uint);
if ((hashes->digests_cnt & bitmap_mask) == hashes->digests_cnt) break;
if (generate_bitmaps (hashes->digests_cnt, hashconfig->dgst_size, bitmap_shift1, (char *) hashes->digests_buf, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, bitmap_mask, bitmap_size, bitmap_s1_a, bitmap_s1_b, bitmap_s1_c, bitmap_s1_d, hashes->digests_cnt / 2) == 0x7fffffff) continue;
if (generate_bitmaps (hashes->digests_cnt, hashconfig->dgst_size, bitmap_shift2, (char *) hashes->digests_buf, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, bitmap_mask, bitmap_size, bitmap_s1_a, bitmap_s1_b, bitmap_s1_c, bitmap_s1_d, hashes->digests_cnt / 2) == 0x7fffffff) continue;
break;
}
bitmap_nums = 1u << bitmap_bits;
bitmap_mask = bitmap_nums - 1;
bitmap_size = bitmap_nums * sizeof (uint);
generate_bitmaps (hashes->digests_cnt, hashconfig->dgst_size, bitmap_shift1, (char *) hashes->digests_buf, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, bitmap_mask, bitmap_size, bitmap_s1_a, bitmap_s1_b, bitmap_s1_c, bitmap_s1_d, -1ul);
generate_bitmaps (hashes->digests_cnt, hashconfig->dgst_size, bitmap_shift2, (char *) hashes->digests_buf, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, bitmap_mask, bitmap_size, bitmap_s2_a, bitmap_s2_b, bitmap_s2_c, bitmap_s2_d, -1ul);
/**
* load rules
*/
@ -1378,7 +1338,7 @@ int main (int argc, char **argv)
{
log_info ("Hashes: %u digests; %u unique digests, %u unique salts", hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt);
log_info ("Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_bits, bitmap_nums, bitmap_mask, bitmap_size, bitmap_shift1, bitmap_shift2);
log_info ("Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2);
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
@ -1670,9 +1630,9 @@ int main (int argc, char **argv)
data.session_ctx = session_ctx;
session_ctx_init (session_ctx, kernel_rules_cnt, kernel_rules_buf, bitmap_size, bitmap_mask, bitmap_shift1, bitmap_shift2, bitmap_s1_a, bitmap_s1_b, bitmap_s1_c, bitmap_s1_d, bitmap_s2_a, bitmap_s2_b, bitmap_s2_c, bitmap_s2_d);
session_ctx_init (session_ctx, kernel_rules_cnt, kernel_rules_buf);
opencl_session_begin (opencl_ctx, hashconfig, hashes, session_ctx, user_options, user_options_extra, folder_config);
opencl_session_begin (opencl_ctx, hashconfig, hashes, session_ctx, user_options, user_options_extra, folder_config, bitmap_ctx);
if (user_options->quiet == false) log_info_nn ("");
@ -3978,18 +3938,11 @@ int main (int argc, char **argv)
wl_data_destroy (wl_data);
bitmap_ctx_destroy (bitmap_ctx);
local_free (all_kernel_rules_cnt);
local_free (all_kernel_rules_buf);
local_free (bitmap_s1_a);
local_free (bitmap_s1_b);
local_free (bitmap_s1_c);
local_free (bitmap_s1_d);
local_free (bitmap_s2_a);
local_free (bitmap_s2_b);
local_free (bitmap_s2_c);
local_free (bitmap_s2_d);
local_free (od_clock_mem_status);
local_free (od_power_control_status);
local_free (nvml_power_limit);

View File

@ -2518,7 +2518,7 @@ void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx)
opencl_ctx->need_xnvctrl = 0;
}
int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const session_ctx_t *session_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config)
int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const session_ctx_t *session_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const bitmap_ctx_t *bitmap_ctx)
{
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
@ -2940,14 +2940,14 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
if (size_hooks > device_param->device_maxmem_alloc) memory_limit_hit = 1;
const u64 size_total
= session_ctx->bitmap_size
+ session_ctx->bitmap_size
+ session_ctx->bitmap_size
+ session_ctx->bitmap_size
+ session_ctx->bitmap_size
+ session_ctx->bitmap_size
+ session_ctx->bitmap_size
+ session_ctx->bitmap_size
= bitmap_ctx->bitmap_size
+ bitmap_ctx->bitmap_size
+ bitmap_ctx->bitmap_size
+ bitmap_ctx->bitmap_size
+ bitmap_ctx->bitmap_size
+ bitmap_ctx->bitmap_size
+ bitmap_ctx->bitmap_size
+ bitmap_ctx->bitmap_size
+ size_bfs
+ size_combs
+ size_digests
@ -3742,14 +3742,14 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_pws, NULL, &device_param->d_pws_amp_buf);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_WRITE, size_tmps, NULL, &device_param->d_tmps);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_WRITE, size_hooks, NULL, &device_param->d_hooks);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, session_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_a);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, session_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_b);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, session_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_c);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, session_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_d);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, session_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_a);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, session_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_b);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, session_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_c);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, session_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_d);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_a);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_b);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_c);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_d);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_a);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_b);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_c);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_d);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_WRITE, size_plains, NULL, &device_param->d_plain_bufs);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_digests, NULL, &device_param->d_digests_buf);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_WRITE, size_shown, NULL, &device_param->d_digests_shown);
@ -3767,14 +3767,14 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
return -1;
}
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s1_a, CL_TRUE, 0, session_ctx->bitmap_size, session_ctx->bitmap_s1_a, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s1_b, CL_TRUE, 0, session_ctx->bitmap_size, session_ctx->bitmap_s1_b, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s1_c, CL_TRUE, 0, session_ctx->bitmap_size, session_ctx->bitmap_s1_c, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s1_d, CL_TRUE, 0, session_ctx->bitmap_size, session_ctx->bitmap_s1_d, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s2_a, CL_TRUE, 0, session_ctx->bitmap_size, session_ctx->bitmap_s2_a, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s2_b, CL_TRUE, 0, session_ctx->bitmap_size, session_ctx->bitmap_s2_b, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s2_c, CL_TRUE, 0, session_ctx->bitmap_size, session_ctx->bitmap_s2_c, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s2_d, CL_TRUE, 0, session_ctx->bitmap_size, session_ctx->bitmap_s2_d, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s1_a, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_a, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s1_b, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_b, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s1_c, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_c, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s1_d, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_d, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s2_a, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_a, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s2_b, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_b, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s2_c, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_c, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s2_d, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_d, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_digests_buf, CL_TRUE, 0, size_digests, hashes->digests_buf, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_digests_shown, CL_TRUE, 0, size_shown, hashes->digests_shown, 0, NULL, NULL);
CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_salt_bufs, CL_TRUE, 0, size_salts, hashes->salts_buf, 0, NULL, NULL);
@ -3882,9 +3882,9 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
* kernel args
*/
device_param->kernel_params_buf32[24] = session_ctx->bitmap_mask;
device_param->kernel_params_buf32[25] = session_ctx->bitmap_shift1;
device_param->kernel_params_buf32[26] = session_ctx->bitmap_shift2;
device_param->kernel_params_buf32[24] = bitmap_ctx->bitmap_mask;
device_param->kernel_params_buf32[25] = bitmap_ctx->bitmap_shift1;
device_param->kernel_params_buf32[26] = bitmap_ctx->bitmap_shift2;
device_param->kernel_params_buf32[27] = 0; // salt_pos
device_param->kernel_params_buf32[28] = 0; // loop_pos
device_param->kernel_params_buf32[29] = 0; // loop_cnt

View File

@ -7,42 +7,14 @@
#include "types.h"
#include "session.h"
void session_ctx_init (session_ctx_t *session_ctx, const u32 kernel_rules_cnt, kernel_rule_t *kernel_rules_buf, const u32 bitmap_size, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, u32 *bitmap_s1_a, u32 *bitmap_s1_b, u32 *bitmap_s1_c, u32 *bitmap_s1_d, u32 *bitmap_s2_a, u32 *bitmap_s2_b, u32 *bitmap_s2_c, u32 *bitmap_s2_d)
void session_ctx_init (session_ctx_t *session_ctx, const u32 kernel_rules_cnt, kernel_rule_t *kernel_rules_buf)
{
session_ctx->kernel_rules_cnt = kernel_rules_cnt;
session_ctx->kernel_rules_buf = kernel_rules_buf;
session_ctx->bitmap_size = bitmap_size;
session_ctx->bitmap_mask = bitmap_mask;
session_ctx->bitmap_shift1 = bitmap_shift1;
session_ctx->bitmap_shift2 = bitmap_shift2;
session_ctx->bitmap_s1_a = bitmap_s1_a;
session_ctx->bitmap_s1_b = bitmap_s1_b;
session_ctx->bitmap_s1_c = bitmap_s1_c;
session_ctx->bitmap_s1_d = bitmap_s1_d;
session_ctx->bitmap_s2_a = bitmap_s2_a;
session_ctx->bitmap_s2_b = bitmap_s2_b;
session_ctx->bitmap_s2_c = bitmap_s2_c;
session_ctx->bitmap_s2_d = bitmap_s2_d;
}
void session_ctx_destroy (session_ctx_t *session_ctx)
{
session_ctx->kernel_rules_buf = NULL;
session_ctx->kernel_rules_cnt = 0;
session_ctx->bitmap_size = 0;
session_ctx->bitmap_mask = 0;
session_ctx->bitmap_shift1 = 0;
session_ctx->bitmap_shift2 = 0;
session_ctx->bitmap_s1_a = NULL;
session_ctx->bitmap_s1_b = NULL;
session_ctx->bitmap_s1_c = NULL;
session_ctx->bitmap_s1_d = NULL;
session_ctx->bitmap_s2_a = NULL;
session_ctx->bitmap_s2_b = NULL;
session_ctx->bitmap_s2_c = NULL;
session_ctx->bitmap_s2_d = NULL;
}

View File

@ -494,6 +494,13 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
}
}
if (user_options->bitmap_min > user_options->bitmap_max)
{
log_error ("ERROR: Invalid bitmap-min specified");
return -1;
}
if (user_options->rp_gen_func_min > user_options->rp_gen_func_max)
{
log_error ("ERROR: Invalid rp-gen-func-min specified");