X-Git-Url: https://www.flypig.org.uk/git/?a=blobdiff_plain;f=OpenCL%2Fm10700.cl;h=b6ba96571e45d7fe2092654f3735594cd02a4592;hb=161a6eb4bc643d8e636e96eda613f5137d30da59;hp=c00d2024f5e76fb834589c3b8978e6e171aa8637;hpb=e4465d7dcb88426532f6b0488cf9bc1cd3b06cc6;p=hashcat.git diff --git a/OpenCL/m10700.cl b/OpenCL/m10700.cl index c00d202..b6ba965 100644 --- a/OpenCL/m10700.cl +++ b/OpenCL/m10700.cl @@ -1,24 +1,20 @@ /** - * Author......: Jens Steube + * Authors.....: Jens Steube + * Gabriele Gristina + * * License.....: MIT */ #define _PDF17L8_ -#include "include/constants.h" -#include "include/kernel_vendor.h" +#include "inc_vendor.cl" +#include "inc_hash_constants.h" +#include "inc_hash_functions.cl" +#include "inc_types.cl" +#include "inc_common.cl" -#define DGST_R0 0 -#define DGST_R1 1 -#define DGST_R2 2 -#define DGST_R3 3 - -#include "include/kernel_functions.c" -#include "types_ocl.c" -#include "common.c" - -#define COMPARE_S "check_single_comp4.c" -#define COMPARE_M "check_multi_comp4.c" +#define COMPARE_S "inc_comp_single.cl" +#define COMPARE_M "inc_comp_multi.cl" typedef struct { @@ -60,7 +56,7 @@ __constant u32 k_sha256[64] = SHA256C3c, SHA256C3d, SHA256C3e, SHA256C3f, }; -static void sha256_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[8]) +void sha256_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[8]) { u32 a = digest[0]; u32 b = digest[1]; @@ -130,7 +126,9 @@ static void sha256_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], ROUND256_STEP (0); + #ifdef _unroll #pragma unroll + #endif for (int i = 16; i < 64; i += 16) { ROUND256_EXPAND (); ROUND256_STEP (i); @@ -170,7 +168,7 @@ __constant u64 k_sha384[80] = SHA384C4c, SHA384C4d, SHA384C4e, SHA384C4f, }; -static void sha384_transform (const u64 w0[4], const u64 w1[4], const u64 w2[4], const u64 w3[4], u64 digest[8]) +void sha384_transform (const u64 w0[4], const u64 w1[4], const u64 w2[4], const u64 w3[4], u64 digest[8]) { u64 a = digest[0]; u64 b = digest[1]; @@ -240,7 +238,9 @@ static void sha384_transform (const u64 w0[4], const u64 w1[4], const u64 w2[4], ROUND384_STEP (0); + #ifdef _unroll #pragma unroll + #endif for (int i = 16; i < 80; i += 16) { ROUND384_EXPAND (); ROUND384_STEP (i); @@ -280,7 +280,7 @@ __constant u64 k_sha512[80] = SHA384C4c, SHA384C4d, SHA384C4e, SHA384C4f, }; -static void sha512_transform (const u64 w0[4], const u64 w1[4], const u64 w2[4], const u64 w3[4], u64 digest[8]) +void sha512_transform (const u64 w0[4], const u64 w1[4], const u64 w2[4], const u64 w3[4], u64 digest[8]) { u64 a = digest[0]; u64 b = digest[1]; @@ -350,7 +350,9 @@ static void sha512_transform (const u64 w0[4], const u64 w1[4], const u64 w2[4], ROUND512_STEP (0); + #ifdef _unroll #pragma unroll + #endif for (int i = 16; i < 80; i += 16) { ROUND512_EXPAND (); ROUND512_STEP (i); @@ -713,7 +715,7 @@ __constant u32 rcon[] = 0x1b000000, 0x36000000, }; -static void AES128_ExpandKey (u32 *userkey, u32 *rek, __local u32 s_te0[256], __local u32 s_te1[256], __local u32 s_te2[256], __local u32 s_te3[256], __local u32 s_te4[256]) +void AES128_ExpandKey (u32 *userkey, u32 *rek, __local u32 *s_te0, __local u32 *s_te1, __local u32 *s_te2, __local u32 *s_te3, __local u32 *s_te4) { rek[0] = swap32 (userkey[0]); rek[1] = swap32 (userkey[1]); @@ -739,7 +741,7 @@ static void AES128_ExpandKey (u32 *userkey, u32 *rek, __local u32 s_te0[256], __ } } -static void AES128_encrypt (const u32 *in, u32 *out, const u32 *rek, __local u32 s_te0[256], __local u32 s_te1[256], __local u32 s_te2[256], __local u32 s_te3[256], __local u32 s_te4[256]) +void AES128_encrypt (const u32 *in, u32 *out, const u32 *rek, __local u32 *s_te0, __local u32 *s_te1, __local u32 *s_te2, __local u32 *s_te3, __local u32 *s_te4) { u32 in_swap[4]; @@ -825,7 +827,7 @@ static void AES128_encrypt (const u32 *in, u32 *out, const u32 *rek, __local u32 out[3] = swap32 (out[3]); } -static void memcat8 (u32 block0[4], u32 block1[4], u32 block2[4], u32 block3[4], const u32 block_len, const u32 append[2]) +void memcat8 (u32 block0[4], u32 block1[4], u32 block2[4], u32 block3[4], const u32 block_len, const u32 append[2]) { switch (block_len) { @@ -1168,7 +1170,7 @@ static void memcat8 (u32 block0[4], u32 block1[4], u32 block2[4], u32 block3[4], #define WORDSZ384 128 #define WORDSZ512 128 -#define PWMAXSZ 32 // oclHashcat password length limit +#define PWMAXSZ 32 // hashcat password length limit #define BLMAXSZ BLSZ512 #define WORDMAXSZ WORDSZ512 @@ -1177,7 +1179,7 @@ static void memcat8 (u32 block0[4], u32 block1[4], u32 block2[4], u32 block3[4], #define WORDMAXSZ4 (WORDMAXSZ / 4) #define AESSZ4 (AESSZ / 4) -static void make_sc (u32 *sc, const u32 *pw, const u32 pw_len, const u32 *bl, const u32 bl_len) +void make_sc (u32 *sc, const u32 *pw, const u32 pw_len, const u32 *bl, const u32 bl_len) { const u32 bd = bl_len / 4; @@ -1198,7 +1200,7 @@ static void make_sc (u32 *sc, const u32 *pw, const u32 pw_len, const u32 *bl, co u32 i; - #ifdef IS_AMD + #if defined IS_AMD || defined IS_GENERIC for (i = 0; i < pd; i++) sc[idx++] = pw[i]; sc[idx++] = pw[i] | amd_bytealign (bl[0], 0, pm4); @@ -1222,14 +1224,14 @@ static void make_sc (u32 *sc, const u32 *pw, const u32 pw_len, const u32 *bl, co } } -static void make_pt_with_offset (u32 *pt, const u32 offset, const u32 *sc, const u32 pwbl_len) +void make_pt_with_offset (u32 *pt, const u32 offset, const u32 *sc, const u32 pwbl_len) { const u32 m = offset % pwbl_len; const u32 om = m % 4; const u32 od = m / 4; - #ifdef IS_AMD + #if defined IS_AMD || defined IS_GENERIC pt[0] = amd_bytealign (sc[od + 1], sc[od + 0], om); pt[1] = amd_bytealign (sc[od + 2], sc[od + 1], om); pt[2] = amd_bytealign (sc[od + 3], sc[od + 2], om); @@ -1246,7 +1248,7 @@ static void make_pt_with_offset (u32 *pt, const u32 offset, const u32 *sc, const #endif } -static void make_w_with_offset (ctx_t *ctx, const u32 W_len, const u32 offset, const u32 *sc, const u32 pwbl_len, u32 *iv, const u32 *rek, __local u32 s_te0[256], __local u32 s_te1[256], __local u32 s_te2[256], __local u32 s_te3[256], __local u32 s_te4[256]) +void make_w_with_offset (ctx_t *ctx, const u32 W_len, const u32 offset, const u32 *sc, const u32 pwbl_len, u32 *iv, const u32 *rek, __local u32 *s_te0, __local u32 *s_te1, __local u32 *s_te2, __local u32 *s_te3, __local u32 *s_te4) { for (u32 k = 0, wk = 0; k < W_len; k += AESSZ, wk += AESSZ4) { @@ -1268,7 +1270,7 @@ static void make_w_with_offset (ctx_t *ctx, const u32 W_len, const u32 offset, c } } -static u32 do_round (const u32 *pw, const u32 pw_len, ctx_t *ctx, __local u32 s_te0[256], __local u32 s_te1[256], __local u32 s_te2[256], __local u32 s_te3[256], __local u32 s_te4[256]) +u32 do_round (const u32 *pw, const u32 pw_len, ctx_t *ctx, __local u32 *s_te0, __local u32 *s_te1, __local u32 *s_te2, __local u32 *s_te3, __local u32 *s_te4) { // make scratch buffer @@ -1516,7 +1518,7 @@ static u32 do_round (const u32 *pw, const u32 pw_len, ctx_t *ctx, __local u32 s_ return ex; } -__kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m10700_init (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global pdf17l8_tmp_t *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global pdf_t *pdf_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max) +__kernel void m10700_init (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global pdf17l8_tmp_t *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global pdf_t *pdf_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max) { /** * base @@ -1622,47 +1624,34 @@ __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m10700_init (__gl tmps[gid].W_len = WORDSZ256; } -__kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m10700_loop (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global pdf17l8_tmp_t *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global pdf_t *pdf_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max) +__kernel void m10700_loop (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global pdf17l8_tmp_t *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global pdf_t *pdf_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max) { + /** + * base + */ + const u32 gid = get_global_id (0); const u32 lid = get_local_id (0); + const u32 lsz = get_local_size (0); /** * aes shared */ - const u32 lid4 = lid * 4; - __local u32 s_te0[256]; __local u32 s_te1[256]; __local u32 s_te2[256]; __local u32 s_te3[256]; __local u32 s_te4[256]; - s_te0[lid4 + 0] = te0[lid4 + 0]; - s_te0[lid4 + 1] = te0[lid4 + 1]; - s_te0[lid4 + 2] = te0[lid4 + 2]; - s_te0[lid4 + 3] = te0[lid4 + 3]; - - s_te1[lid4 + 0] = te1[lid4 + 0]; - s_te1[lid4 + 1] = te1[lid4 + 1]; - s_te1[lid4 + 2] = te1[lid4 + 2]; - s_te1[lid4 + 3] = te1[lid4 + 3]; - - s_te2[lid4 + 0] = te2[lid4 + 0]; - s_te2[lid4 + 1] = te2[lid4 + 1]; - s_te2[lid4 + 2] = te2[lid4 + 2]; - s_te2[lid4 + 3] = te2[lid4 + 3]; - - s_te3[lid4 + 0] = te3[lid4 + 0]; - s_te3[lid4 + 1] = te3[lid4 + 1]; - s_te3[lid4 + 2] = te3[lid4 + 2]; - s_te3[lid4 + 3] = te3[lid4 + 3]; - - s_te4[lid4 + 0] = te4[lid4 + 0]; - s_te4[lid4 + 1] = te4[lid4 + 1]; - s_te4[lid4 + 2] = te4[lid4 + 2]; - s_te4[lid4 + 3] = te4[lid4 + 3]; + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } barrier (CLK_LOCAL_MEM_FENCE); @@ -1681,6 +1670,8 @@ __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m10700_loop (__gl const u32 pw_len = pws[gid].pw_len; + if (pw_len == 0) return; + /** * digest */ @@ -1725,7 +1716,7 @@ __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m10700_loop (__gl tmps[gid].W_len = ctx.W_len; } -__kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m10700_comp (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global pdf17l8_tmp_t *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global pdf_t *pdf_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max) +__kernel void m10700_comp (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global pdf17l8_tmp_t *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global pdf_t *pdf_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max) { /** * modifier