From f2c69ecfe515cad5ac660f0f37dc96b7527d31be Mon Sep 17 00:00:00 2001 From: Matt Palmer Date: Sat, 25 Apr 2020 16:04:20 +1000 Subject: [PATCH] Add md5_update_vector_from_scalar This is similar in concept to *_init_v_f_s, except that all contexts in the vector are updated from the same scalar array of data. --- OpenCL/inc_hash_md5.cl | 52 ++++++++++++++++++++++++++++++++++++++++++ OpenCL/inc_hash_md5.h | 1 + 2 files changed, 53 insertions(+) diff --git a/OpenCL/inc_hash_md5.cl b/OpenCL/inc_hash_md5.cl index 3c52c1f40..7e18a735f 100644 --- a/OpenCL/inc_hash_md5.cl +++ b/OpenCL/inc_hash_md5.cl @@ -1486,6 +1486,58 @@ DECLSPEC void md5_update_vector (md5_ctx_vector_t *ctx, const u32x *w, const int md5_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void md5_update_vector_from_scalar (md5_ctx_vector_t *ctx, const u32 *w, const int len) +{ + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + int pos1; + int pos4; + + for (pos1 = 0, pos4 = 0; pos1 < len - 64; pos1 += 64, pos4 += 16) + { + w0[0] = w[pos4 + 0]; + w0[1] = w[pos4 + 1]; + w0[2] = w[pos4 + 2]; + w0[3] = w[pos4 + 3]; + w1[0] = w[pos4 + 4]; + w1[1] = w[pos4 + 5]; + w1[2] = w[pos4 + 6]; + w1[3] = w[pos4 + 7]; + w2[0] = w[pos4 + 8]; + w2[1] = w[pos4 + 9]; + w2[2] = w[pos4 + 10]; + w2[3] = w[pos4 + 11]; + w3[0] = w[pos4 + 12]; + w3[1] = w[pos4 + 13]; + w3[2] = w[pos4 + 14]; + w3[3] = w[pos4 + 15]; + + md5_update_vector_64 (ctx, w0, w1, w2, w3, 64); + } + + w0[0] = w[pos4 + 0]; + w0[1] = w[pos4 + 1]; + w0[2] = w[pos4 + 2]; + w0[3] = w[pos4 + 3]; + w1[0] = w[pos4 + 4]; + w1[1] = w[pos4 + 5]; + w1[2] = w[pos4 + 6]; + w1[3] = w[pos4 + 7]; + w2[0] = w[pos4 + 8]; + w2[1] = w[pos4 + 9]; + w2[2] = w[pos4 + 10]; + w2[3] = w[pos4 + 11]; + w3[0] = w[pos4 + 12]; + w3[1] = w[pos4 + 13]; + w3[2] = w[pos4 + 14]; + w3[3] = w[pos4 + 15]; + + md5_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); +} + DECLSPEC void md5_update_vector_swap (md5_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; diff --git a/OpenCL/inc_hash_md5.h b/OpenCL/inc_hash_md5.h index 1e6eaaf93..8b37d6969 100644 --- a/OpenCL/inc_hash_md5.h +++ b/OpenCL/inc_hash_md5.h @@ -121,6 +121,7 @@ DECLSPEC void md5_init_vector (md5_ctx_vector_t *ctx); DECLSPEC void md5_init_vector_from_scalar (md5_ctx_vector_t *ctx, md5_ctx_t *ctx0); DECLSPEC void md5_update_vector_64 (md5_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void md5_update_vector (md5_ctx_vector_t *ctx, const u32x *w, const int len); +DECLSPEC void md5_update_vector_from_scalar (md5_ctx_vector_t *ctx, const u32 *w, const int len); DECLSPEC void md5_update_vector_swap (md5_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void md5_update_vector_utf16le (md5_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void md5_update_vector_utf16le_swap (md5_ctx_vector_t *ctx, const u32x *w, const int len);