From 7b24986096cb76caeb8b3e6c4badea0013dd8f6f Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Thu, 31 Mar 2022 11:45:58 +0200 Subject: [PATCH] Add important checks for pw_len == -1 to avoid out of boundary read/writes --- OpenCL/inc_hash_md4.cl | 28 ++++++++++++++++++++++++++++ OpenCL/inc_hash_md5.cl | 28 ++++++++++++++++++++++++++++ OpenCL/inc_hash_ripemd160.cl | 28 ++++++++++++++++++++++++++++ OpenCL/inc_hash_sha1.cl | 28 ++++++++++++++++++++++++++++ OpenCL/inc_hash_sha224.cl | 28 ++++++++++++++++++++++++++++ OpenCL/inc_hash_sha256.cl | 28 ++++++++++++++++++++++++++++ OpenCL/inc_hash_sha384.cl | 28 ++++++++++++++++++++++++++++ OpenCL/inc_hash_sha512.cl | 35 +++++++++++++++++++++++++++++++++++ OpenCL/inc_hash_whirlpool.cl | 28 ++++++++++++++++++++++++++++ OpenCL/m12500-pure.cl | 12 +++++++++--- OpenCL/m22400-pure.cl | 4 +++- OpenCL/m22700-pure.cl | 8 ++++++-- OpenCL/m23700-pure.cl | 12 +++++++++--- OpenCL/m23800-pure.cl | 12 +++++++++--- OpenCL/m24800_a0-pure.cl | 8 ++++++-- OpenCL/m24800_a1-pure.cl | 8 ++++++-- OpenCL/m24800_a3-pure.cl | 8 ++++++-- OpenCL/m27700-pure.cl | 8 ++++++-- OpenCL/shared.cl | 3 +++ 19 files changed, 322 insertions(+), 20 deletions(-) diff --git a/OpenCL/inc_hash_md4.cl b/OpenCL/inc_hash_md4.cl index 6411218fe..7d0d0c5fa 100644 --- a/OpenCL/inc_hash_md4.cl +++ b/OpenCL/inc_hash_md4.cl @@ -377,6 +377,13 @@ DECLSPEC void md4_update_utf16le (PRIVATE_AS md4_ctx_t *ctx, PRIVATE_AS const u3 const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + md4_update_64 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_len); } @@ -437,6 +444,13 @@ DECLSPEC void md4_update_utf16le_swap (PRIVATE_AS md4_ctx_t *ctx, PRIVATE_AS con const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); @@ -686,6 +700,13 @@ DECLSPEC void md4_update_global_utf16le (PRIVATE_AS md4_ctx_t *ctx, GLOBAL_AS co const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + md4_update_64 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_len); } @@ -746,6 +767,13 @@ DECLSPEC void md4_update_global_utf16le_swap (PRIVATE_AS md4_ctx_t *ctx, GLOBAL_ const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); diff --git a/OpenCL/inc_hash_md5.cl b/OpenCL/inc_hash_md5.cl index da496cef6..18324630e 100644 --- a/OpenCL/inc_hash_md5.cl +++ b/OpenCL/inc_hash_md5.cl @@ -413,6 +413,13 @@ DECLSPEC void md5_update_utf16le (PRIVATE_AS md5_ctx_t *ctx, PRIVATE_AS const u3 const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + md5_update_64 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_len); } @@ -473,6 +480,13 @@ DECLSPEC void md5_update_utf16le_swap (PRIVATE_AS md5_ctx_t *ctx, PRIVATE_AS con const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); @@ -722,6 +736,13 @@ DECLSPEC void md5_update_global_utf16le (PRIVATE_AS md5_ctx_t *ctx, GLOBAL_AS co const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + md5_update_64 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_len); } @@ -782,6 +803,13 @@ DECLSPEC void md5_update_global_utf16le_swap (PRIVATE_AS md5_ctx_t *ctx, GLOBAL_ const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); diff --git a/OpenCL/inc_hash_ripemd160.cl b/OpenCL/inc_hash_ripemd160.cl index 8a5554413..e7d196ec4 100644 --- a/OpenCL/inc_hash_ripemd160.cl +++ b/OpenCL/inc_hash_ripemd160.cl @@ -511,6 +511,13 @@ DECLSPEC void ripemd160_update_utf16le (PRIVATE_AS ripemd160_ctx_t *ctx, PRIVATE const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + ripemd160_update_64 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_len); } @@ -571,6 +578,13 @@ DECLSPEC void ripemd160_update_utf16le_swap (PRIVATE_AS ripemd160_ctx_t *ctx, PR const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); @@ -820,6 +834,13 @@ DECLSPEC void ripemd160_update_global_utf16le (PRIVATE_AS ripemd160_ctx_t *ctx, const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + ripemd160_update_64 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_len); } @@ -880,6 +901,13 @@ DECLSPEC void ripemd160_update_global_utf16le_swap (PRIVATE_AS ripemd160_ctx_t * const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); diff --git a/OpenCL/inc_hash_sha1.cl b/OpenCL/inc_hash_sha1.cl index 1f8d9e95e..abb485189 100644 --- a/OpenCL/inc_hash_sha1.cl +++ b/OpenCL/inc_hash_sha1.cl @@ -626,6 +626,13 @@ DECLSPEC void sha1_update_utf16le (PRIVATE_AS sha1_ctx_t *ctx, PRIVATE_AS const const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + sha1_update_64 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_len); } @@ -686,6 +693,13 @@ DECLSPEC void sha1_update_utf16le_swap (PRIVATE_AS sha1_ctx_t *ctx, PRIVATE_AS c const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); @@ -1053,6 +1067,13 @@ DECLSPEC void sha1_update_global_utf16le (PRIVATE_AS sha1_ctx_t *ctx, GLOBAL_AS const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + sha1_update_64 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_len); } @@ -1113,6 +1134,13 @@ DECLSPEC void sha1_update_global_utf16le_swap (PRIVATE_AS sha1_ctx_t *ctx, GLOBA const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); diff --git a/OpenCL/inc_hash_sha224.cl b/OpenCL/inc_hash_sha224.cl index b084214a9..3ca420fd4 100644 --- a/OpenCL/inc_hash_sha224.cl +++ b/OpenCL/inc_hash_sha224.cl @@ -428,6 +428,13 @@ DECLSPEC void sha224_update_utf16le (PRIVATE_AS sha224_ctx_t *ctx, PRIVATE_AS co const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + sha224_update_64 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_len); } @@ -488,6 +495,13 @@ DECLSPEC void sha224_update_utf16le_swap (PRIVATE_AS sha224_ctx_t *ctx, PRIVATE_ const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); @@ -737,6 +751,13 @@ DECLSPEC void sha224_update_global_utf16le (PRIVATE_AS sha224_ctx_t *ctx, GLOBAL const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + sha224_update_64 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_len); } @@ -797,6 +818,13 @@ DECLSPEC void sha224_update_global_utf16le_swap (PRIVATE_AS sha224_ctx_t *ctx, G const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); diff --git a/OpenCL/inc_hash_sha256.cl b/OpenCL/inc_hash_sha256.cl index de55101f4..f75d5ce60 100644 --- a/OpenCL/inc_hash_sha256.cl +++ b/OpenCL/inc_hash_sha256.cl @@ -428,6 +428,13 @@ DECLSPEC void sha256_update_utf16le (PRIVATE_AS sha256_ctx_t *ctx, PRIVATE_AS co const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + sha256_update_64 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_len); } @@ -488,6 +495,13 @@ DECLSPEC void sha256_update_utf16le_swap (PRIVATE_AS sha256_ctx_t *ctx, PRIVATE_ const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); @@ -737,6 +751,13 @@ DECLSPEC void sha256_update_global_utf16le (PRIVATE_AS sha256_ctx_t *ctx, GLOBAL const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + sha256_update_64 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_len); } @@ -797,6 +818,13 @@ DECLSPEC void sha256_update_global_utf16le_swap (PRIVATE_AS sha256_ctx_t *ctx, G const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); diff --git a/OpenCL/inc_hash_sha384.cl b/OpenCL/inc_hash_sha384.cl index e3fd761c6..bdbc90cee 100644 --- a/OpenCL/inc_hash_sha384.cl +++ b/OpenCL/inc_hash_sha384.cl @@ -636,6 +636,13 @@ DECLSPEC void sha384_update_utf16le (PRIVATE_AS sha384_ctx_t *ctx, PRIVATE_AS co const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + sha384_update_128 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_buf + 16, enc_buf + 20, enc_buf + 24, enc_buf + 28, enc_len); } @@ -720,6 +727,13 @@ DECLSPEC void sha384_update_utf16le_swap (PRIVATE_AS sha384_ctx_t *ctx, PRIVATE_ const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); @@ -1145,6 +1159,13 @@ DECLSPEC void sha384_update_global_utf16le (PRIVATE_AS sha384_ctx_t *ctx, GLOBAL const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + sha384_update_128 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_buf + 16, enc_buf + 20, enc_buf + 24, enc_buf + 28, enc_len); } @@ -1229,6 +1250,13 @@ DECLSPEC void sha384_update_global_utf16le_swap (PRIVATE_AS sha384_ctx_t *ctx, G const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); diff --git a/OpenCL/inc_hash_sha512.cl b/OpenCL/inc_hash_sha512.cl index dc0ac665b..33c01be30 100644 --- a/OpenCL/inc_hash_sha512.cl +++ b/OpenCL/inc_hash_sha512.cl @@ -636,6 +636,13 @@ DECLSPEC void sha512_update_utf16le (PRIVATE_AS sha512_ctx_t *ctx, PRIVATE_AS co const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + sha512_update_128 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_buf + 16, enc_buf + 20, enc_buf + 24, enc_buf + 28, enc_len); } @@ -720,6 +727,13 @@ DECLSPEC void sha512_update_utf16le_swap (PRIVATE_AS sha512_ctx_t *ctx, PRIVATE_ const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); @@ -1145,6 +1159,13 @@ DECLSPEC void sha512_update_global_utf16le (PRIVATE_AS sha512_ctx_t *ctx, GLOBAL const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + sha512_update_128 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_buf + 16, enc_buf + 20, enc_buf + 24, enc_buf + 28, enc_len); } @@ -1229,6 +1250,13 @@ DECLSPEC void sha512_update_global_utf16le_swap (PRIVATE_AS sha512_ctx_t *ctx, G const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); @@ -1937,6 +1965,13 @@ DECLSPEC void sha512_hmac_init_global_utf16le_swap (PRIVATE_AS sha512_hmac_ctx_t const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + if (enc_len > 128) { sha512_ctx_t tmp; diff --git a/OpenCL/inc_hash_whirlpool.cl b/OpenCL/inc_hash_whirlpool.cl index 67ba34c8a..a6f2ff09d 100644 --- a/OpenCL/inc_hash_whirlpool.cl +++ b/OpenCL/inc_hash_whirlpool.cl @@ -1032,6 +1032,13 @@ DECLSPEC void whirlpool_update_utf16le (PRIVATE_AS whirlpool_ctx_t *ctx, PRIVATE const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + whirlpool_update_64 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_len); } @@ -1092,6 +1099,13 @@ DECLSPEC void whirlpool_update_utf16le_swap (PRIVATE_AS whirlpool_ctx_t *ctx, PR const int enc_len = hc_enc_next (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); @@ -1341,6 +1355,13 @@ DECLSPEC void whirlpool_update_global_utf16le (PRIVATE_AS whirlpool_ctx_t *ctx, const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + whirlpool_update_64 (ctx, enc_buf + 0, enc_buf + 4, enc_buf + 8, enc_buf + 12, enc_len); } @@ -1401,6 +1422,13 @@ DECLSPEC void whirlpool_update_global_utf16le_swap (PRIVATE_AS whirlpool_ctx_t * const int enc_len = hc_enc_next_global (&hc_enc, w, len, 256, enc_buf, sizeof (enc_buf)); + if (enc_len == -1) + { + ctx->len = -1; + + return; + } + enc_buf[ 0] = hc_swap32_S (enc_buf[ 0]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); diff --git a/OpenCL/m12500-pure.cl b/OpenCL/m12500-pure.cl index 246fad578..f6101ab8c 100644 --- a/OpenCL/m12500-pure.cl +++ b/OpenCL/m12500-pure.cl @@ -746,7 +746,9 @@ KERNEL_FQ void m12500_init (KERN_ATTR_TMPS (rar3_tmp_t)) // store pass and salt in tmps: - const u32 pw_len = pws[gid].pw_len; + const int pw_len = pws[gid].pw_len; + + if (pw_len == -1) return; // gpu_utf8_to_utf16() can result in -1 u32 w[80] = { 0 }; @@ -804,7 +806,9 @@ KERNEL_FQ void m12500_loop (KERN_ATTR_TMPS (rar3_tmp_t)) * base */ - const u32 pw_len = pws[gid].pw_len; + const int pw_len = pws[gid].pw_len; + + if (pw_len == -1) return; // gpu_utf8_to_utf16() can result in -1 const u32 salt_len = 8; @@ -970,7 +974,9 @@ KERNEL_FQ void m12500_comp (KERN_ATTR_TMPS (rar3_tmp_t)) * base */ - const u32 pw_len = pws[gid].pw_len; + const int pw_len = pws[gid].pw_len; + + if (pw_len == -1) return; // gpu_utf8_to_utf16() can result in -1 const u32 salt_len = 8; diff --git a/OpenCL/m22400-pure.cl b/OpenCL/m22400-pure.cl index 4e81400f0..f7da3a4ba 100644 --- a/OpenCL/m22400-pure.cl +++ b/OpenCL/m22400-pure.cl @@ -50,7 +50,9 @@ KERNEL_FQ void m22400_init (KERN_ATTR_TMPS_ESALT (aescrypt_tmp_t, aescrypt_t)) s[2] = salt_bufs[SALT_POS_HOST].salt_buf[2]; s[3] = salt_bufs[SALT_POS_HOST].salt_buf[3]; - const u32 pw_len = pws[gid].pw_len; + const int pw_len = pws[gid].pw_len; + + if (pw_len == -1) return; // gpu_utf8_to_utf16() can result in -1 u32 w[80] = { 0 }; diff --git a/OpenCL/m22700-pure.cl b/OpenCL/m22700-pure.cl index 22b801ce5..d574e9c2d 100644 --- a/OpenCL/m22700-pure.cl +++ b/OpenCL/m22700-pure.cl @@ -331,7 +331,9 @@ KERNEL_FQ void m22700_init (KERN_ATTR_TMPS (scrypt_tmp_t)) hc_enc_init (&hc_enc); - const u32 w_len = hc_enc_next_global (&hc_enc, pws[gid].i, pws[gid].pw_len, 256, w, sizeof (w)); + const int w_len = hc_enc_next_global (&hc_enc, pws[gid].i, pws[gid].pw_len, 256, w, sizeof (w)); + + if (w_len == -1) return; // utf16le to utf16be for (int i = 0, j = 0; i < w_len; i += 4, j += 1) @@ -567,7 +569,9 @@ KERNEL_FQ void m22700_comp (KERN_ATTR_TMPS (scrypt_tmp_t)) hc_enc_init (&hc_enc); - const u32 w_len = hc_enc_next_global (&hc_enc, pws[gid].i, pws[gid].pw_len, 256, w, sizeof (w)); + const int w_len = hc_enc_next_global (&hc_enc, pws[gid].i, pws[gid].pw_len, 256, w, sizeof (w)); + + if (w_len == -1) return; // utf16le to utf16be for (int i = 0, j = 0; i < w_len; i += 4, j += 1) diff --git a/OpenCL/m23700-pure.cl b/OpenCL/m23700-pure.cl index fa5393eda..468711e2f 100644 --- a/OpenCL/m23700-pure.cl +++ b/OpenCL/m23700-pure.cl @@ -854,7 +854,9 @@ KERNEL_FQ void m23700_init (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, rar3_t)) // store pass and salt in tmps: - const u32 pw_len = pws[gid].pw_len; + const int pw_len = pws[gid].pw_len; + + if (pw_len == -1) return; // gpu_utf8_to_utf16() can result in -1 u32 w[80] = { 0 }; @@ -912,7 +914,9 @@ KERNEL_FQ void m23700_loop (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, rar3_t)) * base */ - const u32 pw_len = pws[gid].pw_len; + const int pw_len = pws[gid].pw_len; + + if (pw_len == -1) return; // gpu_utf8_to_utf16() can result in -1 const u32 salt_len = 8; @@ -1086,7 +1090,9 @@ KERNEL_FQ void m23700_comp (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, rar3_t)) * base */ - const u32 pw_len = pws[gid].pw_len; + const int pw_len = pws[gid].pw_len; + + if (pw_len == -1) return; // gpu_utf8_to_utf16() can result in -1 const u32 salt_len = 8; diff --git a/OpenCL/m23800-pure.cl b/OpenCL/m23800-pure.cl index 6eca59377..5a20464cc 100644 --- a/OpenCL/m23800-pure.cl +++ b/OpenCL/m23800-pure.cl @@ -765,7 +765,9 @@ KERNEL_FQ void m23800_init (KERN_ATTR_TMPS_HOOKS_ESALT (rar3_tmp_t, rar3_hook_t, // store pass and salt in tmps: - const u32 pw_len = pws[gid].pw_len; + const int pw_len = pws[gid].pw_len; + + if (pw_len == -1) return; // gpu_utf8_to_utf16() can result in -1 u32 w[80] = { 0 }; @@ -823,7 +825,9 @@ KERNEL_FQ void m23800_loop (KERN_ATTR_TMPS_HOOKS_ESALT (rar3_tmp_t, rar3_hook_t, * base */ - const u32 pw_len = pws[gid].pw_len; + const int pw_len = pws[gid].pw_len; + + if (pw_len == -1) return; // gpu_utf8_to_utf16() can result in -1 const u32 salt_len = 8; @@ -990,7 +994,9 @@ KERNEL_FQ void m23800_hook23 (KERN_ATTR_TMPS_HOOKS_ESALT (rar3_tmp_t, rar3_hook_ * base */ - const u32 pw_len = pws[gid].pw_len; + const int pw_len = pws[gid].pw_len; + + if (pw_len == -1) return; // gpu_utf8_to_utf16() can result in -1 const u32 salt_len = 8; diff --git a/OpenCL/m24800_a0-pure.cl b/OpenCL/m24800_a0-pure.cl index fb69a94e9..512ecec1c 100644 --- a/OpenCL/m24800_a0-pure.cl +++ b/OpenCL/m24800_a0-pure.cl @@ -49,7 +49,9 @@ KERNEL_FQ void m24800_mxx (KERN_ATTR_RULES ()) hc_enc_init (&hc_enc); - const u32 t_len = hc_enc_next (&hc_enc, tmp.i, tmp.pw_len, 256, t, sizeof (t)); + const int t_len = hc_enc_next (&hc_enc, tmp.i, tmp.pw_len, 256, t, sizeof (t)); + + if (t_len == -1) continue; // hash time @@ -115,7 +117,9 @@ KERNEL_FQ void m24800_sxx (KERN_ATTR_RULES ()) hc_enc_init (&hc_enc); - const u32 t_len = hc_enc_next (&hc_enc, tmp.i, tmp.pw_len, 256, t, sizeof (t)); + const int t_len = hc_enc_next (&hc_enc, tmp.i, tmp.pw_len, 256, t, sizeof (t)); + + if (t_len == -1) continue; // hash time diff --git a/OpenCL/m24800_a1-pure.cl b/OpenCL/m24800_a1-pure.cl index 0785b6024..a1b2766f7 100644 --- a/OpenCL/m24800_a1-pure.cl +++ b/OpenCL/m24800_a1-pure.cl @@ -72,7 +72,9 @@ KERNEL_FQ void m24800_mxx (KERN_ATTR_BASIC ()) hc_enc_init (&hc_enc); - const u32 t_len = hc_enc_next (&hc_enc, c, pw_len + comb_len, 256, t, sizeof (t)); + const int t_len = hc_enc_next (&hc_enc, c, pw_len + comb_len, 256, t, sizeof (t)); + + if (t_len == -1) continue; // hash time @@ -163,7 +165,9 @@ KERNEL_FQ void m24800_sxx (KERN_ATTR_BASIC ()) hc_enc_init (&hc_enc); - const u32 t_len = hc_enc_next (&hc_enc, c, pw_len + comb_len, 256, t, sizeof (t)); + const int t_len = hc_enc_next (&hc_enc, c, pw_len + comb_len, 256, t, sizeof (t)); + + if (t_len == -1) continue; // hash time diff --git a/OpenCL/m24800_a3-pure.cl b/OpenCL/m24800_a3-pure.cl index bbc4acd5c..cb76326ec 100644 --- a/OpenCL/m24800_a3-pure.cl +++ b/OpenCL/m24800_a3-pure.cl @@ -58,7 +58,9 @@ KERNEL_FQ void m24800_mxx (KERN_ATTR_VECTOR ()) hc_enc_init (&hc_enc); - const u32 t_len = hc_enc_next (&hc_enc, w, pw_len, 256, t, sizeof (t)); + const int t_len = hc_enc_next (&hc_enc, w, pw_len, 256, t, sizeof (t)); + + if (t_len == -1) continue; // hash time @@ -135,7 +137,9 @@ KERNEL_FQ void m24800_sxx (KERN_ATTR_VECTOR ()) hc_enc_init (&hc_enc); - const u32 t_len = hc_enc_next (&hc_enc, w, pw_len, 256, t, sizeof (t)); + const int t_len = hc_enc_next (&hc_enc, w, pw_len, 256, t, sizeof (t)); + + if (t_len == -1) continue; // hash time diff --git a/OpenCL/m27700-pure.cl b/OpenCL/m27700-pure.cl index 588647e49..dc58e5210 100644 --- a/OpenCL/m27700-pure.cl +++ b/OpenCL/m27700-pure.cl @@ -281,7 +281,9 @@ KERNEL_FQ void m27700_init (KERN_ATTR_TMPS (scrypt_tmp_t)) hc_enc_init (&hc_enc); - const u32 w_len = hc_enc_next_global (&hc_enc, pws[gid].i, pws[gid].pw_len, 256, w, sizeof (w)); + const int w_len = hc_enc_next_global (&hc_enc, pws[gid].i, pws[gid].pw_len, 256, w, sizeof (w)); + + if (w_len == -1) return; // utf16le to utf16be @@ -518,7 +520,9 @@ KERNEL_FQ void m27700_comp (KERN_ATTR_TMPS (scrypt_tmp_t)) hc_enc_init (&hc_enc); - const u32 w_len = hc_enc_next_global (&hc_enc, pws[gid].i, pws[gid].pw_len, 256, w, sizeof (w)); + const int w_len = hc_enc_next_global (&hc_enc, pws[gid].i, pws[gid].pw_len, 256, w, sizeof (w)); + + if (w_len == -1) return; // utf16le to utf16be diff --git a/OpenCL/shared.cl b/OpenCL/shared.cl index 55da40a55..7b8939ded 100644 --- a/OpenCL/shared.cl +++ b/OpenCL/shared.cl @@ -269,6 +269,9 @@ KERNEL_FQ void gpu_utf8_to_utf16 (KERN_ATTR_GPU_UTF8_TO_UTF16) hc_enc_init (&hc_enc); + // note that this can result in pw_len = -1 + // need to check for pw_len in kernel + pw_out.pw_len = hc_enc_next (&hc_enc, pw_in.i, pw_in.pw_len, 256, pw_out.i, 256); pws_buf[gid] = pw_out;