2016-03-01 17:56:46 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2016-03-01 17:56:46 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
2016-05-09 19:32:12 +00:00
|
|
|
|
2016-05-25 21:04:26 +00:00
|
|
|
#include "inc_vendor.cl"
|
2016-06-26 21:39:42 +00:00
|
|
|
#include "inc_hash_constants.h"
|
2016-05-25 21:04:26 +00:00
|
|
|
#include "inc_hash_functions.cl"
|
|
|
|
#include "inc_types.cl"
|
|
|
|
#include "inc_common.cl"
|
2017-07-08 22:13:00 +00:00
|
|
|
#include "inc_hash_sha1.cl"
|
|
|
|
#include "inc_cipher_aes.cl"
|
2016-03-01 17:56:46 +00:00
|
|
|
|
2017-08-25 15:52:55 +00:00
|
|
|
__kernel void m13200_init (__global pw_t *pws, __global const kernel_rule_t *rules_buf, __global const pw_t *combs_buf, __global const bf_t *bfs_buf, __global axcrypt_tmp_t *tmps, __global void *hooks, __global const u32 *bitmaps_buf_s1_a, __global const u32 *bitmaps_buf_s1_b, __global const u32 *bitmaps_buf_s1_c, __global const u32 *bitmaps_buf_s1_d, __global const u32 *bitmaps_buf_s2_a, __global const u32 *bitmaps_buf_s2_b, __global const u32 *bitmaps_buf_s2_c, __global const u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global const digest_t *digests_buf, __global u32 *hashes_shown, __global const salt_t *salt_bufs, __global const 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u64 gid_max)
|
2016-03-01 17:56:46 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* base
|
|
|
|
*/
|
|
|
|
|
2017-08-19 14:39:22 +00:00
|
|
|
const u64 gid = get_global_id (0);
|
2016-03-01 17:56:46 +00:00
|
|
|
|
|
|
|
if (gid >= gid_max) return;
|
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
/**
|
|
|
|
* KEK
|
|
|
|
*/
|
2016-03-01 17:56:46 +00:00
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
sha1_ctx_t ctx;
|
2016-03-01 17:56:46 +00:00
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
sha1_init (&ctx);
|
2016-05-09 19:32:12 +00:00
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
sha1_update_global_swap (&ctx, pws[gid].i, pws[gid].pw_len);
|
2016-05-09 19:32:12 +00:00
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
sha1_final (&ctx);
|
2016-03-01 17:56:46 +00:00
|
|
|
|
|
|
|
u32 KEK[5];
|
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
KEK[0] = ctx.h[0];
|
|
|
|
KEK[1] = ctx.h[1];
|
|
|
|
KEK[2] = ctx.h[2];
|
|
|
|
KEK[3] = ctx.h[3];
|
|
|
|
KEK[4] = ctx.h[4];
|
2016-03-01 17:56:46 +00:00
|
|
|
|
|
|
|
/* hash XOR salt is KEK, used as key for AES wrapping routine */
|
|
|
|
tmps[gid].KEK[0] = KEK[0] ^ salt_bufs[salt_pos].salt_buf[0];
|
|
|
|
tmps[gid].KEK[1] = KEK[1] ^ salt_bufs[salt_pos].salt_buf[1];
|
|
|
|
tmps[gid].KEK[2] = KEK[2] ^ salt_bufs[salt_pos].salt_buf[2];
|
|
|
|
tmps[gid].KEK[3] = KEK[3] ^ salt_bufs[salt_pos].salt_buf[3];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* salt_buf[0..3] is salt
|
|
|
|
* salt_buf[4..9] is wrapped_key
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* set lsb */
|
|
|
|
tmps[gid].lsb[0] = salt_bufs[salt_pos].salt_buf[6];
|
|
|
|
tmps[gid].lsb[1] = salt_bufs[salt_pos].salt_buf[7];
|
|
|
|
tmps[gid].lsb[2] = salt_bufs[salt_pos].salt_buf[8];
|
|
|
|
tmps[gid].lsb[3] = salt_bufs[salt_pos].salt_buf[9];
|
|
|
|
|
|
|
|
/* set msb */
|
|
|
|
tmps[gid].cipher[0] = salt_bufs[salt_pos].salt_buf[4];
|
|
|
|
tmps[gid].cipher[1] = salt_bufs[salt_pos].salt_buf[5];
|
|
|
|
tmps[gid].cipher[2] = 0;
|
|
|
|
tmps[gid].cipher[3] = 0;
|
|
|
|
}
|
|
|
|
|
2017-08-25 15:52:55 +00:00
|
|
|
__kernel void m13200_loop (__global pw_t *pws, __global const kernel_rule_t *rules_buf, __global const pw_t *combs_buf, __global const bf_t *bfs_buf, __global axcrypt_tmp_t *tmps, __global void *hooks, __global const u32 *bitmaps_buf_s1_a, __global const u32 *bitmaps_buf_s1_b, __global const u32 *bitmaps_buf_s1_c, __global const u32 *bitmaps_buf_s1_d, __global const u32 *bitmaps_buf_s2_a, __global const u32 *bitmaps_buf_s2_b, __global const u32 *bitmaps_buf_s2_c, __global const u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global const digest_t *digests_buf, __global u32 *hashes_shown, __global const salt_t *salt_bufs, __global const 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u64 gid_max)
|
2016-03-01 17:56:46 +00:00
|
|
|
{
|
2017-08-19 14:39:22 +00:00
|
|
|
const u64 gid = get_global_id (0);
|
|
|
|
const u64 lid = get_local_id (0);
|
|
|
|
const u64 lsz = get_local_size (0);
|
2016-03-01 17:56:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* aes shared
|
|
|
|
*/
|
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
#ifdef REAL_SHM
|
|
|
|
|
2016-03-01 17:56:46 +00:00
|
|
|
__local u32 s_td0[256];
|
|
|
|
__local u32 s_td1[256];
|
|
|
|
__local u32 s_td2[256];
|
|
|
|
__local u32 s_td3[256];
|
|
|
|
__local u32 s_td4[256];
|
|
|
|
|
|
|
|
__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];
|
|
|
|
|
2018-08-12 16:04:33 +00:00
|
|
|
for (MAYBE_VOLATILE u32 i = lid; i < 256; i += lsz)
|
2016-03-01 17:56:46 +00:00
|
|
|
{
|
|
|
|
s_td0[i] = td0[i];
|
|
|
|
s_td1[i] = td1[i];
|
|
|
|
s_td2[i] = td2[i];
|
|
|
|
s_td3[i] = td3[i];
|
|
|
|
s_td4[i] = td4[i];
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
#else
|
2016-03-01 17:56:46 +00:00
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
__constant u32a *s_td0 = td0;
|
|
|
|
__constant u32a *s_td1 = td1;
|
|
|
|
__constant u32a *s_td2 = td2;
|
|
|
|
__constant u32a *s_td3 = td3;
|
|
|
|
__constant u32a *s_td4 = td4;
|
2016-03-01 17:56:46 +00:00
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
__constant u32a *s_te0 = te0;
|
|
|
|
__constant u32a *s_te1 = te1;
|
|
|
|
__constant u32a *s_te2 = te2;
|
|
|
|
__constant u32a *s_te3 = te3;
|
|
|
|
__constant u32a *s_te4 = te4;
|
2016-03-01 17:56:46 +00:00
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
#endif
|
2016-05-09 19:32:12 +00:00
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
if (gid >= gid_max) return;
|
2016-03-01 17:56:46 +00:00
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
u32 ukey[4];
|
2016-03-01 17:56:46 +00:00
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
ukey[0] = tmps[gid].KEK[0];
|
|
|
|
ukey[1] = tmps[gid].KEK[1];
|
|
|
|
ukey[2] = tmps[gid].KEK[2];
|
|
|
|
ukey[3] = tmps[gid].KEK[3];
|
2016-03-01 17:56:46 +00:00
|
|
|
|
|
|
|
u32 lsb[4];
|
2016-05-09 19:32:12 +00:00
|
|
|
|
2016-03-01 17:56:46 +00:00
|
|
|
lsb[0] = tmps[gid].lsb[0];
|
|
|
|
lsb[1] = tmps[gid].lsb[1];
|
|
|
|
lsb[2] = tmps[gid].lsb[2];
|
|
|
|
lsb[3] = tmps[gid].lsb[3];
|
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
u32 cipher[4];
|
|
|
|
|
2016-03-01 17:56:46 +00:00
|
|
|
cipher[0] = tmps[gid].cipher[0];
|
|
|
|
cipher[1] = tmps[gid].cipher[1];
|
|
|
|
cipher[2] = tmps[gid].cipher[2];
|
|
|
|
cipher[3] = tmps[gid].cipher[3];
|
2016-05-09 19:32:12 +00:00
|
|
|
|
2016-03-01 17:56:46 +00:00
|
|
|
/**
|
2017-07-08 22:13:00 +00:00
|
|
|
* aes init
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define KEYLEN 44
|
|
|
|
|
|
|
|
u32 ks[KEYLEN];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* aes decrypt key
|
|
|
|
*/
|
|
|
|
|
2017-07-09 15:39:38 +00:00
|
|
|
AES128_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4);
|
2016-03-01 17:56:46 +00:00
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
const u32 wrapping_rounds = salt_bufs[salt_pos].salt_iter - 1;
|
2016-03-01 17:56:46 +00:00
|
|
|
|
|
|
|
/* custom AES un-wrapping loop */
|
|
|
|
for (u32 i = 0, j = wrapping_rounds - loop_pos; i < loop_cnt; i++, j--)
|
|
|
|
{
|
2017-07-08 22:13:00 +00:00
|
|
|
const u32 j2 = j * 2;
|
|
|
|
|
|
|
|
cipher[0] ^= swap32_S (j2 + 2);
|
2016-03-01 17:56:46 +00:00
|
|
|
|
|
|
|
/* R[i] */
|
|
|
|
cipher[2] = lsb[2];
|
|
|
|
cipher[3] = lsb[3];
|
|
|
|
|
|
|
|
/* AES_ECB(KEK, (MSB XOR (NUMBER_AES_BLOCKS * j + i)) | R[i]) */
|
2017-07-08 22:13:00 +00:00
|
|
|
|
2017-07-09 15:39:38 +00:00
|
|
|
AES128_decrypt (ks, cipher, cipher, s_td0, s_td1, s_td2, s_td3, s_td4);
|
2016-03-01 17:56:46 +00:00
|
|
|
|
|
|
|
lsb[2] = cipher[2];
|
|
|
|
lsb[3] = cipher[3];
|
|
|
|
|
|
|
|
/* 2nd block treatment */
|
2017-07-08 22:13:00 +00:00
|
|
|
cipher[0] ^= swap32_S (j2 + 1);
|
2016-03-01 17:56:46 +00:00
|
|
|
|
|
|
|
cipher[2] = lsb[0];
|
|
|
|
cipher[3] = lsb[1];
|
|
|
|
|
2017-07-09 15:39:38 +00:00
|
|
|
AES128_decrypt (ks, cipher, cipher, s_td0, s_td1, s_td2, s_td3, s_td4);
|
2016-03-01 17:56:46 +00:00
|
|
|
|
|
|
|
lsb[0] = cipher[2];
|
|
|
|
lsb[1] = cipher[3];
|
|
|
|
}
|
|
|
|
|
|
|
|
tmps[gid].lsb[0] = lsb[0];
|
|
|
|
tmps[gid].lsb[1] = lsb[1];
|
|
|
|
tmps[gid].lsb[2] = lsb[2];
|
|
|
|
tmps[gid].lsb[3] = lsb[3];
|
2016-05-09 19:32:12 +00:00
|
|
|
|
2016-03-01 17:56:46 +00:00
|
|
|
tmps[gid].cipher[0] = cipher[0];
|
|
|
|
tmps[gid].cipher[1] = cipher[1];
|
|
|
|
tmps[gid].cipher[2] = cipher[2];
|
|
|
|
tmps[gid].cipher[3] = cipher[3];
|
|
|
|
}
|
|
|
|
|
2017-08-25 15:52:55 +00:00
|
|
|
__kernel void m13200_comp (__global pw_t *pws, __global const kernel_rule_t *rules_buf, __global const pw_t *combs_buf, __global const bf_t *bfs_buf, __global axcrypt_tmp_t *tmps, __global void *hooks, __global const u32 *bitmaps_buf_s1_a, __global const u32 *bitmaps_buf_s1_b, __global const u32 *bitmaps_buf_s1_c, __global const u32 *bitmaps_buf_s1_d, __global const u32 *bitmaps_buf_s2_a, __global const u32 *bitmaps_buf_s2_b, __global const u32 *bitmaps_buf_s2_c, __global const u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global const digest_t *digests_buf, __global u32 *hashes_shown, __global const salt_t *salt_bufs, __global const 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u64 gid_max)
|
2016-03-01 17:56:46 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* base
|
|
|
|
*/
|
|
|
|
|
2017-08-19 14:39:22 +00:00
|
|
|
const u64 gid = get_global_id (0);
|
2016-03-01 17:56:46 +00:00
|
|
|
|
|
|
|
if (gid >= gid_max) return;
|
|
|
|
|
2017-08-19 14:39:22 +00:00
|
|
|
const u64 lid = get_local_id (0);
|
2017-07-08 22:13:00 +00:00
|
|
|
|
2016-03-01 17:56:46 +00:00
|
|
|
#define il_pos 0
|
|
|
|
|
2017-07-08 22:13:00 +00:00
|
|
|
if (tmps[gid].cipher[0] == 0xa6a6a6a6 && tmps[gid].cipher[1] == 0xa6a6a6a6)
|
2016-03-01 17:56:46 +00:00
|
|
|
{
|
2017-06-16 08:48:10 +00:00
|
|
|
if (atomic_inc (&hashes_shown[digests_offset]) == 0)
|
|
|
|
{
|
|
|
|
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos);
|
|
|
|
}
|
2016-03-01 17:56:46 +00:00
|
|
|
}
|
|
|
|
}
|