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_sha512.cl"
15#endif
16
17KERNEL_FQ void m01740_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  sha512_ctx_t ctx0;
33
34  sha512_init (&ctx0);
35
36  sha512_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len);
37
38  sha512_update_global_utf16le_swap (&ctx0, pws[gid].i, pws[gid].pw_len);
39
40  /**
41   * loop
42   */
43
44  for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
45  {
46    sha512_ctx_t ctx = ctx0;
47
48    sha512_update_global_utf16le_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
49
50    sha512_final (&ctx);
51
52    const u32 r0 = l32_from_64_S (ctx.h[7]);
53    const u32 r1 = h32_from_64_S (ctx.h[7]);
54    const u32 r2 = l32_from_64_S (ctx.h[3]);
55    const u32 r3 = h32_from_64_S (ctx.h[3]);
56
57    COMPARE_M_SCALAR (r0, r1, r2, r3);
58  }
59}
60
61KERNEL_FQ void m01740_sxx (KERN_ATTR_BASIC ())
62{
63  /**
64   * modifier
65   */
66
67  const u64 lid = get_local_id (0);
68  const u64 gid = get_global_id (0);
69
70  if (gid >= gid_max) return;
71
72  /**
73   * digest
74   */
75
76  const u32 search[4] =
77  {
78    digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0],
79    digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1],
80    digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2],
81    digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3]
82  };
83
84  /**
85   * base
86   */
87
88  sha512_ctx_t ctx0;
89
90  sha512_init (&ctx0);
91
92  sha512_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len);
93
94  sha512_update_global_utf16le_swap (&ctx0, pws[gid].i, pws[gid].pw_len);
95
96  /**
97   * loop
98   */
99
100  for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
101  {
102    sha512_ctx_t ctx = ctx0;
103
104    sha512_update_global_utf16le_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
105
106    sha512_final (&ctx);
107
108    const u32 r0 = l32_from_64_S (ctx.h[7]);
109    const u32 r1 = h32_from_64_S (ctx.h[7]);
110    const u32 r2 = l32_from_64_S (ctx.h[3]);
111    const u32 r3 = h32_from_64_S (ctx.h[3]);
112
113    COMPARE_S_SCALAR (r0, r1, r2, r3);
114  }
115}
116