Add cSHAKE128 and cSHAKE256 implementations#355
Add cSHAKE128 and cSHAKE256 implementations#355tarcieri merged 3 commits intoRustCrypto:masterfrom jvdsn:master
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. |
tarcieri
left a comment
There was a problem hiding this comment.
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
digestv0.10.0. It differs in some places from the implementation in #325, most importantly:resetfeature to indicate whether reset support should be compiled in.new_with_function_nameaccepts 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_namecould be made private for now?Some additional notes:
CShake128andCShake256don'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_testfunction 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.