1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-22 06:38:11 +00:00

Prepare for allow other OpenCL platforms thans AMD and NVidia

This commit is contained in:
jsteube 2016-01-04 13:17:20 +01:00
parent 6f1100f643
commit 3b589e3aac
5 changed files with 129 additions and 8 deletions

View File

@ -18,7 +18,6 @@ static inline u64 swap64 (const u64 v)
{
return (as_ulong (as_uchar8 (v).s76543210));
}
#endif
#ifdef IS_NV
@ -50,7 +49,18 @@ static inline u64 swap64 (const u64 v)
return r;
}
#endif
#ifdef IS_UNKNOWN
static inline u32 swap32 (const u32 v)
{
return (as_uint (as_uchar4 (v).s3210));
}
static inline u64 swap64 (const u64 v)
{
return (as_ulong (as_uchar8 (v).s76543210));
}
#endif
#ifdef IS_AMD
@ -349,6 +359,30 @@ static inline u64 rotl64 (const u64 a, const u64 n)
#endif
#endif
#ifdef IS_UNKNOWN
static inline u32 rotr32 (const u32 a, const u32 n)
{
return rotate (a, 32 - n);
}
static inline u32 rotl32 (const u32 a, const u32 n)
{
return rotate (a, n);
}
static inline u64 rotr64 (const u64 a, const u32 n)
{
return rotate (a, (u64) 64 - n);
}
static inline u64 rotl64 (const u64 a, const u32 n)
{
return rotr64 (a, 64 - n);
}
#endif
typedef struct
{
#if defined _DES_

View File

@ -33,6 +33,16 @@
#define MD4_Go(x,y,z) (bitselect ((x), (y), ((x) ^ (z))))
#endif
#ifdef IS_UNKNOWN
#define MD4_F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
#define MD4_G(x,y,z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
#define MD4_H(x,y,z) ((x) ^ (y) ^ (z))
#define MD4_H1(x,y,z) ((tmp2 = (x) ^ (y)) ^ (z))
#define MD4_H2(x,y,z) ((x) ^ tmp2)
#define MD4_Fo(x,y,z) (MD4_F((x), (y), (z)))
#define MD4_Go(x,y,z) (MD4_G((x), (y), (z)))
#endif
#define MD4_STEP(f,a,b,c,d,x,K,s) \
{ \
a += K; \
@ -83,6 +93,17 @@
#define MD5_Go(x,y,z) (bitselect ((y), (x), (z)))
#endif
#ifdef IS_UNKNOWN
#define MD5_F(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#define MD5_G(x,y,z) ((y) ^ ((z) & ((x) ^ (y))))
#define MD5_H(x,y,z) ((x) ^ (y) ^ (z))
#define MD5_H1(x,y,z) ((tmp2 = (x) ^ (y)) ^ (z))
#define MD5_H2(x,y,z) ((x) ^ tmp2)
#define MD5_I(x,y,z) ((y) ^ ((x) | ~(z)))
#define MD5_Fo(x,y,z) (MD5_F((x), (y), (z)))
#define MD5_Go(x,y,z) (MD5_G((x), (y), (z)))
#endif
#define MD5_STEP(f,a,b,c,d,x,K,s) \
{ \
a += K; \
@ -125,6 +146,14 @@
#define SHA1_F2o(x,y,z) (bitselect ((x), (y), ((x) ^ (z))))
#endif
#ifdef IS_UNKNOWN
#define SHA1_F0(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#define SHA1_F1(x,y,z) ((x) ^ (y) ^ (z))
#define SHA1_F2(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
#define SHA1_F0o(x,y,z) (SHA1_F0 ((x), (y), (z)))
#define SHA1_F2o(x,y,z) (SHA1_F2 ((x), (y), (z)))
#endif
#define SHA1_STEP(f,a,b,c,d,e,x) \
{ \
e += K; \
@ -192,6 +221,13 @@
#define SHA256_F1o(x,y,z) (bitselect ((z), (y), (x)))
#endif
#ifdef IS_UNKNOWN
#define SHA256_F0(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
#define SHA256_F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#define SHA256_F0o(x,y,z) (SHA256_F0 ((x), (y), (z)))
#define SHA256_F1o(x,y,z) (SHA256_F1 ((x), (y), (z)))
#endif
#define SHA256_STEP(F0,F1,a,b,c,d,e,f,g,h,x,K) \
{ \
h += K; \
@ -229,6 +265,11 @@
#define SHA384_F1o(x,y,z) (bitselect ((x), (y), ((x) ^ (z))))
#endif
#ifdef IS_UNKNOWN
#define SHA384_F0o(x,y,z) (SHA384_F0 ((x), (y), (z)))
#define SHA384_F1o(x,y,z) (SHA384_F1 ((x), (y), (z)))
#endif
#define SHA384_STEP(F0,F1,a,b,c,d,e,f,g,h,x,K) \
{ \
u64 temp0; \
@ -268,6 +309,11 @@
#define SHA512_F1o(x,y,z) (bitselect ((x), (y), ((x) ^ (z))))
#endif
#ifdef IS_UNKNOWN
#define SHA512_F0o(x,y,z) (SHA512_F0 ((x), (y), (z)))
#define SHA512_F1o(x,y,z) (SHA512_F1 ((x), (y), (z)))
#endif
#define SHA512_STEP(F0,F1,a,b,c,d,e,f,g,h,x,K) \
{ \
u64 temp0; \
@ -320,6 +366,16 @@
#define RIPEMD160_Io(x,y,z) (bitselect ((y), (x), (z)))
#endif
#ifdef IS_UNKNOWN
#define RIPEMD160_F(x,y,z) ((x) ^ (y) ^ (z))
#define RIPEMD160_G(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) /* x ? y : z */
#define RIPEMD160_H(x,y,z) (((x) | ~(y)) ^ (z))
#define RIPEMD160_I(x,y,z) ((y) ^ ((z) & ((x) ^ (y)))) /* z ? x : y */
#define RIPEMD160_J(x,y,z) ((x) ^ ((y) | ~(z)))
#define RIPEMD160_Go(x,y,z) (RIPEMD160_G ((x), (y), (z)))
#define RIPEMD160_Io(x,y,z) (RIPEMD160_I ((x), (y), (z)))
#endif
#define RIPEMD160_STEP(f,a,b,c,d,e,x,K,s) \
{ \
a += K; \

View File

@ -17,12 +17,20 @@
#define IS_NV
#endif
#if VENDOR_ID == 9998 // temporary for dev
#define IS_UNKNOWN
#endif
#if VENDOR_ID == 9999
#define IS_UNKNOWN
#endif
/**
* AMD specific
*/
#ifdef IS_AMD
#pragma OPENCL EXTENSION cl_amd_media_ops : enable
#pragma OPENCL EXTENSION cl_amd_media_ops : enable
#pragma OPENCL EXTENSION cl_amd_media_ops2 : enable
#endif

View File

@ -89,10 +89,12 @@
#define CL_VENDOR_AMD "Advanced Micro Devices, Inc."
#define CL_VENDOR_SDS "Shiloh Distributed Solutions"
#define CL_VENDOR_APPLE "Apple"
#define CL_VENDOR_POCL "The pocl project"
#define VENDOR_ID_AMD 4098
#define VENDOR_ID_NV 4318
#define VENDOR_ID_UNKNOWN 0
#define VENDOR_ID_POCL 9998
#define VENDOR_ID_UNKNOWN 9999
#define BLOCK_SIZE 64

View File

@ -12277,9 +12277,11 @@ int main (int argc, char **argv)
if (gpu_platform == NULL)
{
log_error ("ERROR: Too many OpenCL compatible platforms found");
log_error (" Please select a single platform using the --gpu-platform option");
log_error ("");
log_error ("Available OpenCL platforms:");
log_info ("Please select a single platform using the --gpu-platform option");
log_info ("");
log_info ("Available OpenCL platforms:");
log_info ("");
for (uint i = 0; i < CL_platforms_cnt; i++)
{
@ -12289,9 +12291,11 @@ int main (int argc, char **argv)
hc_clGetPlatformInfo (CL_platforms[i], CL_PLATFORM_VENDOR, sizeof (CL_platform_vendor), CL_platform_vendor, NULL);
printf ("* %d = %s\n", i + 1, CL_platform_vendor);
log_info ("* %d = %s", i + 1, CL_platform_vendor);
}
log_info ("");
return (-1);
}
else
@ -12319,24 +12323,41 @@ int main (int argc, char **argv)
hc_clGetPlatformInfo (CL_platform, CL_PLATFORM_VENDOR, sizeof (CL_platform_vendor), CL_platform_vendor, NULL);
cl_device_type device_type;
uint vendor_id;
if (strcmp (CL_platform_vendor, CL_VENDOR_AMD) == 0)
{
vendor_id = VENDOR_ID_AMD;
device_type = CL_DEVICE_TYPE_GPU;
}
else if (strcmp (CL_platform_vendor, CL_VENDOR_NV) == 0)
{
vendor_id = VENDOR_ID_NV;
device_type = CL_DEVICE_TYPE_GPU;
// make sure that we do not directly control the fan for NVidia
gpu_temp_retain = 0;
data.gpu_temp_retain = gpu_temp_retain;
}
else if (strcmp (CL_platform_vendor, CL_VENDOR_POCL) == 0)
{
vendor_id = VENDOR_ID_POCL;
device_type = CL_DEVICE_TYPE_CPU;
gpu_temp_disable = 1;
}
else
{
vendor_id = VENDOR_ID_UNKNOWN;
device_type = CL_DEVICE_TYPE_DEFAULT;
}
if (vendor_id == VENDOR_ID_UNKNOWN)
@ -12375,7 +12396,7 @@ int main (int argc, char **argv)
uint devices_all_cnt = 0;
hc_clGetDeviceIDs (CL_platform, CL_DEVICE_TYPE_GPU, DEVICES_MAX, devices_all, (uint *) &devices_all_cnt);
hc_clGetDeviceIDs (CL_platform, device_type, DEVICES_MAX, devices_all, (uint *) &devices_all_cnt);
int hm_adapters_all = devices_all_cnt;