1/**
2 * Author......: See docs/credits.txt
3 * License.....: MIT
4 */
5
6//#define NEW_SIMD_CODE
7
8#ifdef KERNEL_STATIC
9#include "inc_vendor.h"
10#include "inc_types.h"
11#include "inc_platform.cl"
12#include "inc_common.cl"
13#include "inc_scalar.cl"
14#include "inc_hash_md5.cl"
15#endif
16
17KERNEL_FQ void m03800_mxx (KERN_ATTR_BASIC ())
18{
19  /**
20   * modifier
21   */
22
23  const u64 lid = get_local_id (0);
24  const u64 gid = get_global_id (0);
25
26  if (gid >= gid_max) return;
27
28  /**
29   * base
30   */
31
32  const u32 salt_len = salt_bufs[SALT_POS].salt_len;
33
34  u32 s[64] = { 0 };
35
36  for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1)
37  {
38    s[idx] = salt_bufs[SALT_POS].salt_buf[idx];
39  }
40
41  md5_ctx_t ctx0;
42
43  md5_init (&ctx0);
44
45  md5_update (&ctx0, s, salt_len);
46
47  md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len);
48
49  /**
50   * loop
51   */
52
53  for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
54  {
55    md5_ctx_t ctx = ctx0;
56
57    md5_update_global (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
58
59    md5_update (&ctx, s, salt_len);
60
61    md5_final (&ctx);
62
63    const u32 r0 = ctx.h[DGST_R0];
64    const u32 r1 = ctx.h[DGST_R1];
65    const u32 r2 = ctx.h[DGST_R2];
66    const u32 r3 = ctx.h[DGST_R3];
67
68    COMPARE_M_SCALAR (r0, r1, r2, r3);
69  }
70}
71
72KERNEL_FQ void m03800_sxx (KERN_ATTR_BASIC ())
73{
74  /**
75   * modifier
76   */
77
78  const u64 lid = get_local_id (0);
79  const u64 gid = get_global_id (0);
80
81  if (gid >= gid_max) return;
82
83  /**
84   * digest
85   */
86
87  const u32 search[4] =
88  {
89    digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0],
90    digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1],
91    digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2],
92    digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3]
93  };
94
95  /**
96   * base
97   */
98
99  const u32 salt_len = salt_bufs[SALT_POS].salt_len;
100
101  u32 s[64] = { 0 };
102
103  for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1)
104  {
105    s[idx] = salt_bufs[SALT_POS].salt_buf[idx];
106  }
107
108  md5_ctx_t ctx0;
109
110  md5_init (&ctx0);
111
112  md5_update (&ctx0, s, salt_len);
113
114  md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len);
115
116  /**
117   * loop
118   */
119
120  for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
121  {
122    md5_ctx_t ctx = ctx0;
123
124    md5_update_global (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
125
126    md5_update (&ctx, s, salt_len);
127
128    md5_final (&ctx);
129
130    const u32 r0 = ctx.h[DGST_R0];
131    const u32 r1 = ctx.h[DGST_R1];
132    const u32 r2 = ctx.h[DGST_R2];
133    const u32 r3 = ctx.h[DGST_R3];
134
135    COMPARE_S_SCALAR (r0, r1, r2, r3);
136  }
137}
138