-
Notifications
You must be signed in to change notification settings - Fork 578
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
Refactoring SHA3: based on new permutation keccak-fips #3673
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a sanity check I used this refactoring as the foundation for the new XOF interface (#3671). In general that seems to work nicely. Though, I'm wondering whether we should make the Keccak_FIPS
implementation more generic. Most notably to allow multiple (unaligned) calls to expand()
. The logic for that already exists in SHAKE_XOF::generate_bytes()
. But centralizing it here, would benefit other users of Keccak_FIPS
.
Unfortunately, I didn't manage to finish a thorough review today. Will look deeper into it tomorrow.
In the meantime: @randombit, could you please skim this and give feedback on the general direction of this refactoring?
I didn't manage to finish the review this morning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this seems basically fine.
I'd suggest keccak_perm
as the module name since keccak_fips
doesn't really capture what the module is doing.
@falko-strenzke I'm currently working at restructuring this even further (fully removing the |
#3675 contains two extra patches on top of this work. One adds some convenience functions to the internal @falko-strenzke, I hope you'll excuse me for having taken this PR over like that. I suggest that you take my patches, squash the changes as you see fit and update this PR for merging. #3675 can then be closed. |
Done. |
f4eb7aa
to
3ced414
Compare
…ck for SHA-3 renamed keccak_fips to keccak_perm(utation) everywhere keccak finish now without output removed output length from keccak permutation Clean up the Keccak_Permutation * replace single-shot ::expand() with more versatile ::squeeze() * use BufferStuffer/BufferSlicer in ::squeeze() and ::absorb() * remove low-level access to Keccak state * remove static Keccak state mutation methods * ::permute() is now private
3ced414
to
85b70ed
Compare
@randombit now @reneme and me agree that this combined PR of ours is ready for final review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine, thanks.
One request before merge: please benchmark the various operations to make sure we're not introducing any major performance regression. Especially I would be concerned about Kyber as it seems very sensitive to the XOF performance.
... measured as the average of three runs of SHA-3 is very much biased towards |
I also observe a performance loss for
It is also based on the average of 3 measurements, plattform @reneme @randombit Is this worth exploring in more detail? |
I feel this deviation is within the tolerance of the measurement accuracy of this benchmark tool. |
Agree. I would be concerned about anything >10%, numbers here seem ok |
This PR is needed as a prerequisite of #3570.