1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-26 01:50:10 +00:00

Add important checks for pw_len == -1 to avoid out of boundary read/writes

This commit is contained in:
Jens Steube 2022-03-31 11:45:58 +02:00
parent 753994bfe0
commit 7b24986096
19 changed files with 322 additions and 20 deletions

View File

@ -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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); 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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]);

View File

@ -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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); 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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]);

View File

@ -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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); 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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]);

View File

@ -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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); 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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]);

View File

@ -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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); 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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]);

View File

@ -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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); 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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]);

View File

@ -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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); 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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]);

View File

@ -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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); 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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); 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)); 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) if (enc_len > 128)
{ {
sha512_ctx_t tmp; sha512_ctx_t tmp;

View File

@ -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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); 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)); 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); 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)); 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[ 0] = hc_swap32_S (enc_buf[ 0]);
enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]); enc_buf[ 1] = hc_swap32_S (enc_buf[ 1]);
enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]); enc_buf[ 2] = hc_swap32_S (enc_buf[ 2]);

View File

@ -746,7 +746,9 @@ KERNEL_FQ void m12500_init (KERN_ATTR_TMPS (rar3_tmp_t))
// store pass and salt in tmps: // 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 }; u32 w[80] = { 0 };
@ -804,7 +806,9 @@ KERNEL_FQ void m12500_loop (KERN_ATTR_TMPS (rar3_tmp_t))
* base * 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; const u32 salt_len = 8;
@ -970,7 +974,9 @@ KERNEL_FQ void m12500_comp (KERN_ATTR_TMPS (rar3_tmp_t))
* base * 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; const u32 salt_len = 8;

View File

@ -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[2] = salt_bufs[SALT_POS_HOST].salt_buf[2];
s[3] = salt_bufs[SALT_POS_HOST].salt_buf[3]; 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 }; u32 w[80] = { 0 };

View File

@ -331,7 +331,9 @@ KERNEL_FQ void m22700_init (KERN_ATTR_TMPS (scrypt_tmp_t))
hc_enc_init (&hc_enc); 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 // utf16le to utf16be
for (int i = 0, j = 0; i < w_len; i += 4, j += 1) 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); 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 // utf16le to utf16be
for (int i = 0, j = 0; i < w_len; i += 4, j += 1) for (int i = 0, j = 0; i < w_len; i += 4, j += 1)

View File

@ -854,7 +854,9 @@ KERNEL_FQ void m23700_init (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, rar3_t))
// store pass and salt in tmps: // 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 }; u32 w[80] = { 0 };
@ -912,7 +914,9 @@ KERNEL_FQ void m23700_loop (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, rar3_t))
* base * 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; const u32 salt_len = 8;
@ -1086,7 +1090,9 @@ KERNEL_FQ void m23700_comp (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, rar3_t))
* base * 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; const u32 salt_len = 8;

View File

@ -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: // 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 }; 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 * 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; 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 * 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; const u32 salt_len = 8;

View File

@ -49,7 +49,9 @@ KERNEL_FQ void m24800_mxx (KERN_ATTR_RULES ())
hc_enc_init (&hc_enc); 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 // hash time
@ -115,7 +117,9 @@ KERNEL_FQ void m24800_sxx (KERN_ATTR_RULES ())
hc_enc_init (&hc_enc); 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 // hash time

View File

@ -72,7 +72,9 @@ KERNEL_FQ void m24800_mxx (KERN_ATTR_BASIC ())
hc_enc_init (&hc_enc); 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 // hash time
@ -163,7 +165,9 @@ KERNEL_FQ void m24800_sxx (KERN_ATTR_BASIC ())
hc_enc_init (&hc_enc); 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 // hash time

View File

@ -58,7 +58,9 @@ KERNEL_FQ void m24800_mxx (KERN_ATTR_VECTOR ())
hc_enc_init (&hc_enc); 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 // hash time
@ -135,7 +137,9 @@ KERNEL_FQ void m24800_sxx (KERN_ATTR_VECTOR ())
hc_enc_init (&hc_enc); 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 // hash time

View File

@ -281,7 +281,9 @@ KERNEL_FQ void m27700_init (KERN_ATTR_TMPS (scrypt_tmp_t))
hc_enc_init (&hc_enc); 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 // utf16le to utf16be
@ -518,7 +520,9 @@ KERNEL_FQ void m27700_comp (KERN_ATTR_TMPS (scrypt_tmp_t))
hc_enc_init (&hc_enc); 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 // utf16le to utf16be

View File

@ -269,6 +269,9 @@ KERNEL_FQ void gpu_utf8_to_utf16 (KERN_ATTR_GPU_UTF8_TO_UTF16)
hc_enc_init (&hc_enc); 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); 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; pws_buf[gid] = pw_out;