debris / tiny-keccak

An implementation of Keccak derived functions specified in FIPS-202, SP800-185 and KangarooTwelve
Creative Commons Zero v1.0 Universal
193 stars 49 forks source link

Allow resetting Keccak internal buffer by zeroing out #46

Open SuperFluffy opened 4 years ago

SuperFluffy commented 4 years ago

I would like to be able to reset the internal KeccakState of a Keccak instance so that its buffer and offset are zeroed out. I can see that there is a method reset on KeccakState, which however is only ever called from KangarooTwelve.

It is possible to provide a reset method on Keccak calling KeccakState:reset? Is there maybe a reason why there is no such method? I can otherwise provide a PR, but I wanted to ask first.

rajivshah3 commented 3 years ago

Hi @debris , would you be open to providing a reset method on Keccak so that we can zero out the buffer there?

stackinspector commented 1 year ago

One thing to note: cSHAKE, and all cSHAKE-based functions, cannot straightly expose the reset method, because cSHAKE has a process of initialization based on name and custom_string, in other words the "initial" Buffer state is not all zero. You can refer to RustCrypto's cSHAKE implementation. However, Keccak, SHA3 and SHAKE do not have an initialization process, so you can straightly expose the reset method.