From 5920bd7f782fb24bf4a1f92dc31b828beac6df26 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Thu, 6 Jun 2019 15:02:22 +0200 Subject: [PATCH] Speed up -m 19300 in general --- OpenCL/m19300_a0-pure.cl | 38 ++++++++++++++------------------------ OpenCL/m19300_a1-pure.cl | 22 ++-------------------- OpenCL/m19300_a3-pure.cl | 34 ++++++++++++++-------------------- 3 files changed, 30 insertions(+), 64 deletions(-) diff --git a/OpenCL/m19300_a0-pure.cl b/OpenCL/m19300_a0-pure.cl index eebb953d6..e646d1d50 100644 --- a/OpenCL/m19300_a0-pure.cl +++ b/OpenCL/m19300_a0-pure.cl @@ -43,22 +43,21 @@ KERNEL_FQ void m19300_mxx (KERN_ATTR_RULES_ESALT (sha1_double_salt_t)) COPY_PW (pws[gid]); - const int salt1_len = esalt_bufs[digests_offset].salt1_len; const int salt2_len = esalt_bufs[digests_offset].salt2_len; - u32 s1[64] = { 0 }; u32 s2[64] = { 0 }; - for (int i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) - { - s1[idx] = hc_swap32_S (esalt_bufs[digests_offset].salt1_buf[idx]); - } - for (int i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) { s2[idx] = hc_swap32_S (esalt_bufs[digests_offset].salt2_buf[idx]); } + sha1_ctx_t ctx0; + + sha1_init (&ctx0); + + sha1_update_global_swap (&ctx0, esalt_bufs[digests_offset].salt1_buf, esalt_bufs[digests_offset].salt1_len); + /** * loop */ @@ -69,11 +68,7 @@ KERNEL_FQ void m19300_mxx (KERN_ATTR_RULES_ESALT (sha1_double_salt_t)) tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); - sha1_ctx_t ctx; - - sha1_init (&ctx); - - sha1_update (&ctx, s1, salt1_len); + sha1_ctx_t ctx = ctx0; sha1_update_swap (&ctx, tmp.i, tmp.pw_len); @@ -119,22 +114,21 @@ KERNEL_FQ void m19300_sxx (KERN_ATTR_RULES_ESALT (sha1_double_salt_t)) COPY_PW (pws[gid]); - const int salt1_len = esalt_bufs[digests_offset].salt1_len; const int salt2_len = esalt_bufs[digests_offset].salt2_len; - u32 s1[64] = { 0 }; u32 s2[64] = { 0 }; - for (int i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) - { - s1[idx] = hc_swap32_S (esalt_bufs[digests_offset].salt1_buf[idx]); - } - for (int i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) { s2[idx] = hc_swap32_S (esalt_bufs[digests_offset].salt2_buf[idx]); } + sha1_ctx_t ctx0; + + sha1_init (&ctx0); + + sha1_update_global_swap (&ctx0, esalt_bufs[digests_offset].salt1_buf, esalt_bufs[digests_offset].salt1_len); + /** * loop */ @@ -145,11 +139,7 @@ KERNEL_FQ void m19300_sxx (KERN_ATTR_RULES_ESALT (sha1_double_salt_t)) tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); - sha1_ctx_t ctx; - - sha1_init (&ctx); - - sha1_update (&ctx, s1, salt1_len); + sha1_ctx_t ctx = ctx0; sha1_update_swap (&ctx, tmp.i, tmp.pw_len); diff --git a/OpenCL/m19300_a1-pure.cl b/OpenCL/m19300_a1-pure.cl index 0e11ddb18..f11cbb77f 100644 --- a/OpenCL/m19300_a1-pure.cl +++ b/OpenCL/m19300_a1-pure.cl @@ -39,19 +39,10 @@ KERNEL_FQ void m19300_mxx (KERN_ATTR_ESALT (sha1_double_salt_t)) * base */ - const u32 salt_len = salt_bufs[salt_pos].salt_len; - - const int salt1_len = esalt_bufs[digests_offset].salt1_len; const int salt2_len = esalt_bufs[digests_offset].salt2_len; - u32 s1[64] = { 0 }; u32 s2[64] = { 0 }; - for (int i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) - { - s1[idx] = hc_swap32_S (esalt_bufs[digests_offset].salt1_buf[idx]); - } - for (int i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) { s2[idx] = hc_swap32_S (esalt_bufs[digests_offset].salt2_buf[idx]); @@ -61,7 +52,7 @@ KERNEL_FQ void m19300_mxx (KERN_ATTR_ESALT (sha1_double_salt_t)) sha1_init (&ctx0); - sha1_update (&ctx0, s1, salt1_len); + sha1_update_global_swap (&ctx0, esalt_bufs[digests_offset].salt1_buf, esalt_bufs[digests_offset].salt1_len); sha1_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); @@ -115,19 +106,10 @@ KERNEL_FQ void m19300_sxx (KERN_ATTR_ESALT (sha1_double_salt_t)) * base */ - const u32 salt_len = salt_bufs[salt_pos].salt_len; - - const int salt1_len = esalt_bufs[digests_offset].salt1_len; const int salt2_len = esalt_bufs[digests_offset].salt2_len; - u32 s1[64] = { 0 }; u32 s2[64] = { 0 }; - for (int i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) - { - s1[idx] = hc_swap32_S (esalt_bufs[digests_offset].salt1_buf[idx]); - } - for (int i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) { s2[idx] = hc_swap32_S (esalt_bufs[digests_offset].salt2_buf[idx]); @@ -137,7 +119,7 @@ KERNEL_FQ void m19300_sxx (KERN_ATTR_ESALT (sha1_double_salt_t)) sha1_init (&ctx0); - sha1_update (&ctx0, s1, salt1_len); + sha1_update_global_swap (&ctx0, esalt_bufs[digests_offset].salt1_buf, esalt_bufs[digests_offset].salt1_len); sha1_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); diff --git a/OpenCL/m19300_a3-pure.cl b/OpenCL/m19300_a3-pure.cl index fc715f841..ef74edf0d 100644 --- a/OpenCL/m19300_a3-pure.cl +++ b/OpenCL/m19300_a3-pure.cl @@ -48,22 +48,21 @@ KERNEL_FQ void m19300_mxx (KERN_ATTR_VECTOR_ESALT (sha1_double_salt_t)) w[idx] = pws[gid].i[idx]; } - const int salt1_len = esalt_bufs[digests_offset].salt1_len; const int salt2_len = esalt_bufs[digests_offset].salt2_len; - u32x s1[64] = { 0 }; u32x s2[64] = { 0 }; - for (int i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) - { - s1[idx] = hc_swap32_S (esalt_bufs[digests_offset].salt1_buf[idx]); - } - for (int i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) { s2[idx] = hc_swap32_S (esalt_bufs[digests_offset].salt2_buf[idx]); } + sha1_ctx_t ctx0; + + sha1_init (&ctx0); + + sha1_update_global_swap (&ctx0, esalt_bufs[digests_offset].salt1_buf, esalt_bufs[digests_offset].salt1_len); + /** * loop */ @@ -80,9 +79,7 @@ KERNEL_FQ void m19300_mxx (KERN_ATTR_VECTOR_ESALT (sha1_double_salt_t)) sha1_ctx_vector_t ctx; - sha1_init_vector (&ctx); - - sha1_update_vector (&ctx, s1, salt1_len); + sha1_init_vector_from_scalar (&ctx, &ctx0); sha1_update_vector (&ctx, w, pw_len); @@ -135,22 +132,21 @@ KERNEL_FQ void m19300_sxx (KERN_ATTR_VECTOR_ESALT (sha1_double_salt_t)) w[idx] = pws[gid].i[idx]; } - const int salt1_len = esalt_bufs[digests_offset].salt1_len; const int salt2_len = esalt_bufs[digests_offset].salt2_len; - u32x s1[64] = { 0 }; u32x s2[64] = { 0 }; - for (int i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) - { - s1[idx] = hc_swap32_S (esalt_bufs[digests_offset].salt1_buf[idx]); - } - for (int i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) { s2[idx] = hc_swap32_S (esalt_bufs[digests_offset].salt2_buf[idx]); } + sha1_ctx_t ctx0; + + sha1_init (&ctx0); + + sha1_update_global_swap (&ctx0, esalt_bufs[digests_offset].salt1_buf, esalt_bufs[digests_offset].salt1_len); + /** * loop */ @@ -167,9 +163,7 @@ KERNEL_FQ void m19300_sxx (KERN_ATTR_VECTOR_ESALT (sha1_double_salt_t)) sha1_ctx_vector_t ctx; - sha1_init_vector (&ctx); - - sha1_update_vector (&ctx, s1, salt1_len); + sha1_init_vector_from_scalar (&ctx, &ctx0); sha1_update_vector (&ctx, w, pw_len);