1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-02-21 03:52:09 +00:00

Converted to new SIMD: -m 3100 -a 0

This commit is contained in:
Jens Steube 2016-02-05 21:44:23 +01:00
parent ffab75a8d4
commit ceb96a7735

View File

@ -7,6 +7,8 @@
#define _DES_ #define _DES_
#define NEW_SIMD_CODE
#include "include/constants.h" #include "include/constants.h"
#include "include/kernel_vendor.h" #include "include/kernel_vendor.h"
@ -20,9 +22,7 @@
#include "OpenCL/common.c" #include "OpenCL/common.c"
#include "include/rp_kernel.h" #include "include/rp_kernel.h"
#include "OpenCL/rp.c" #include "OpenCL/rp.c"
#include "OpenCL/simd.c"
#define COMPARE_S "OpenCL/check_single_comp4.c"
#define COMPARE_M "OpenCL/check_multi_comp4.c"
#define PERM_OP(a,b,tt,n,m) \ #define PERM_OP(a,b,tt,n,m) \
{ \ { \
@ -368,12 +368,12 @@ __constant u32 c_skb[8][64] =
#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7]) #define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7])
#endif #endif
static void _des_crypt_encrypt (u32 iv[2], u32 data[2], u32 Kc[16], u32 Kd[16], __local u32 (*s_SPtrans)[64]) static void _des_crypt_encrypt (u32x iv[2], u32x data[2], u32x Kc[16], u32x Kd[16], __local u32 (*s_SPtrans)[64])
{ {
u32 tt; u32x tt;
u32 r = data[0]; u32x r = data[0];
u32 l = data[1]; u32x l = data[1];
IP (r, l, tt); IP (r, l, tt);
@ -383,8 +383,8 @@ static void _des_crypt_encrypt (u32 iv[2], u32 data[2], u32 Kc[16], u32 Kd[16],
#pragma unroll 16 #pragma unroll 16
for (u32 i = 0; i < 16; i += 2) for (u32 i = 0; i < 16; i += 2)
{ {
u32 u; u32x u;
u32 t; u32x t;
u = Kc[i + 0] ^ r; u = Kc[i + 0] ^ r;
t = Kd[i + 0] ^ rotl32 (r, 28u); t = Kd[i + 0] ^ rotl32 (r, 28u);
@ -420,9 +420,9 @@ static void _des_crypt_encrypt (u32 iv[2], u32 data[2], u32 Kc[16], u32 Kd[16],
iv[1] = r; iv[1] = r;
} }
static void _des_crypt_keysetup (u32 c, u32 d, u32 Kc[16], u32 Kd[16], __local u32 (*s_skb)[64]) static void _des_crypt_keysetup (u32x c, u32x d, u32x Kc[16], u32x Kd[16], __local u32 (*s_skb)[64])
{ {
u32 tt; u32x tt;
PERM_OP (d, c, tt, 4, 0x0f0f0f0f); PERM_OP (d, c, tt, 4, 0x0f0f0f0f);
HPERM_OP (c, tt, 2, 0xcccc0000); HPERM_OP (c, tt, 2, 0xcccc0000);
@ -455,13 +455,13 @@ static void _des_crypt_keysetup (u32 c, u32 d, u32 Kc[16], u32 Kd[16], __local u
c = c & 0x0fffffff; c = c & 0x0fffffff;
d = d & 0x0fffffff; d = d & 0x0fffffff;
const u32 c00 = (c >> 0) & 0x0000003f; const u32x c00 = (c >> 0) & 0x0000003f;
const u32 c06 = (c >> 6) & 0x00383003; const u32x c06 = (c >> 6) & 0x00383003;
const u32 c07 = (c >> 7) & 0x0000003c; const u32x c07 = (c >> 7) & 0x0000003c;
const u32 c13 = (c >> 13) & 0x0000060f; const u32x c13 = (c >> 13) & 0x0000060f;
const u32 c20 = (c >> 20) & 0x00000001; const u32x c20 = (c >> 20) & 0x00000001;
u32 s = BOX (((c00 >> 0) & 0xff), 0, s_skb) u32x s = BOX (((c00 >> 0) & 0xff), 0, s_skb)
| BOX (((c06 >> 0) & 0xff) | BOX (((c06 >> 0) & 0xff)
|((c07 >> 0) & 0xff), 1, s_skb) |((c07 >> 0) & 0xff), 1, s_skb)
| BOX (((c13 >> 0) & 0xff) | BOX (((c13 >> 0) & 0xff)
@ -470,12 +470,12 @@ static void _des_crypt_keysetup (u32 c, u32 d, u32 Kc[16], u32 Kd[16], __local u
|((c13 >> 8) & 0xff) |((c13 >> 8) & 0xff)
|((c06 >> 16) & 0xff), 3, s_skb); |((c06 >> 16) & 0xff), 3, s_skb);
const u32 d00 = (d >> 0) & 0x00003c3f; const u32x d00 = (d >> 0) & 0x00003c3f;
const u32 d07 = (d >> 7) & 0x00003f03; const u32x d07 = (d >> 7) & 0x00003f03;
const u32 d21 = (d >> 21) & 0x0000000f; const u32x d21 = (d >> 21) & 0x0000000f;
const u32 d22 = (d >> 22) & 0x00000030; const u32x d22 = (d >> 22) & 0x00000030;
u32 t = BOX (((d00 >> 0) & 0xff), 4, s_skb) u32x t = BOX (((d00 >> 0) & 0xff), 4, s_skb)
| BOX (((d07 >> 0) & 0xff) | BOX (((d07 >> 0) & 0xff)
|((d00 >> 8) & 0xff), 5, s_skb) |((d00 >> 8) & 0xff), 5, s_skb)
| BOX (((d07 >> 8) & 0xff), 6, s_skb) | BOX (((d07 >> 8) & 0xff), 6, s_skb)
@ -576,37 +576,14 @@ __kernel void m03100_m04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
* loop * loop
*/ */
for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++) for (u32 il_pos = 0; il_pos < rules_cnt; il_pos += VECT_SIZE)
{ {
u32 w0[4]; u32x w0[4] = { 0 };
u32x w1[4] = { 0 };
u32x w2[4] = { 0 };
u32x w3[4] = { 0 };
w0[0] = pw_buf0[0]; const u32 out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
w0[1] = pw_buf0[1];
w0[2] = pw_buf0[2];
w0[3] = pw_buf0[3];
u32 w1[4];
w1[0] = pw_buf1[0];
w1[1] = pw_buf1[1];
w1[2] = pw_buf1[2];
w1[3] = pw_buf1[3];
u32 w2[4];
w2[0] = 0;
w2[1] = 0;
w2[2] = 0;
w2[3] = 0;
u32 w3[4];
w3[0] = 0;
w3[1] = 0;
w3[2] = 0;
w3[3] = 0;
const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
const u32 salt_word_len = (salt_len + out_len) * 2; const u32 salt_word_len = (salt_len + out_len) * 2;
@ -614,28 +591,28 @@ __kernel void m03100_m04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
* prepend salt * prepend salt
*/ */
u32 w0_t[4]; u32x w0_t[4];
w0_t[0] = w0[0]; w0_t[0] = w0[0];
w0_t[1] = w0[1]; w0_t[1] = w0[1];
w0_t[2] = w0[2]; w0_t[2] = w0[2];
w0_t[3] = w0[3]; w0_t[3] = w0[3];
u32 w1_t[4]; u32x w1_t[4];
w1_t[0] = w1[0]; w1_t[0] = w1[0];
w1_t[1] = w1[1]; w1_t[1] = w1[1];
w1_t[2] = w1[2]; w1_t[2] = w1[2];
w1_t[3] = w1[3]; w1_t[3] = w1[3];
u32 w2_t[4]; u32x w2_t[4];
w2_t[0] = w2[0]; w2_t[0] = w2[0];
w2_t[1] = w2[1]; w2_t[1] = w2[1];
w2_t[2] = w2[2]; w2_t[2] = w2[2];
w2_t[3] = w2[3]; w2_t[3] = w2[3];
u32 w3_t[4]; u32x w3_t[4];
w3_t[0] = w3[0]; w3_t[0] = w3[0];
w3_t[1] = w3[1]; w3_t[1] = w3[1];
@ -653,7 +630,7 @@ __kernel void m03100_m04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
w1_t[2] |= salt_buf1[2]; w1_t[2] |= salt_buf1[2];
w1_t[3] |= salt_buf1[3]; w1_t[3] |= salt_buf1[3];
u32 dst[16]; u32x dst[16];
dst[ 0] = w0_t[0]; dst[ 0] = w0_t[0];
dst[ 1] = w0_t[1]; dst[ 1] = w0_t[1];
@ -677,7 +654,7 @@ __kernel void m03100_m04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
* plus LEFT_ROTATE by 2 * plus LEFT_ROTATE by 2
*/ */
u32 Kc[16]; u32x Kc[16];
Kc[ 0] = 0x64649040; Kc[ 0] = 0x64649040;
Kc[ 1] = 0x14909858; Kc[ 1] = 0x14909858;
@ -696,7 +673,7 @@ __kernel void m03100_m04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
Kc[14] = 0x584020b4; Kc[14] = 0x584020b4;
Kc[15] = 0x00742c4c; Kc[15] = 0x00742c4c;
u32 Kd[16]; u32x Kd[16];
Kd[ 0] = 0xa42ce40c; Kd[ 0] = 0xa42ce40c;
Kd[ 1] = 0x64689858; Kd[ 1] = 0x64689858;
@ -719,14 +696,14 @@ __kernel void m03100_m04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
* key1 (generate key) * key1 (generate key)
*/ */
u32 iv[2]; u32x iv[2];
iv[0] = 0; iv[0] = 0;
iv[1] = 0; iv[1] = 0;
for (u32 j = 0, k = 0; j < salt_word_len; j += 8, k++) for (u32 j = 0, k = 0; j < salt_word_len; j += 8, k++)
{ {
u32 data[2]; u32x data[2];
data[0] = ((dst[k] << 16) & 0xff000000) | ((dst[k] << 8) & 0x0000ff00); data[0] = ((dst[k] << 16) & 0xff000000) | ((dst[k] << 8) & 0x0000ff00);
data[1] = ((dst[k] >> 0) & 0xff000000) | ((dst[k] >> 8) & 0x0000ff00); data[1] = ((dst[k] >> 0) & 0xff000000) | ((dst[k] >> 8) & 0x0000ff00);
@ -748,7 +725,7 @@ __kernel void m03100_m04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
for (u32 j = 0, k = 0; j < salt_word_len; j += 8, k++) for (u32 j = 0, k = 0; j < salt_word_len; j += 8, k++)
{ {
u32 data[2]; u32x data[2];
data[0] = ((dst[k] << 16) & 0xff000000) | ((dst[k] << 8) & 0x0000ff00); data[0] = ((dst[k] << 16) & 0xff000000) | ((dst[k] << 8) & 0x0000ff00);
data[1] = ((dst[k] >> 0) & 0xff000000) | ((dst[k] >> 8) & 0x0000ff00); data[1] = ((dst[k] >> 0) & 0xff000000) | ((dst[k] >> 8) & 0x0000ff00);
@ -763,12 +740,12 @@ __kernel void m03100_m04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
* cmp * cmp
*/ */
const u32 r0 = iv[0]; const u32x r0 = iv[0];
const u32 r1 = iv[1]; const u32x r1 = iv[1];
const u32 r2 = 0; const u32x r2 = 0;
const u32 r3 = 0; const u32x r3 = 0;
#include COMPARE_M COMPARE_M_SIMD (r0, r1, r2, r3);
} }
} }
@ -878,37 +855,14 @@ __kernel void m03100_s04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
* loop * loop
*/ */
for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++) for (u32 il_pos = 0; il_pos < rules_cnt; il_pos += VECT_SIZE)
{ {
u32 w0[4]; u32x w0[4] = { 0 };
u32x w1[4] = { 0 };
u32x w2[4] = { 0 };
u32x w3[4] = { 0 };
w0[0] = pw_buf0[0]; const u32 out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
w0[1] = pw_buf0[1];
w0[2] = pw_buf0[2];
w0[3] = pw_buf0[3];
u32 w1[4];
w1[0] = pw_buf1[0];
w1[1] = pw_buf1[1];
w1[2] = pw_buf1[2];
w1[3] = pw_buf1[3];
u32 w2[4];
w2[0] = 0;
w2[1] = 0;
w2[2] = 0;
w2[3] = 0;
u32 w3[4];
w3[0] = 0;
w3[1] = 0;
w3[2] = 0;
w3[3] = 0;
const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
const u32 salt_word_len = (salt_len + out_len) * 2; const u32 salt_word_len = (salt_len + out_len) * 2;
@ -916,28 +870,28 @@ __kernel void m03100_s04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
* prepend salt * prepend salt
*/ */
u32 w0_t[4]; u32x w0_t[4];
w0_t[0] = w0[0]; w0_t[0] = w0[0];
w0_t[1] = w0[1]; w0_t[1] = w0[1];
w0_t[2] = w0[2]; w0_t[2] = w0[2];
w0_t[3] = w0[3]; w0_t[3] = w0[3];
u32 w1_t[4]; u32x w1_t[4];
w1_t[0] = w1[0]; w1_t[0] = w1[0];
w1_t[1] = w1[1]; w1_t[1] = w1[1];
w1_t[2] = w1[2]; w1_t[2] = w1[2];
w1_t[3] = w1[3]; w1_t[3] = w1[3];
u32 w2_t[4]; u32x w2_t[4];
w2_t[0] = w2[0]; w2_t[0] = w2[0];
w2_t[1] = w2[1]; w2_t[1] = w2[1];
w2_t[2] = w2[2]; w2_t[2] = w2[2];
w2_t[3] = w2[3]; w2_t[3] = w2[3];
u32 w3_t[4]; u32x w3_t[4];
w3_t[0] = w3[0]; w3_t[0] = w3[0];
w3_t[1] = w3[1]; w3_t[1] = w3[1];
@ -955,7 +909,7 @@ __kernel void m03100_s04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
w1_t[2] |= salt_buf1[2]; w1_t[2] |= salt_buf1[2];
w1_t[3] |= salt_buf1[3]; w1_t[3] |= salt_buf1[3];
u32 dst[16]; u32x dst[16];
dst[ 0] = w0_t[0]; dst[ 0] = w0_t[0];
dst[ 1] = w0_t[1]; dst[ 1] = w0_t[1];
@ -979,7 +933,7 @@ __kernel void m03100_s04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
* plus LEFT_ROTATE by 2 * plus LEFT_ROTATE by 2
*/ */
u32 Kc[16]; u32x Kc[16];
Kc[ 0] = 0x64649040; Kc[ 0] = 0x64649040;
Kc[ 1] = 0x14909858; Kc[ 1] = 0x14909858;
@ -998,7 +952,7 @@ __kernel void m03100_s04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
Kc[14] = 0x584020b4; Kc[14] = 0x584020b4;
Kc[15] = 0x00742c4c; Kc[15] = 0x00742c4c;
u32 Kd[16]; u32x Kd[16];
Kd[ 0] = 0xa42ce40c; Kd[ 0] = 0xa42ce40c;
Kd[ 1] = 0x64689858; Kd[ 1] = 0x64689858;
@ -1021,14 +975,14 @@ __kernel void m03100_s04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
* key1 (generate key) * key1 (generate key)
*/ */
u32 iv[2]; u32x iv[2];
iv[0] = 0; iv[0] = 0;
iv[1] = 0; iv[1] = 0;
for (u32 j = 0, k = 0; j < salt_word_len; j += 8, k++) for (u32 j = 0, k = 0; j < salt_word_len; j += 8, k++)
{ {
u32 data[2]; u32x data[2];
data[0] = ((dst[k] << 16) & 0xff000000) | ((dst[k] << 8) & 0x0000ff00); data[0] = ((dst[k] << 16) & 0xff000000) | ((dst[k] << 8) & 0x0000ff00);
data[1] = ((dst[k] >> 0) & 0xff000000) | ((dst[k] >> 8) & 0x0000ff00); data[1] = ((dst[k] >> 0) & 0xff000000) | ((dst[k] >> 8) & 0x0000ff00);
@ -1050,7 +1004,7 @@ __kernel void m03100_s04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
for (u32 j = 0, k = 0; j < salt_word_len; j += 8, k++) for (u32 j = 0, k = 0; j < salt_word_len; j += 8, k++)
{ {
u32 data[2]; u32x data[2];
data[0] = ((dst[k] << 16) & 0xff000000) | ((dst[k] << 8) & 0x0000ff00); data[0] = ((dst[k] << 16) & 0xff000000) | ((dst[k] << 8) & 0x0000ff00);
data[1] = ((dst[k] >> 0) & 0xff000000) | ((dst[k] >> 8) & 0x0000ff00); data[1] = ((dst[k] >> 0) & 0xff000000) | ((dst[k] >> 8) & 0x0000ff00);
@ -1065,12 +1019,12 @@ __kernel void m03100_s04 (__global pw_t *pws, __global kernel_rule_t * rules_bu
* cmp * cmp
*/ */
const u32 r0 = iv[0]; const u32x r0 = iv[0];
const u32 r1 = iv[1]; const u32x r1 = iv[1];
const u32 r2 = 0; const u32x r2 = 0;
const u32 r3 = 0; const u32x r3 = 0;
#include COMPARE_S COMPARE_M_SIMD (r0, r1, r2, r3);
} }
} }