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

Code quality issue in SHA3: useless division #816

Open
msprotz opened this issue May 9, 2023 · 2 comments
Open

Code quality issue in SHA3: useless division #816

msprotz opened this issue May 9, 2023 · 2 comments

Comments

@msprotz
Copy link
Contributor

msprotz commented May 9, 2023

Reported by @karthikbhargavan

https://github.com/hacl-star/hacl-star/blob/main/dist/gcc-compatible/Hacl_Hash_SHA3.c#L307 could be 1 instead of a division

@msprotz msprotz changed the title Code quality issue in SHA3 Code quality issue in SHA3: useless division May 22, 2023
@R1kM
Copy link
Contributor

R1kM commented Jun 9, 2023

Permanent link for the code mentioned above:

Hacl_Hash_SHA3_update_multi_sha3(a1, s2, buf, block_len(i) / block_len(a1));

@R1kM
Copy link
Contributor

R1kM commented Jun 9, 2023

Relevant F* code:
The call to update_multi in the generic functor implementation:

c.update_multi (G.hide i) block_state prevlen buf (c.blocks_state_len i);

The update_multi instantiation for Keccak:

Hacl.Hash.SHA3.update_multi a s () blocks (len `U32.div` Hacl.Hash.SHA3.(block_len a)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants