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 in SHA2 streaming: could share more code between finish_224 and finish_256 #772

Open
msprotz opened this issue Feb 8, 2023 · 0 comments

Comments

@msprotz
Copy link
Contributor

msprotz commented Feb 8, 2023

Right now, Hacl_SHA2_Streaming.c has two nearly identical functions for Streaming_sha2_224_finish, and Streaming_sha2_256_finish... these two functions call update_224/update_256 (these are identical, we have a proof), update_last_224/update_last_256 (same deal), then finish_224/finish_256.

finish_224 can be expressed in terms of finish_256 followed by a truncation; or worded differently, one could rewrite Streaming_sha2_224_finish to call Streaming_sha2_256_finish then truncate the result, which would save one code size in that file.

(Same deal with 384/512).

@msprotz msprotz changed the title Code quality in SHA2 streaming Code quality in SHA2 streaming: could share more code between finish_224 and finish_256 May 22, 2023
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

1 participant