Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dilithium: fix check hint #7803

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -32389,6 +32389,12 @@ static int test_wc_dilithium_verify(void)
0);
ExpectIntEQ(res, 0);
sig[100] ^= 0x80;

/* Set all indeces to 0. */
XMEMSET(sig + sigLen - 4, 0, 4);
ExpectIntEQ(wc_dilithium_verify_msg(sig, sigLen, msg, 32, &res, key),
SIG_VERIFY_E);
ExpectIntEQ(res, 0);
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions wolfcrypt/src/dilithium.c
Original file line number Diff line number Diff line change
Expand Up @@ -3183,11 +3183,11 @@ static int dilithium_check_hint(const byte* h, byte k, byte omega)
unsigned int i;

/* Skip polynomial index while count is 0. */
while ((h[omega + o] == 0) && (o < k)) {
while ((o < k) && (h[omega + o] == 0)) {
o++;
}
/* Check all possible hints. */
for (i = 1; i < omega; i++) {
for (i = 1; (o < k) && (i < omega); i++) {
/* Done with polynomial if index equals count of hints. */
if (i == h[omega + o]) {
/* Next polynomial index while count is index. */
Expand Down