#define _SHA1_
-#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
{
{ 0x33323031, 4 }
};
-static void append_word (u32 w0[4], u32 w1[4], const u32 append[4], const u32 offset)
+void append_word (u32 w0[4], u32 w1[4], const u32 append[4], const u32 offset)
{
switch (offset)
{
}
}
-static void append_salt (u32 w0[4], u32 w1[4], u32 w2[4], const u32 append[5], const u32 offset)
+void append_salt (u32 w0[4], u32 w1[4], u32 w2[4], const u32 append[5], const u32 offset)
{
- switch (offset)
- {
- case 2:
- w0[0] = w0[0] | append[0] << 16;
- w0[1] = append[0] >> 16 | append[1] << 16;
- w0[2] = append[1] >> 16 | append[2] << 16;
- w0[3] = append[2] >> 16 | append[3] << 16;
- w1[0] = append[3] >> 16 | append[4] << 16;
- w1[1] = append[4] >> 16;
- break;
-
- case 3:
- w0[0] = w0[0] | append[0] << 24;
- w0[1] = append[0] >> 8 | append[1] << 24;
- w0[2] = append[1] >> 8 | append[2] << 24;
- w0[3] = append[2] >> 8 | append[3] << 24;
- w1[0] = append[3] >> 8 | append[4] << 24;
- w1[1] = append[4] >> 8;
- break;
-
- case 4:
- w0[1] = append[0];
- w0[2] = append[1];
- w0[3] = append[2];
- w1[0] = append[3];
- w1[1] = append[4];
- break;
+ u32 tmp0;
+ u32 tmp1;
+ u32 tmp2;
+ u32 tmp3;
+ u32 tmp4;
+ u32 tmp5;
- case 5:
- w0[1] = w0[1] | append[0] << 8;
- w0[2] = append[0] >> 24 | append[1] << 8;
- w0[3] = append[1] >> 24 | append[2] << 8;
- w1[0] = append[2] >> 24 | append[3] << 8;
- w1[1] = append[3] >> 24 | append[4] << 8;
- w1[2] = append[4] >> 24;
- break;
+ #if defined IS_AMD || defined IS_GENERIC
- case 6:
- w0[1] = w0[1] | append[0] << 16;
- w0[2] = append[0] >> 16 | append[1] << 16;
- w0[3] = append[1] >> 16 | append[2] << 16;
- w1[0] = append[2] >> 16 | append[3] << 16;
- w1[1] = append[3] >> 16 | append[4] << 16;
- w1[2] = append[4] >> 16;
- break;
+ const int offset_minus_4 = 4 - (offset & 3);
- case 7:
- w0[1] = w0[1] | append[0] << 24;
- w0[2] = append[0] >> 8 | append[1] << 24;
- w0[3] = append[1] >> 8 | append[2] << 24;
- w1[0] = append[2] >> 8 | append[3] << 24;
- w1[1] = append[3] >> 8 | append[4] << 24;
- w1[2] = append[4] >> 8;
- break;
+ tmp0 = amd_bytealign (append[0], 0, offset_minus_4);
+ tmp1 = amd_bytealign (append[1], append[0], offset_minus_4);
+ tmp2 = amd_bytealign (append[2], append[1], offset_minus_4);
+ tmp3 = amd_bytealign (append[3], append[2], offset_minus_4);
+ tmp4 = amd_bytealign (append[4], append[3], offset_minus_4);
+ tmp5 = amd_bytealign ( 0, append[4], offset_minus_4);
- case 8:
- w0[2] = append[0];
- w0[3] = append[1];
- w1[0] = append[2];
- w1[1] = append[3];
- w1[2] = append[4];
- break;
+ const u32 mod = offset & 3;
- case 9:
- w0[2] = w0[2] | append[0] << 8;
- w0[3] = append[0] >> 24 | append[1] << 8;
- w1[0] = append[1] >> 24 | append[2] << 8;
- w1[1] = append[2] >> 24 | append[3] << 8;
- w1[2] = append[3] >> 24 | append[4] << 8;
- w1[3] = append[4] >> 24;
- break;
+ if (mod == 0)
+ {
+ tmp0 = tmp1;
+ tmp1 = tmp2;
+ tmp2 = tmp3;
+ tmp3 = tmp4;
+ tmp4 = tmp5;
+ tmp5 = 0;
+ }
- case 10:
- w0[2] = w0[2] | append[0] << 16;
- w0[3] = append[0] >> 16 | append[1] << 16;
- w1[0] = append[1] >> 16 | append[2] << 16;
- w1[1] = append[2] >> 16 | append[3] << 16;
- w1[2] = append[3] >> 16 | append[4] << 16;
- w1[3] = append[4] >> 16;
- break;
+ #endif
- case 11:
- w0[2] = w0[2] | append[0] << 24;
- w0[3] = append[0] >> 8 | append[1] << 24;
- w1[0] = append[1] >> 8 | append[2] << 24;
- w1[1] = append[2] >> 8 | append[3] << 24;
- w1[2] = append[3] >> 8 | append[4] << 24;
- w1[3] = append[4] >> 8;
- break;
+ #ifdef IS_NV
- case 12:
- w0[3] = append[0];
- w1[0] = append[1];
- w1[1] = append[2];
- w1[2] = append[3];
- w1[3] = append[4];
- break;
+ const int offset_minus_4 = 4 - (offset & 3);
- case 13:
- w0[3] = w0[3] | append[0] << 8;
- w1[0] = append[0] >> 24 | append[1] << 8;
- w1[1] = append[1] >> 24 | append[2] << 8;
- w1[2] = append[2] >> 24 | append[3] << 8;
- w1[3] = append[3] >> 24 | append[4] << 8;
- w2[0] = append[4] >> 24;
- break;
+ const int selector = (0x76543210 >> (offset_minus_4 * 4)) & 0xffff;
- case 14:
- w0[3] = w0[3] | append[0] << 16;
- w1[0] = append[0] >> 16 | append[1] << 16;
- w1[1] = append[1] >> 16 | append[2] << 16;
- w1[2] = append[2] >> 16 | append[3] << 16;
- w1[3] = append[3] >> 16 | append[4] << 16;
- w2[0] = append[4] >> 16;
- break;
+ tmp0 = __byte_perm ( 0, append[0], selector);
+ tmp1 = __byte_perm (append[0], append[1], selector);
+ tmp2 = __byte_perm (append[1], append[2], selector);
+ tmp3 = __byte_perm (append[2], append[3], selector);
+ tmp4 = __byte_perm (append[3], append[4], selector);
+ tmp5 = __byte_perm (append[4], 0, selector);
- case 15:
- w0[3] = w0[3] | append[0] << 24;
- w1[0] = append[0] >> 8 | append[1] << 24;
- w1[1] = append[1] >> 8 | append[2] << 24;
- w1[2] = append[2] >> 8 | append[3] << 24;
- w1[3] = append[3] >> 8 | append[4] << 24;
- w2[0] = append[4] >> 8;
- break;
+ #endif
- case 16:
- w1[0] = append[0];
- w1[1] = append[1];
- w1[2] = append[2];
- w1[3] = append[3];
- w2[0] = append[4];
- break;
+ const u32 div = offset / 4;
- case 17:
- w1[0] = w1[0] | append[0] << 8;
- w1[1] = append[0] >> 24 | append[1] << 8;
- w1[2] = append[1] >> 24 | append[2] << 8;
- w1[3] = append[2] >> 24 | append[3] << 8;
- w2[0] = append[3] >> 24 | append[4] << 8;
- w2[1] = append[4] >> 24;
- break;
-
- case 18:
- w1[0] = w1[0] | append[0] << 16;
- w1[1] = append[0] >> 16 | append[1] << 16;
- w1[2] = append[1] >> 16 | append[2] << 16;
- w1[3] = append[2] >> 16 | append[3] << 16;
- w2[0] = append[3] >> 16 | append[4] << 16;
- w2[1] = append[4] >> 16;
- break;
-
- case 19:
- w1[0] = w1[0] | append[0] << 24;
- w1[1] = append[0] >> 8 | append[1] << 24;
- w1[2] = append[1] >> 8 | append[2] << 24;
- w1[3] = append[2] >> 8 | append[3] << 24;
- w2[0] = append[3] >> 8 | append[4] << 24;
- w2[1] = append[4] >> 8;
- break;
+ switch (div)
+ {
+ case 0: w0[0] |= tmp0;
+ w0[1] = tmp1;
+ w0[2] = tmp2;
+ w0[3] = tmp3;
+ w1[0] = tmp4;
+ w1[1] = tmp5;
+ break;
+ case 1: w0[1] |= tmp0;
+ w0[2] = tmp1;
+ w0[3] = tmp2;
+ w1[0] = tmp3;
+ w1[1] = tmp4;
+ w1[2] = tmp5;
+ break;
+ case 2: w0[2] |= tmp0;
+ w0[3] = tmp1;
+ w1[0] = tmp2;
+ w1[1] = tmp3;
+ w1[2] = tmp4;
+ w1[3] = tmp5;
+ break;
+ case 3: w0[3] |= tmp0;
+ w1[0] = tmp1;
+ w1[1] = tmp2;
+ w1[2] = tmp3;
+ w1[3] = tmp4;
+ w2[0] = tmp5;
+ break;
+ case 4: w1[0] |= tmp0;
+ w1[1] = tmp1;
+ w1[2] = tmp2;
+ w1[3] = tmp3;
+ w2[0] = tmp4;
+ w2[1] = tmp5;
+ break;
}
}
-static void sha1_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[5])
+void sha1_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[5])
{
u32 A = digest[0];
u32 B = digest[1];
digest[4] += E;
}
-__kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05800_init (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global androidpin_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 void *esalt_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 m05800_init (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global androidpin_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 void *esalt_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
tmps[gid].digest_buf[4] = digest[4];
}
-__kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05800_loop (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global androidpin_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 void *esalt_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 m05800_loop (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global androidpin_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 void *esalt_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);
+
+ /**
+ * cache precomputed conversion table in shared memory
+ */
+
+ __local entry_t s_pc[1024];
+
+ for (u32 i = lid; i < 1024; i += lsz)
+ {
+ s_pc[i] = pc[i];
+ }
+
+ barrier (CLK_LOCAL_MEM_FENCE);
+
+ if (gid >= gid_max) return;
+
+ /**
+ * base
+ */
u32 word_buf[4];
const u32 pw_len = pws[gid].pw_len;
- const u32 lid = get_local_id (0);
-
u32 digest[5];
digest[0] = tmps[gid].digest_buf[0];
digest[3] = tmps[gid].digest_buf[3];
digest[4] = tmps[gid].digest_buf[4];
- /**
- * cache precomputed conversion table in shared memory
- */
-
- __local entry_t s_pc[1024];
-
- const u32 lid16 = lid * 16;
-
- s_pc[lid16 + 0] = pc[lid16 + 0];
- s_pc[lid16 + 1] = pc[lid16 + 1];
- s_pc[lid16 + 2] = pc[lid16 + 2];
- s_pc[lid16 + 3] = pc[lid16 + 3];
- s_pc[lid16 + 4] = pc[lid16 + 4];
- s_pc[lid16 + 5] = pc[lid16 + 5];
- s_pc[lid16 + 6] = pc[lid16 + 6];
- s_pc[lid16 + 7] = pc[lid16 + 7];
- s_pc[lid16 + 8] = pc[lid16 + 8];
- s_pc[lid16 + 9] = pc[lid16 + 9];
- s_pc[lid16 + 10] = pc[lid16 + 10];
- s_pc[lid16 + 11] = pc[lid16 + 11];
- s_pc[lid16 + 12] = pc[lid16 + 12];
- s_pc[lid16 + 13] = pc[lid16 + 13];
- s_pc[lid16 + 14] = pc[lid16 + 14];
- s_pc[lid16 + 15] = pc[lid16 + 15];
-
- barrier (CLK_LOCAL_MEM_FENCE);
-
- if (gid >= gid_max) return;
-
/**
* salt
*/
tmps[gid].digest_buf[4] = digest[4];
}
-__kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05800_comp (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global androidpin_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 void *esalt_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 m05800_comp (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global androidpin_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 void *esalt_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