-
Notifications
You must be signed in to change notification settings - Fork 265
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
Add cSHAKE128 and cSHAKE256 implementations #355
Conversation
Yeah, it's quite unfortunate. I had a similar issue with MAC types in BTW with #351 merged you can rebase and the CI should be fixed. |
Thanks for taking this up! |
In that case, you use the |
I just noticed the KMAC algorithm does use this function name, so we should probably keep it public for when KMAC is implemented. |
@newpavlov when would you have time to review this PR? I'm also still open for suggestions to making the API more ergonomic, but right now I feel like this is the easiest way to construct a CSHAKE instance:
which is a bit more complex than other digests, but not too bad. |
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.
LGTM. @newpavlov care to do a pass reviewing this?
Can we get a new version published with this? |
Released in #384 |
Based on pull request #325 from @elichai. I was planning on extending their branch and creating a merge commit first, to not lose the Git history, but unfortunately that proved too difficult.
This implementation uses
digest
v0.10.0. It differs in some places from the implementation in #325, most importantly:reset
feature to indicate whether reset support should be compiled in.new_with_function_name
accepts a function name argument. This results in some overhead for the cSHAKE initialization, but normally the initialization shouldn't be performed a lot anyway. Even though the end user will probably never need it, I didn't want to omit that functionality should it ever be necessary in the future. Though perhapsnew_with_function_name
could be made private for now?Some additional notes:
CShake128
andCShake256
don't implementDefault
, the easiest way to construct an instance is usingCShake128::from_core(CShake128Core::new(customization))
which is quite verbose. I didn't find a way to make this shorter in the current trait typesystem. Perhaps that's something that could be improved indigest
.xof_reset_test
function doesn't apply here because the structs don't implementDefault
.The test vectors are still from https://github.com/damaki/libkeccak/tree/master/tests/kat/testvectors/cSHAKE together with the current SHAKE tests for an empty customization.
Once again, many credits to @elichai.