mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-30 11:58:15 +00:00
224 lines
5.3 KiB
C
224 lines
5.3 KiB
C
/**
|
|
* Authors.....: Jens Steube <jens.steube@gmail.com>
|
|
* Gabriele Gristina <matrix@hashcat.net>
|
|
*
|
|
* License.....: MIT
|
|
*/
|
|
|
|
#ifndef _OPENCL_H
|
|
#define _OPENCL_H
|
|
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
|
|
static const char CL_VENDOR_AMD[] = "Advanced Micro Devices, Inc.";
|
|
static const char CL_VENDOR_AMD_USE_INTEL[] = "GenuineIntel";
|
|
static const char CL_VENDOR_APPLE[] = "Apple";
|
|
static const char CL_VENDOR_INTEL_BEIGNET[] = "Intel";
|
|
static const char CL_VENDOR_INTEL_SDK[] = "Intel(R) Corporation";
|
|
static const char CL_VENDOR_MESA[] = "Mesa";
|
|
static const char CL_VENDOR_NV[] = "NVIDIA Corporation";
|
|
static const char CL_VENDOR_POCL[] = "The pocl project";
|
|
|
|
typedef enum vendor_id
|
|
{
|
|
VENDOR_ID_AMD = (1 << 0),
|
|
VENDOR_ID_APPLE = (1 << 1),
|
|
VENDOR_ID_INTEL_BEIGNET = (1 << 2),
|
|
VENDOR_ID_INTEL_SDK = (1 << 3),
|
|
VENDOR_ID_MESA = (1 << 4),
|
|
VENDOR_ID_NV = (1 << 5),
|
|
VENDOR_ID_POCL = (1 << 6),
|
|
VENDOR_ID_AMD_USE_INTEL = (1 << 7),
|
|
VENDOR_ID_GENERIC = (1 << 31)
|
|
|
|
} vendor_id_t;
|
|
|
|
typedef struct __hc_device_param hc_device_param_t;
|
|
|
|
struct __hc_device_param
|
|
{
|
|
cl_device_id device;
|
|
cl_device_type device_type;
|
|
|
|
uint device_id;
|
|
uint platform_devices_id; // for mapping with hms devices
|
|
|
|
bool skipped;
|
|
|
|
uint sm_major;
|
|
uint sm_minor;
|
|
uint kernel_exec_timeout;
|
|
|
|
uint device_processors;
|
|
u64 device_maxmem_alloc;
|
|
u64 device_global_mem;
|
|
u32 device_maxclock_frequency;
|
|
size_t device_maxworkgroup_size;
|
|
|
|
uint vector_width;
|
|
|
|
uint kernel_threads;
|
|
uint kernel_loops;
|
|
uint kernel_accel;
|
|
uint kernel_loops_min;
|
|
uint kernel_loops_max;
|
|
uint kernel_accel_min;
|
|
uint kernel_accel_max;
|
|
uint kernel_power;
|
|
uint hardware_power;
|
|
|
|
size_t size_pws;
|
|
size_t size_tmps;
|
|
size_t size_hooks;
|
|
size_t size_bfs;
|
|
size_t size_combs;
|
|
size_t size_rules;
|
|
size_t size_rules_c;
|
|
size_t size_root_css;
|
|
size_t size_markov_css;
|
|
size_t size_digests;
|
|
size_t size_salts;
|
|
size_t size_shown;
|
|
size_t size_results;
|
|
size_t size_plains;
|
|
|
|
FILE *combs_fp;
|
|
comb_t *combs_buf;
|
|
|
|
void *hooks_buf;
|
|
|
|
pw_t *pws_buf;
|
|
uint pws_cnt;
|
|
|
|
u64 words_off;
|
|
u64 words_done;
|
|
|
|
uint outerloop_pos;
|
|
uint outerloop_left;
|
|
|
|
uint innerloop_pos;
|
|
uint innerloop_left;
|
|
|
|
uint exec_pos;
|
|
double exec_ms[EXEC_CACHE];
|
|
|
|
// workaround cpu spinning
|
|
|
|
double exec_us_prev1[EXPECTED_ITERATIONS];
|
|
double exec_us_prev2[EXPECTED_ITERATIONS];
|
|
double exec_us_prev3[EXPECTED_ITERATIONS];
|
|
|
|
// this is "current" speed
|
|
|
|
uint speed_pos;
|
|
u64 speed_cnt[SPEED_CACHE];
|
|
double speed_ms[SPEED_CACHE];
|
|
|
|
hc_timer_t timer_speed;
|
|
|
|
// device specific attributes starting
|
|
|
|
char *device_name;
|
|
char *device_vendor;
|
|
char *device_name_chksum;
|
|
char *device_version;
|
|
char *driver_version;
|
|
|
|
bool opencl_v12;
|
|
|
|
double nvidia_spin_damp;
|
|
|
|
cl_platform_id platform;
|
|
|
|
cl_uint device_vendor_id;
|
|
cl_uint platform_vendor_id;
|
|
|
|
cl_kernel kernel1;
|
|
cl_kernel kernel12;
|
|
cl_kernel kernel2;
|
|
cl_kernel kernel23;
|
|
cl_kernel kernel3;
|
|
cl_kernel kernel_mp;
|
|
cl_kernel kernel_mp_l;
|
|
cl_kernel kernel_mp_r;
|
|
cl_kernel kernel_amp;
|
|
cl_kernel kernel_tm;
|
|
cl_kernel kernel_weak;
|
|
cl_kernel kernel_memset;
|
|
|
|
cl_context context;
|
|
|
|
cl_program program;
|
|
cl_program program_mp;
|
|
cl_program program_amp;
|
|
|
|
cl_command_queue command_queue;
|
|
|
|
cl_mem d_pws_buf;
|
|
cl_mem d_pws_amp_buf;
|
|
cl_mem d_words_buf_l;
|
|
cl_mem d_words_buf_r;
|
|
cl_mem d_rules;
|
|
cl_mem d_rules_c;
|
|
cl_mem d_combs;
|
|
cl_mem d_combs_c;
|
|
cl_mem d_bfs;
|
|
cl_mem d_bfs_c;
|
|
cl_mem d_tm_c;
|
|
cl_mem d_bitmap_s1_a;
|
|
cl_mem d_bitmap_s1_b;
|
|
cl_mem d_bitmap_s1_c;
|
|
cl_mem d_bitmap_s1_d;
|
|
cl_mem d_bitmap_s2_a;
|
|
cl_mem d_bitmap_s2_b;
|
|
cl_mem d_bitmap_s2_c;
|
|
cl_mem d_bitmap_s2_d;
|
|
cl_mem d_plain_bufs;
|
|
cl_mem d_digests_buf;
|
|
cl_mem d_digests_shown;
|
|
cl_mem d_salt_bufs;
|
|
cl_mem d_esalt_bufs;
|
|
cl_mem d_bcrypt_bufs;
|
|
cl_mem d_tmps;
|
|
cl_mem d_hooks;
|
|
cl_mem d_result;
|
|
cl_mem d_scryptV0_buf;
|
|
cl_mem d_scryptV1_buf;
|
|
cl_mem d_scryptV2_buf;
|
|
cl_mem d_scryptV3_buf;
|
|
cl_mem d_root_css_buf;
|
|
cl_mem d_markov_css_buf;
|
|
|
|
void *kernel_params[PARAMCNT];
|
|
void *kernel_params_mp[PARAMCNT];
|
|
void *kernel_params_mp_r[PARAMCNT];
|
|
void *kernel_params_mp_l[PARAMCNT];
|
|
void *kernel_params_amp[PARAMCNT];
|
|
void *kernel_params_tm[PARAMCNT];
|
|
void *kernel_params_memset[PARAMCNT];
|
|
|
|
u32 kernel_params_buf32[PARAMCNT];
|
|
|
|
u32 kernel_params_mp_buf32[PARAMCNT];
|
|
u64 kernel_params_mp_buf64[PARAMCNT];
|
|
|
|
u32 kernel_params_mp_r_buf32[PARAMCNT];
|
|
u64 kernel_params_mp_r_buf64[PARAMCNT];
|
|
|
|
u32 kernel_params_mp_l_buf32[PARAMCNT];
|
|
u64 kernel_params_mp_l_buf64[PARAMCNT];
|
|
|
|
u32 kernel_params_amp_buf32[PARAMCNT];
|
|
u32 kernel_params_memset_buf32[PARAMCNT];
|
|
};
|
|
|
|
#endif // _OPENCL_H
|
|
|
|
uint setup_opencl_platforms_filter (char *opencl_platforms);
|
|
u32 setup_devices_filter (char *opencl_devices);
|
|
cl_device_type setup_device_types_filter (char *opencl_device_types);
|
|
|
|
void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengths, const u8 **kernel_sources);
|
|
void writeProgramBin (char *dst, u8 *binary, size_t binary_size);
|