2015-12-04 14:47:52 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2015-12-04 14:47:52 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
2019-03-22 14:16:25 +00:00
|
|
|
#ifdef KERNEL_STATIC
|
2019-03-21 22:00:38 +00:00
|
|
|
#include "inc_vendor.h"
|
|
|
|
#include "inc_types.h"
|
2019-04-26 11:59:43 +00:00
|
|
|
#include "inc_platform.cl"
|
2016-05-25 21:04:26 +00:00
|
|
|
#include "inc_common.cl"
|
2017-07-07 10:14:06 +00:00
|
|
|
#include "inc_hash_sha1.cl"
|
2019-03-22 14:16:25 +00:00
|
|
|
#endif
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2016-05-25 21:04:26 +00:00
|
|
|
#define COMPARE_S "inc_comp_single.cl"
|
|
|
|
#define COMPARE_M "inc_comp_multi.cl"
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2019-03-08 10:14:33 +00:00
|
|
|
typedef struct saph_sha1_tmp
|
|
|
|
{
|
|
|
|
u32 digest_buf[5];
|
|
|
|
|
|
|
|
} saph_sha1_tmp_t;
|
|
|
|
|
2019-03-22 21:27:58 +00:00
|
|
|
KERNEL_FQ void m10300_init (KERN_ATTR_TMPS (saph_sha1_tmp_t))
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* base
|
|
|
|
*/
|
|
|
|
|
2017-08-19 14:39:22 +00:00
|
|
|
const u64 gid = get_global_id (0);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2022-01-04 21:57:26 +00:00
|
|
|
if (gid >= GID_CNT) return;
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2017-07-07 10:14:06 +00:00
|
|
|
sha1_ctx_t ctx;
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2017-07-07 10:14:06 +00:00
|
|
|
sha1_init (&ctx);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2019-02-26 20:20:07 +00:00
|
|
|
sha1_update_global_swap (&ctx, pws[gid].i, pws[gid].pw_len);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2022-01-04 17:07:18 +00:00
|
|
|
sha1_update_global_swap (&ctx, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2017-07-07 10:14:06 +00:00
|
|
|
sha1_final (&ctx);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2017-07-07 10:14:06 +00:00
|
|
|
tmps[gid].digest_buf[0] = ctx.h[0];
|
|
|
|
tmps[gid].digest_buf[1] = ctx.h[1];
|
|
|
|
tmps[gid].digest_buf[2] = ctx.h[2];
|
|
|
|
tmps[gid].digest_buf[3] = ctx.h[3];
|
|
|
|
tmps[gid].digest_buf[4] = ctx.h[4];
|
2015-12-04 14:47:52 +00:00
|
|
|
}
|
|
|
|
|
2019-03-22 21:27:58 +00:00
|
|
|
KERNEL_FQ void m10300_loop (KERN_ATTR_TMPS (saph_sha1_tmp_t))
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* base
|
|
|
|
*/
|
|
|
|
|
2017-08-19 14:39:22 +00:00
|
|
|
const u64 gid = get_global_id (0);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2022-01-04 21:57:26 +00:00
|
|
|
if (gid >= GID_CNT) return;
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2017-07-07 10:14:06 +00:00
|
|
|
/**
|
|
|
|
* init
|
|
|
|
*/
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2017-07-07 10:14:06 +00:00
|
|
|
sha1_ctx_t ctx;
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2017-07-07 10:14:06 +00:00
|
|
|
sha1_init (&ctx);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2019-02-26 20:20:07 +00:00
|
|
|
sha1_update_global_swap (&ctx, pws[gid].i, pws[gid].pw_len);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2017-07-07 10:14:06 +00:00
|
|
|
/**
|
|
|
|
* load
|
|
|
|
*/
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2015-12-15 11:04:22 +00:00
|
|
|
u32 digest[5];
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
digest[0] = tmps[gid].digest_buf[0];
|
|
|
|
digest[1] = tmps[gid].digest_buf[1];
|
|
|
|
digest[2] = tmps[gid].digest_buf[2];
|
|
|
|
digest[3] = tmps[gid].digest_buf[3];
|
|
|
|
digest[4] = tmps[gid].digest_buf[4];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* loop
|
|
|
|
*/
|
|
|
|
|
2022-01-04 17:07:18 +00:00
|
|
|
for (u32 i = 0; i < LOOP_CNT; i++)
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
2015-12-15 11:04:22 +00:00
|
|
|
u32 w0[4];
|
|
|
|
u32 w1[4];
|
|
|
|
u32 w2[4];
|
|
|
|
u32 w3[4];
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
w0[0] = digest[0];
|
|
|
|
w0[1] = digest[1];
|
|
|
|
w0[2] = digest[2];
|
|
|
|
w0[3] = digest[3];
|
|
|
|
w1[0] = digest[4];
|
2017-07-07 10:14:06 +00:00
|
|
|
w1[1] = 0;
|
2015-12-04 14:47:52 +00:00
|
|
|
w1[2] = 0;
|
|
|
|
w1[3] = 0;
|
|
|
|
w2[0] = 0;
|
|
|
|
w2[1] = 0;
|
|
|
|
w2[2] = 0;
|
|
|
|
w2[3] = 0;
|
|
|
|
w3[0] = 0;
|
|
|
|
w3[1] = 0;
|
|
|
|
w3[2] = 0;
|
|
|
|
w3[3] = 0;
|
|
|
|
|
2017-07-07 10:14:06 +00:00
|
|
|
sha1_ctx_t ctx_inner = ctx;
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2017-07-07 10:14:06 +00:00
|
|
|
sha1_update_64 (&ctx_inner, w0, w1, w2, w3, 20);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2017-07-07 10:14:06 +00:00
|
|
|
sha1_final (&ctx_inner);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2017-07-07 10:14:06 +00:00
|
|
|
digest[0] = ctx_inner.h[0];
|
|
|
|
digest[1] = ctx_inner.h[1];
|
|
|
|
digest[2] = ctx_inner.h[2];
|
|
|
|
digest[3] = ctx_inner.h[3];
|
|
|
|
digest[4] = ctx_inner.h[4];
|
2015-12-04 14:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tmps[gid].digest_buf[0] = digest[0];
|
|
|
|
tmps[gid].digest_buf[1] = digest[1];
|
|
|
|
tmps[gid].digest_buf[2] = digest[2];
|
|
|
|
tmps[gid].digest_buf[3] = digest[3];
|
|
|
|
tmps[gid].digest_buf[4] = digest[4];
|
|
|
|
}
|
|
|
|
|
2019-03-22 21:27:58 +00:00
|
|
|
KERNEL_FQ void m10300_comp (KERN_ATTR_TMPS (saph_sha1_tmp_t))
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* modifier
|
|
|
|
*/
|
|
|
|
|
2017-08-19 14:39:22 +00:00
|
|
|
const u64 gid = get_global_id (0);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2022-01-04 21:57:26 +00:00
|
|
|
if (gid >= GID_CNT) return;
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2017-08-19 14:39:22 +00:00
|
|
|
const u64 lid = get_local_id (0);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* digest
|
|
|
|
*/
|
|
|
|
|
2015-12-15 11:04:22 +00:00
|
|
|
const u32 r0 = tmps[gid].digest_buf[0];
|
|
|
|
const u32 r1 = tmps[gid].digest_buf[1];
|
|
|
|
const u32 r2 = tmps[gid].digest_buf[2];
|
|
|
|
const u32 r3 = tmps[gid].digest_buf[3];
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
#define il_pos 0
|
|
|
|
|
2019-03-22 14:16:25 +00:00
|
|
|
#ifdef KERNEL_STATIC
|
2015-12-15 11:04:22 +00:00
|
|
|
#include COMPARE_M
|
2019-03-22 14:16:25 +00:00
|
|
|
#endif
|
2015-12-04 14:47:52 +00:00
|
|
|
}
|