diff --git a/OpenCL/inc_common.cl b/OpenCL/inc_common.cl index 16eb3b124..ad63d2133 100644 --- a/OpenCL/inc_common.cl +++ b/OpenCL/inc_common.cl @@ -2064,8 +2064,8 @@ DECLSPEC int hc_enc_has_next (hc_enc_t *hc_enc, const int sz) return 0; } -// Input buffer and Output buffer size has to be multiple of 16 and at least of size 16 -// The output buffer will by zero padded +// Input buffer and Output buffer size has to be multiple of 4 and at least of size 4. +// The output buffer is not zero padded, so entire buffer has to be set all zero before entering this function or truncated afterwards. DECLSPEC int hc_enc_next (hc_enc_t *hc_enc, const u32 *src_buf, const int src_len, const int src_sz, u32 *dst_buf, const int dst_sz) { @@ -2193,20 +2193,6 @@ DECLSPEC int hc_enc_next (hc_enc_t *hc_enc, const u32 *src_buf, const int src_le } } - if (dst_pos < dst_sz) - { - const int dst_block = dst_pos / 16; - - truncate_block_4x4_le_S (dst_buf + (dst_block * 4), dst_pos & 15); - - const int zero_block = dst_block + 1; - - for (int i = zero_block * 16, j = zero_block * 4; i < dst_sz; i += 4, j += 1) - { - dst_buf[j] = 0; - } - } - hc_enc->pos = src_pos; return dst_pos; @@ -2338,20 +2324,6 @@ DECLSPEC int hc_enc_next_global (hc_enc_t *hc_enc, GLOBAL_AS const u32 *src_buf, } } - if (dst_pos < dst_sz) - { - const int dst_block = dst_pos / 16; - - truncate_block_4x4_le_S (dst_buf + (dst_block * 4), dst_pos & 15); - - const int zero_block = dst_block + 1; - - for (int i = zero_block * 16, j = zero_block * 4; i < dst_sz; i += 4, j += 1) - { - dst_buf[j] = 0; - } - } - hc_enc->pos = src_pos; return dst_pos; diff --git a/OpenCL/inc_hash_md4.cl b/OpenCL/inc_hash_md4.cl index eeb837427..138df06f3 100644 --- a/OpenCL/inc_hash_md4.cl +++ b/OpenCL/inc_hash_md4.cl @@ -371,7 +371,7 @@ DECLSPEC void md4_update_utf16le (md4_ctx_t *ctx, const u32 *w, const int len) while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -431,7 +431,7 @@ DECLSPEC void md4_update_utf16le_swap (md4_ctx_t *ctx, const u32 *w, const int l while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -680,7 +680,7 @@ DECLSPEC void md4_update_global_utf16le (md4_ctx_t *ctx, GLOBAL_AS const u32 *w, while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -740,7 +740,7 @@ DECLSPEC void md4_update_global_utf16le_swap (md4_ctx_t *ctx, GLOBAL_AS const u3 while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); diff --git a/OpenCL/inc_hash_md5.cl b/OpenCL/inc_hash_md5.cl index 26ed0939b..7031a0422 100644 --- a/OpenCL/inc_hash_md5.cl +++ b/OpenCL/inc_hash_md5.cl @@ -407,7 +407,7 @@ DECLSPEC void md5_update_utf16le (md5_ctx_t *ctx, const u32 *w, const int len) while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -467,7 +467,7 @@ DECLSPEC void md5_update_utf16le_swap (md5_ctx_t *ctx, const u32 *w, const int l while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -716,7 +716,7 @@ DECLSPEC void md5_update_global_utf16le (md5_ctx_t *ctx, GLOBAL_AS const u32 *w, while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -776,7 +776,7 @@ DECLSPEC void md5_update_global_utf16le_swap (md5_ctx_t *ctx, GLOBAL_AS const u3 while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); diff --git a/OpenCL/inc_hash_ripemd160.cl b/OpenCL/inc_hash_ripemd160.cl index 09b6c6e74..e5b98d44c 100644 --- a/OpenCL/inc_hash_ripemd160.cl +++ b/OpenCL/inc_hash_ripemd160.cl @@ -505,7 +505,7 @@ DECLSPEC void ripemd160_update_utf16le (ripemd160_ctx_t *ctx, const u32 *w, cons while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -565,7 +565,7 @@ DECLSPEC void ripemd160_update_utf16le_swap (ripemd160_ctx_t *ctx, const u32 *w, while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -814,7 +814,7 @@ DECLSPEC void ripemd160_update_global_utf16le (ripemd160_ctx_t *ctx, GLOBAL_AS c while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -874,7 +874,7 @@ DECLSPEC void ripemd160_update_global_utf16le_swap (ripemd160_ctx_t *ctx, GLOBAL while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); diff --git a/OpenCL/inc_hash_sha1.cl b/OpenCL/inc_hash_sha1.cl index 58a9ef0f4..c0806bd52 100644 --- a/OpenCL/inc_hash_sha1.cl +++ b/OpenCL/inc_hash_sha1.cl @@ -620,7 +620,7 @@ DECLSPEC void sha1_update_utf16le (sha1_ctx_t *ctx, const u32 *w, const int len) while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -680,7 +680,7 @@ DECLSPEC void sha1_update_utf16le_swap (sha1_ctx_t *ctx, const u32 *w, const int while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -1047,7 +1047,7 @@ DECLSPEC void sha1_update_global_utf16le (sha1_ctx_t *ctx, GLOBAL_AS const u32 * while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -1107,7 +1107,7 @@ DECLSPEC void sha1_update_global_utf16le_swap (sha1_ctx_t *ctx, GLOBAL_AS const while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); diff --git a/OpenCL/inc_hash_sha224.cl b/OpenCL/inc_hash_sha224.cl index 46ffe74af..026b5af62 100644 --- a/OpenCL/inc_hash_sha224.cl +++ b/OpenCL/inc_hash_sha224.cl @@ -422,7 +422,7 @@ DECLSPEC void sha224_update_utf16le (sha224_ctx_t *ctx, const u32 *w, const int while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -482,7 +482,7 @@ DECLSPEC void sha224_update_utf16le_swap (sha224_ctx_t *ctx, const u32 *w, const while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -731,7 +731,7 @@ DECLSPEC void sha224_update_global_utf16le (sha224_ctx_t *ctx, GLOBAL_AS const u while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -791,7 +791,7 @@ DECLSPEC void sha224_update_global_utf16le_swap (sha224_ctx_t *ctx, GLOBAL_AS co while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); diff --git a/OpenCL/inc_hash_sha256.cl b/OpenCL/inc_hash_sha256.cl index 8942ea328..c4e11bc1e 100644 --- a/OpenCL/inc_hash_sha256.cl +++ b/OpenCL/inc_hash_sha256.cl @@ -422,7 +422,7 @@ DECLSPEC void sha256_update_utf16le (sha256_ctx_t *ctx, const u32 *w, const int while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -482,7 +482,7 @@ DECLSPEC void sha256_update_utf16le_swap (sha256_ctx_t *ctx, const u32 *w, const while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -731,7 +731,7 @@ DECLSPEC void sha256_update_global_utf16le (sha256_ctx_t *ctx, GLOBAL_AS const u while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -791,7 +791,7 @@ DECLSPEC void sha256_update_global_utf16le_swap (sha256_ctx_t *ctx, GLOBAL_AS co while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); diff --git a/OpenCL/inc_hash_sha384.cl b/OpenCL/inc_hash_sha384.cl index 4ebd5e818..ad580b91d 100644 --- a/OpenCL/inc_hash_sha384.cl +++ b/OpenCL/inc_hash_sha384.cl @@ -630,7 +630,7 @@ DECLSPEC void sha384_update_utf16le (sha384_ctx_t *ctx, const u32 *w, const int while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[32]; + u32 enc_buf[32] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -714,7 +714,7 @@ DECLSPEC void sha384_update_utf16le_swap (sha384_ctx_t *ctx, const u32 *w, const while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[32]; + u32 enc_buf[32] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -1139,7 +1139,7 @@ DECLSPEC void sha384_update_global_utf16le (sha384_ctx_t *ctx, GLOBAL_AS const u while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[32]; + u32 enc_buf[32] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -1223,7 +1223,7 @@ DECLSPEC void sha384_update_global_utf16le_swap (sha384_ctx_t *ctx, GLOBAL_AS co while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[32]; + u32 enc_buf[32] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); diff --git a/OpenCL/inc_hash_sha512.cl b/OpenCL/inc_hash_sha512.cl index 236e83814..8cc664557 100644 --- a/OpenCL/inc_hash_sha512.cl +++ b/OpenCL/inc_hash_sha512.cl @@ -630,7 +630,7 @@ DECLSPEC void sha512_update_utf16le (sha512_ctx_t *ctx, const u32 *w, const int while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[32]; + u32 enc_buf[32] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -714,7 +714,7 @@ DECLSPEC void sha512_update_utf16le_swap (sha512_ctx_t *ctx, const u32 *w, const while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[32]; + u32 enc_buf[32] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -1139,7 +1139,7 @@ DECLSPEC void sha512_update_global_utf16le (sha512_ctx_t *ctx, GLOBAL_AS const u while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[32]; + u32 enc_buf[32] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -1223,7 +1223,7 @@ DECLSPEC void sha512_update_global_utf16le_swap (sha512_ctx_t *ctx, GLOBAL_AS co while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[32]; + u32 enc_buf[32] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); diff --git a/OpenCL/inc_hash_whirlpool.cl b/OpenCL/inc_hash_whirlpool.cl index 60fa8b620..59a9a266b 100644 --- a/OpenCL/inc_hash_whirlpool.cl +++ b/OpenCL/inc_hash_whirlpool.cl @@ -1026,7 +1026,7 @@ DECLSPEC void whirlpool_update_utf16le (whirlpool_ctx_t *ctx, const u32 *w, cons while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -1086,7 +1086,7 @@ DECLSPEC void whirlpool_update_utf16le_swap (whirlpool_ctx_t *ctx, const u32 *w, while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -1335,7 +1335,7 @@ DECLSPEC void whirlpool_update_global_utf16le (whirlpool_ctx_t *ctx, GLOBAL_AS c while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); @@ -1395,7 +1395,7 @@ DECLSPEC void whirlpool_update_global_utf16le_swap (whirlpool_ctx_t *ctx, GLOBAL while (hc_enc_has_next (&hc_enc, len)) { - u32 enc_buf[16]; + u32 enc_buf[16] = { 0 }; const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf));