2017-04-30 22:48:09 +00:00
|
|
|
/**
|
|
|
|
* Author......: See docs/credits.txt
|
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
2017-05-01 20:21:54 +00:00
|
|
|
#define NEW_SIMD_CODE
|
|
|
|
|
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"
|
2017-04-30 22:48:09 +00:00
|
|
|
#include "inc_common.cl"
|
2017-05-01 20:21:54 +00:00
|
|
|
#include "inc_simd.cl"
|
2017-07-09 21:05:14 +00:00
|
|
|
#include "inc_hash_md4.cl"
|
|
|
|
#include "inc_hash_sha1.cl"
|
2019-03-09 07:07:50 +00:00
|
|
|
#include "inc_cipher_des.cl"
|
2019-03-22 14:16:25 +00:00
|
|
|
#endif
|
2017-04-30 22:48:09 +00:00
|
|
|
|
2017-05-14 14:02:30 +00:00
|
|
|
#define COMPARE_S "inc_comp_single.cl"
|
|
|
|
#define COMPARE_M "inc_comp_multi.cl"
|
|
|
|
|
2019-03-08 11:50:31 +00:00
|
|
|
typedef struct dpapimk
|
|
|
|
{
|
|
|
|
u32 context;
|
|
|
|
|
|
|
|
u32 SID[32];
|
|
|
|
u32 SID_len;
|
|
|
|
u32 SID_offset;
|
|
|
|
|
|
|
|
/* here only for possible
|
|
|
|
forward compatibiliy
|
|
|
|
*/
|
|
|
|
// u8 cipher_algo[16];
|
|
|
|
// u8 hash_algo[16];
|
|
|
|
|
|
|
|
u32 iv[4];
|
|
|
|
u32 contents_len;
|
|
|
|
u32 contents[128];
|
|
|
|
|
|
|
|
} dpapimk_t;
|
|
|
|
|
|
|
|
typedef struct dpapimk_tmp_v1
|
|
|
|
{
|
|
|
|
u32 ipad[5];
|
|
|
|
u32 opad[5];
|
|
|
|
u32 dgst[10];
|
|
|
|
u32 out[10];
|
|
|
|
|
|
|
|
u32 userKey[5];
|
|
|
|
|
|
|
|
} dpapimk_tmp_v1_t;
|
|
|
|
|
2019-04-13 16:46:19 +00:00
|
|
|
DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest)
|
2017-04-30 22:48:09 +00:00
|
|
|
{
|
|
|
|
digest[0] = ipad[0];
|
|
|
|
digest[1] = ipad[1];
|
|
|
|
digest[2] = ipad[2];
|
|
|
|
digest[3] = ipad[3];
|
|
|
|
digest[4] = ipad[4];
|
|
|
|
|
2017-07-09 21:05:14 +00:00
|
|
|
sha1_transform_vector (w0, w1, w2, w3, digest);
|
2017-04-30 22:48:09 +00:00
|
|
|
|
|
|
|
w0[0] = digest[0];
|
|
|
|
w0[1] = digest[1];
|
|
|
|
w0[2] = digest[2];
|
|
|
|
w0[3] = digest[3];
|
|
|
|
w1[0] = digest[4];
|
|
|
|
w1[1] = 0x80000000;
|
|
|
|
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] = (64 + 20) * 8;
|
|
|
|
|
|
|
|
digest[0] = opad[0];
|
|
|
|
digest[1] = opad[1];
|
|
|
|
digest[2] = opad[2];
|
|
|
|
digest[3] = opad[3];
|
|
|
|
digest[4] = opad[4];
|
|
|
|
|
2017-07-09 21:05:14 +00:00
|
|
|
sha1_transform_vector (w0, w1, w2, w3, digest);
|
2017-05-01 20:21:54 +00:00
|
|
|
}
|
|
|
|
|
2019-03-22 21:27:58 +00:00
|
|
|
KERNEL_FQ void m15300_init (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v1_t, dpapimk_t))
|
2017-04-30 22:48:09 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* base
|
|
|
|
*/
|
|
|
|
|
2017-08-19 14:39:22 +00:00
|
|
|
const u64 gid = get_global_id (0);
|
2017-04-30 22:48:09 +00:00
|
|
|
|
|
|
|
if (gid >= gid_max) return;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* main
|
|
|
|
*/
|
|
|
|
|
|
|
|
u32 digest_context[5];
|
|
|
|
|
|
|
|
if (esalt_bufs[digests_offset].context == 1)
|
|
|
|
{
|
2017-07-09 21:05:14 +00:00
|
|
|
/* local credentials */
|
|
|
|
|
|
|
|
sha1_ctx_t ctx;
|
|
|
|
|
|
|
|
sha1_init (&ctx);
|
|
|
|
|
2019-02-26 20:20:07 +00:00
|
|
|
sha1_update_global_utf16le_swap (&ctx, pws[gid].i, pws[gid].pw_len);
|
2017-04-30 22:48:09 +00:00
|
|
|
|
2017-07-09 21:05:14 +00:00
|
|
|
sha1_final (&ctx);
|
|
|
|
|
|
|
|
digest_context[0] = ctx.h[0];
|
|
|
|
digest_context[1] = ctx.h[1];
|
|
|
|
digest_context[2] = ctx.h[2];
|
|
|
|
digest_context[3] = ctx.h[3];
|
|
|
|
digest_context[4] = ctx.h[4];
|
2017-04-30 22:48:09 +00:00
|
|
|
}
|
|
|
|
else if (esalt_bufs[digests_offset].context == 2)
|
|
|
|
{
|
2017-07-09 21:05:14 +00:00
|
|
|
/* domain credentials */
|
|
|
|
|
|
|
|
md4_ctx_t ctx;
|
|
|
|
|
|
|
|
md4_init (&ctx);
|
2017-04-30 22:48:09 +00:00
|
|
|
|
2019-02-26 20:20:07 +00:00
|
|
|
md4_update_global_utf16le (&ctx, pws[gid].i, pws[gid].pw_len);
|
2017-04-30 22:48:09 +00:00
|
|
|
|
2017-07-09 21:05:14 +00:00
|
|
|
md4_final (&ctx);
|
|
|
|
|
|
|
|
digest_context[0] = ctx.h[0];
|
|
|
|
digest_context[1] = ctx.h[1];
|
|
|
|
digest_context[2] = ctx.h[2];
|
|
|
|
digest_context[3] = ctx.h[3];
|
|
|
|
digest_context[4] = 0;
|
2017-04-30 22:48:09 +00:00
|
|
|
|
2019-03-23 21:15:38 +00:00
|
|
|
digest_context[0] = hc_swap32_S (digest_context[0]);
|
|
|
|
digest_context[1] = hc_swap32_S (digest_context[1]);
|
|
|
|
digest_context[2] = hc_swap32_S (digest_context[2]);
|
|
|
|
digest_context[3] = hc_swap32_S (digest_context[3]);
|
2017-04-30 22:48:09 +00:00
|
|
|
}
|
2017-07-09 21:05:14 +00:00
|
|
|
|
2017-05-01 20:21:54 +00:00
|
|
|
/* initialize hmac-sha1 */
|
2017-04-30 22:48:09 +00:00
|
|
|
|
2017-07-09 21:05:14 +00:00
|
|
|
u32 w0[4];
|
|
|
|
u32 w1[4];
|
|
|
|
u32 w2[4];
|
|
|
|
u32 w3[4];
|
2017-04-30 22:48:09 +00:00
|
|
|
|
2017-05-01 20:21:54 +00:00
|
|
|
w0[0] = digest_context[0];
|
|
|
|
w0[1] = digest_context[1];
|
|
|
|
w0[2] = digest_context[2];
|
|
|
|
w0[3] = digest_context[3];
|
|
|
|
w1[0] = digest_context[4];
|
2017-04-30 22:48:09 +00:00
|
|
|
w1[1] = 0;
|
|
|
|
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-09 21:05:14 +00:00
|
|
|
sha1_hmac_ctx_t ctx;
|
2017-04-30 22:48:09 +00:00
|
|
|
|
2017-07-10 09:15:15 +00:00
|
|
|
sha1_hmac_init_64 (&ctx, w0, w1, w2, w3);
|
2017-04-30 22:48:09 +00:00
|
|
|
|
2017-07-09 21:05:14 +00:00
|
|
|
sha1_hmac_update_global (&ctx, esalt_bufs[digests_offset].SID, esalt_bufs[digests_offset].SID_len);
|
2017-05-01 20:21:54 +00:00
|
|
|
|
2017-07-09 21:05:14 +00:00
|
|
|
sha1_hmac_final (&ctx);
|
2017-04-30 22:48:09 +00:00
|
|
|
|
2017-05-01 20:21:54 +00:00
|
|
|
u32 key[5];
|
2017-04-30 22:48:09 +00:00
|
|
|
|
2017-07-09 21:05:14 +00:00
|
|
|
key[0] = ctx.opad.h[0];
|
|
|
|
key[1] = ctx.opad.h[1];
|
|
|
|
key[2] = ctx.opad.h[2];
|
|
|
|
key[3] = ctx.opad.h[3];
|
|
|
|
key[4] = ctx.opad.h[4];
|
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
/* this key is used as password for pbkdf2-hmac-sha1 */
|
2017-04-30 22:48:09 +00:00
|
|
|
|
2017-05-07 00:04:53 +00:00
|
|
|
tmps[gid].userKey[0] = key[0];
|
|
|
|
tmps[gid].userKey[1] = key[1];
|
|
|
|
tmps[gid].userKey[2] = key[2];
|
|
|
|
tmps[gid].userKey[3] = key[3];
|
|
|
|
tmps[gid].userKey[4] = key[4];
|
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
w0[0] = key[0];
|
|
|
|
w0[1] = key[1];
|
|
|
|
w0[2] = key[2];
|
|
|
|
w0[3] = key[3];
|
|
|
|
w1[0] = key[4];
|
|
|
|
w1[1] = 0;
|
|
|
|
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-05-01 20:21:54 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
sha1_hmac_ctx_t sha1_hmac_ctx;
|
2017-05-01 20:21:54 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
sha1_hmac_init_64 (&sha1_hmac_ctx, w0, w1, w2, w3);
|
2017-05-01 20:21:54 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
tmps[gid].ipad[0] = sha1_hmac_ctx.ipad.h[0];
|
|
|
|
tmps[gid].ipad[1] = sha1_hmac_ctx.ipad.h[1];
|
|
|
|
tmps[gid].ipad[2] = sha1_hmac_ctx.ipad.h[2];
|
|
|
|
tmps[gid].ipad[3] = sha1_hmac_ctx.ipad.h[3];
|
|
|
|
tmps[gid].ipad[4] = sha1_hmac_ctx.ipad.h[4];
|
2017-05-01 20:21:54 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
tmps[gid].opad[0] = sha1_hmac_ctx.opad.h[0];
|
|
|
|
tmps[gid].opad[1] = sha1_hmac_ctx.opad.h[1];
|
|
|
|
tmps[gid].opad[2] = sha1_hmac_ctx.opad.h[2];
|
|
|
|
tmps[gid].opad[3] = sha1_hmac_ctx.opad.h[3];
|
|
|
|
tmps[gid].opad[4] = sha1_hmac_ctx.opad.h[4];
|
2017-05-01 20:21:54 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
w0[0] = esalt_bufs[digests_offset].iv[0];
|
|
|
|
w0[1] = esalt_bufs[digests_offset].iv[1];
|
|
|
|
w0[2] = esalt_bufs[digests_offset].iv[2];
|
|
|
|
w0[3] = esalt_bufs[digests_offset].iv[3];
|
|
|
|
w1[0] = 0;
|
|
|
|
w1[1] = 0;
|
|
|
|
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-05-01 20:21:54 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 16);
|
|
|
|
|
|
|
|
for (u32 i = 0, j = 1; i < 8; i += 5, j += 1)
|
|
|
|
{
|
|
|
|
sha1_hmac_ctx_t sha1_hmac_ctx2 = sha1_hmac_ctx;
|
|
|
|
|
|
|
|
w0[0] = j;
|
|
|
|
w0[1] = 0;
|
|
|
|
w0[2] = 0;
|
|
|
|
w0[3] = 0;
|
2017-07-09 21:05:14 +00:00
|
|
|
w1[0] = 0;
|
|
|
|
w1[1] = 0;
|
2017-05-06 14:55:36 +00:00
|
|
|
w1[2] = 0;
|
2017-05-01 20:21:54 +00:00
|
|
|
w1[3] = 0;
|
|
|
|
w2[0] = 0;
|
|
|
|
w2[1] = 0;
|
|
|
|
w2[2] = 0;
|
|
|
|
w2[3] = 0;
|
|
|
|
w3[0] = 0;
|
|
|
|
w3[1] = 0;
|
|
|
|
w3[2] = 0;
|
2017-07-09 21:05:14 +00:00
|
|
|
w3[3] = 0;
|
2017-05-01 20:21:54 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
sha1_hmac_update_64 (&sha1_hmac_ctx2, w0, w1, w2, w3, 4);
|
2017-05-01 20:21:54 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
sha1_hmac_final (&sha1_hmac_ctx2);
|
2017-07-09 21:05:14 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
tmps[gid].dgst[i + 0] = sha1_hmac_ctx2.opad.h[0];
|
|
|
|
tmps[gid].dgst[i + 1] = sha1_hmac_ctx2.opad.h[1];
|
|
|
|
tmps[gid].dgst[i + 2] = sha1_hmac_ctx2.opad.h[2];
|
|
|
|
tmps[gid].dgst[i + 3] = sha1_hmac_ctx2.opad.h[3];
|
|
|
|
tmps[gid].dgst[i + 4] = sha1_hmac_ctx2.opad.h[4];
|
2017-07-09 21:05:14 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0];
|
|
|
|
tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1];
|
|
|
|
tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2];
|
|
|
|
tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3];
|
|
|
|
tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4];
|
|
|
|
}
|
|
|
|
}
|
2017-05-01 20:21:54 +00:00
|
|
|
|
2019-03-22 21:27:58 +00:00
|
|
|
KERNEL_FQ void m15300_loop (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v1_t, dpapimk_t))
|
2017-09-20 17:19:23 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* base
|
|
|
|
*/
|
2017-05-01 20:21:54 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
const u64 gid = get_global_id (0);
|
|
|
|
|
|
|
|
if ((gid * VECT_SIZE) >= gid_max) return;
|
|
|
|
|
|
|
|
u32x ipad[5];
|
|
|
|
u32x opad[5];
|
|
|
|
|
|
|
|
ipad[0] = packv (tmps, ipad, gid, 0);
|
|
|
|
ipad[1] = packv (tmps, ipad, gid, 1);
|
|
|
|
ipad[2] = packv (tmps, ipad, gid, 2);
|
|
|
|
ipad[3] = packv (tmps, ipad, gid, 3);
|
|
|
|
ipad[4] = packv (tmps, ipad, gid, 4);
|
|
|
|
|
|
|
|
opad[0] = packv (tmps, opad, gid, 0);
|
|
|
|
opad[1] = packv (tmps, opad, gid, 1);
|
|
|
|
opad[2] = packv (tmps, opad, gid, 2);
|
|
|
|
opad[3] = packv (tmps, opad, gid, 3);
|
|
|
|
opad[4] = packv (tmps, opad, gid, 4);
|
|
|
|
|
|
|
|
for (u32 i = 0; i < 8; i += 5)
|
2017-07-09 21:05:14 +00:00
|
|
|
{
|
2017-09-20 17:19:23 +00:00
|
|
|
u32x dgst[5];
|
|
|
|
u32x out[5];
|
|
|
|
|
|
|
|
dgst[0] = packv (tmps, dgst, gid, i + 0);
|
|
|
|
dgst[1] = packv (tmps, dgst, gid, i + 1);
|
|
|
|
dgst[2] = packv (tmps, dgst, gid, i + 2);
|
|
|
|
dgst[3] = packv (tmps, dgst, gid, i + 3);
|
|
|
|
dgst[4] = packv (tmps, dgst, gid, i + 4);
|
|
|
|
|
|
|
|
out[0] = packv (tmps, out, gid, i + 0);
|
|
|
|
out[1] = packv (tmps, out, gid, i + 1);
|
|
|
|
out[2] = packv (tmps, out, gid, i + 2);
|
|
|
|
out[3] = packv (tmps, out, gid, i + 3);
|
|
|
|
out[4] = packv (tmps, out, gid, i + 4);
|
|
|
|
|
|
|
|
for (u32 j = 0; j < loop_cnt; j++)
|
2017-07-09 21:05:14 +00:00
|
|
|
{
|
2017-09-20 17:19:23 +00:00
|
|
|
u32x w0[4];
|
|
|
|
u32x w1[4];
|
|
|
|
u32x w2[4];
|
|
|
|
u32x w3[4];
|
|
|
|
|
|
|
|
w0[0] = out[0];
|
|
|
|
w0[1] = out[1];
|
|
|
|
w0[2] = out[2];
|
|
|
|
w0[3] = out[3];
|
|
|
|
w1[0] = out[4];
|
|
|
|
w1[1] = 0x80000000;
|
2017-07-09 21:05:14 +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;
|
2017-09-20 17:19:23 +00:00
|
|
|
w3[3] = (64 + 20) * 8;
|
2017-04-30 22:48:09 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
hmac_sha1_run_V (w0, w1, w2, w3, ipad, opad, dgst);
|
2017-04-30 22:48:09 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
out[0] ^= dgst[0];
|
|
|
|
out[1] ^= dgst[1];
|
|
|
|
out[2] ^= dgst[2];
|
|
|
|
out[3] ^= dgst[3];
|
|
|
|
out[4] ^= dgst[4];
|
2017-07-09 21:05:14 +00:00
|
|
|
}
|
2017-09-20 17:19:23 +00:00
|
|
|
|
|
|
|
unpackv (tmps, dgst, gid, i + 0, dgst[0]);
|
|
|
|
unpackv (tmps, dgst, gid, i + 1, dgst[1]);
|
|
|
|
unpackv (tmps, dgst, gid, i + 2, dgst[2]);
|
|
|
|
unpackv (tmps, dgst, gid, i + 3, dgst[3]);
|
|
|
|
unpackv (tmps, dgst, gid, i + 4, dgst[4]);
|
|
|
|
|
|
|
|
unpackv (tmps, out, gid, i + 0, out[0]);
|
|
|
|
unpackv (tmps, out, gid, i + 1, out[1]);
|
|
|
|
unpackv (tmps, out, gid, i + 2, out[2]);
|
|
|
|
unpackv (tmps, out, gid, i + 3, out[3]);
|
|
|
|
unpackv (tmps, out, gid, i + 4, out[4]);
|
2017-05-01 20:21:54 +00:00
|
|
|
}
|
2017-04-30 22:48:09 +00:00
|
|
|
}
|
|
|
|
|
2019-03-22 21:27:58 +00:00
|
|
|
KERNEL_FQ void m15300_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v1_t, dpapimk_t))
|
2017-04-30 22:48:09 +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);
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-07-09 15:39:38 +00:00
|
|
|
/**
|
|
|
|
* des shared
|
|
|
|
*/
|
|
|
|
|
2019-03-09 07:07:50 +00:00
|
|
|
#ifdef REAL_SHM
|
|
|
|
|
2019-03-22 21:27:58 +00:00
|
|
|
LOCAL_AS u32 s_SPtrans[8][64];
|
|
|
|
LOCAL_AS u32 s_skb[8][64];
|
2017-07-09 15:39:38 +00:00
|
|
|
|
2019-03-03 18:18:56 +00:00
|
|
|
for (u32 i = lid; i < 64; i += lsz)
|
2017-05-06 14:55:36 +00:00
|
|
|
{
|
2017-07-09 15:39:38 +00:00
|
|
|
s_SPtrans[0][i] = c_SPtrans[0][i];
|
|
|
|
s_SPtrans[1][i] = c_SPtrans[1][i];
|
|
|
|
s_SPtrans[2][i] = c_SPtrans[2][i];
|
|
|
|
s_SPtrans[3][i] = c_SPtrans[3][i];
|
|
|
|
s_SPtrans[4][i] = c_SPtrans[4][i];
|
|
|
|
s_SPtrans[5][i] = c_SPtrans[5][i];
|
|
|
|
s_SPtrans[6][i] = c_SPtrans[6][i];
|
|
|
|
s_SPtrans[7][i] = c_SPtrans[7][i];
|
|
|
|
|
|
|
|
s_skb[0][i] = c_skb[0][i];
|
|
|
|
s_skb[1][i] = c_skb[1][i];
|
|
|
|
s_skb[2][i] = c_skb[2][i];
|
|
|
|
s_skb[3][i] = c_skb[3][i];
|
|
|
|
s_skb[4][i] = c_skb[4][i];
|
|
|
|
s_skb[5][i] = c_skb[5][i];
|
|
|
|
s_skb[6][i] = c_skb[6][i];
|
|
|
|
s_skb[7][i] = c_skb[7][i];
|
|
|
|
}
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-07-09 15:39:38 +00:00
|
|
|
barrier (CLK_LOCAL_MEM_FENCE);
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2019-03-09 07:07:50 +00:00
|
|
|
#else
|
|
|
|
|
2019-03-22 21:27:58 +00:00
|
|
|
CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans;
|
|
|
|
CONSTANT_AS u32a (*s_skb)[64] = c_skb;
|
2019-03-09 07:07:50 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2017-07-09 15:39:38 +00:00
|
|
|
if (gid >= gid_max) return;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* main
|
|
|
|
*/
|
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
u32 w0[4];
|
|
|
|
u32 w1[4];
|
|
|
|
u32 w2[4];
|
|
|
|
u32 w3[4];
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
u32 key[6];
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2019-03-23 21:15:38 +00:00
|
|
|
key[0] = hc_swap32_S (tmps[gid].out[0]);
|
|
|
|
key[1] = hc_swap32_S (tmps[gid].out[1]);
|
|
|
|
key[2] = hc_swap32_S (tmps[gid].out[2]);
|
|
|
|
key[3] = hc_swap32_S (tmps[gid].out[3]);
|
|
|
|
key[4] = hc_swap32_S (tmps[gid].out[4]);
|
|
|
|
key[5] = hc_swap32_S (tmps[gid].out[5]);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
u32 iv[2];
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2019-03-23 21:15:38 +00:00
|
|
|
iv[0] = hc_swap32_S (tmps[gid].out[6]);
|
|
|
|
iv[1] = hc_swap32_S (tmps[gid].out[7]);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
u32 decrypted[26];
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
/* Construct 3DES keys */
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
const u32 a = (key[0]);
|
|
|
|
const u32 b = (key[1]);
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
u32 Ka[16];
|
|
|
|
u32 Kb[16];
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
_des_crypt_keysetup (a, b, Ka, Kb, s_skb);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
const u32 c = (key[2]);
|
|
|
|
const u32 d = (key[3]);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
u32 Kc[16];
|
|
|
|
u32 Kd[16];
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
_des_crypt_keysetup (c, d, Kc, Kd, s_skb);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
const u32 e = (key[4]);
|
|
|
|
const u32 f = (key[5]);
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
u32 Ke[16];
|
|
|
|
u32 Kf[16];
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
_des_crypt_keysetup (e, f, Ke, Kf, s_skb);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
u32 contents_pos;
|
|
|
|
u32 contents_off;
|
|
|
|
u32 wx_off;
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
for (wx_off = 0, contents_pos = 0, contents_off = 0; contents_pos < esalt_bufs[digests_offset].contents_len; wx_off += 2, contents_pos += 8, contents_off += 2)
|
|
|
|
{
|
|
|
|
/* First Pass */
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
u32 data[2];
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2019-03-23 21:15:38 +00:00
|
|
|
data[0] = hc_swap32_S (esalt_bufs[digests_offset].contents[contents_off + 0]);
|
|
|
|
data[1] = hc_swap32_S (esalt_bufs[digests_offset].contents[contents_off + 1]);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
u32 p1[2];
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
_des_crypt_decrypt (p1, data, Ke, Kf, s_SPtrans);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
/* Second Pass */
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
u32 p2[2];
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
_des_crypt_encrypt (p2, p1, Kc, Kd, s_SPtrans);
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
/* Third Pass */
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
u32 out[2];
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
_des_crypt_decrypt (out, p2, Ka, Kb, s_SPtrans);
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
out[0] ^= iv[0];
|
|
|
|
out[1] ^= iv[1];
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
decrypted[wx_off + 0] = out[0];
|
|
|
|
decrypted[wx_off + 1] = out[1];
|
2017-05-06 14:55:36 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
iv[0] = data[0];
|
|
|
|
iv[1] = data[1];
|
2017-05-06 14:55:36 +00:00
|
|
|
}
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
u32 hmacSalt[4];
|
|
|
|
u32 expectedHmac[4];
|
|
|
|
u32 lastKey[16];
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2019-03-23 21:15:38 +00:00
|
|
|
hmacSalt[0] = hc_swap32_S (decrypted[0]);
|
|
|
|
hmacSalt[1] = hc_swap32_S (decrypted[1]);
|
|
|
|
hmacSalt[2] = hc_swap32_S (decrypted[2]);
|
|
|
|
hmacSalt[3] = hc_swap32_S (decrypted[3]);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2019-03-23 21:15:38 +00:00
|
|
|
expectedHmac[0] = hc_swap32_S (decrypted[4 + 0]);
|
|
|
|
expectedHmac[1] = hc_swap32_S (decrypted[4 + 1]);
|
|
|
|
expectedHmac[2] = hc_swap32_S (decrypted[4 + 2]);
|
|
|
|
expectedHmac[3] = hc_swap32_S (decrypted[4 + 3]);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
for(int i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
lastKey[i] = decrypted[i + 26 - 16];
|
|
|
|
}
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
w0[0] = tmps[gid].userKey[0];
|
|
|
|
w0[1] = tmps[gid].userKey[1];
|
|
|
|
w0[2] = tmps[gid].userKey[2];
|
|
|
|
w0[3] = tmps[gid].userKey[3];
|
|
|
|
w1[0] = tmps[gid].userKey[4];
|
|
|
|
w1[1] = 0;
|
|
|
|
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-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
sha1_hmac_ctx_t ctx;
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
sha1_hmac_init_64 (&ctx, w0, w1, w2, w3);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
w0[0] = hmacSalt[0];
|
|
|
|
w0[1] = hmacSalt[1];
|
|
|
|
w0[2] = hmacSalt[2];
|
|
|
|
w0[3] = hmacSalt[3];
|
|
|
|
w1[0] = 0;
|
|
|
|
w1[1] = 0;
|
|
|
|
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-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
sha1_hmac_update_64 (&ctx, w0, w1, w2, w3, 16);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
sha1_hmac_final (&ctx);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
w0[0] = ctx.opad.h[0];
|
|
|
|
w0[1] = ctx.opad.h[1];
|
|
|
|
w0[2] = ctx.opad.h[2];
|
|
|
|
w0[3] = ctx.opad.h[3];
|
|
|
|
w1[0] = ctx.opad.h[4];
|
|
|
|
w1[1] = 0;
|
|
|
|
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-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
sha1_hmac_init_64 (&ctx, w0, w1, w2, w3);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2019-03-23 21:15:38 +00:00
|
|
|
w0[0] = hc_swap32_S (lastKey[ 0]);
|
|
|
|
w0[1] = hc_swap32_S (lastKey[ 1]);
|
|
|
|
w0[2] = hc_swap32_S (lastKey[ 2]);
|
|
|
|
w0[3] = hc_swap32_S (lastKey[ 3]);
|
|
|
|
w1[0] = hc_swap32_S (lastKey[ 4]);
|
|
|
|
w1[1] = hc_swap32_S (lastKey[ 5]);
|
|
|
|
w1[2] = hc_swap32_S (lastKey[ 6]);
|
|
|
|
w1[3] = hc_swap32_S (lastKey[ 7]);
|
|
|
|
w2[0] = hc_swap32_S (lastKey[ 8]);
|
|
|
|
w2[1] = hc_swap32_S (lastKey[ 9]);
|
|
|
|
w2[2] = hc_swap32_S (lastKey[10]);
|
|
|
|
w2[3] = hc_swap32_S (lastKey[11]);
|
|
|
|
w3[0] = hc_swap32_S (lastKey[12]);
|
|
|
|
w3[1] = hc_swap32_S (lastKey[13]);
|
|
|
|
w3[2] = hc_swap32_S (lastKey[14]);
|
|
|
|
w3[3] = hc_swap32_S (lastKey[15]);
|
2017-09-20 17:19:23 +00:00
|
|
|
|
|
|
|
sha1_hmac_update_64 (&ctx, w0, w1, w2, w3, 64);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
sha1_hmac_final (&ctx);
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
#define il_pos 0
|
2017-05-07 00:04:53 +00:00
|
|
|
|
2017-09-20 17:19:23 +00:00
|
|
|
if ((expectedHmac[0] == ctx.opad.h[0])
|
|
|
|
&& (expectedHmac[1] == ctx.opad.h[1])
|
|
|
|
&& (expectedHmac[2] == ctx.opad.h[2])
|
|
|
|
&& (expectedHmac[3] == ctx.opad.h[3]))
|
|
|
|
{
|
|
|
|
if (atomic_inc (&hashes_shown[digests_offset]) == 0)
|
2017-05-06 14:55:36 +00:00
|
|
|
{
|
2019-03-15 20:48:49 +00:00
|
|
|
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0);
|
2017-05-06 14:55:36 +00:00
|
|
|
}
|
|
|
|
}
|
2017-04-30 22:48:09 +00:00
|
|
|
}
|