Closed otonashixav closed 3 years ago
Reset can't be used after clean, indeed — where it can, it initializes the state only by accident, not by design. BLAKE2b works like this because its initial state depends on user configuration and key or salt, so that state is stored and when you call reset it is restored, allowing you to run hash with the initial parameters that you set. Clean throws everything away, including the configuration parameters, the key, and the salt. SHA on the other hand, doesn't have configurable features, so it just puts the IV constants back.
I should document that clean is intended as a final wipe for safety so that fewer secret bytes remain in memory. After you call clean, you shouldn't do anything else with the object.
I was attempting to modify ed25519 to use blake2b instead of sha512, but wasn't able to get the sign function to produce a correct signature without modifying how the blake2b object was used.
It seems that calling
reset
afterclean
on a blake2b object does not reinitialize the state, hence it cannot be reused after callingclean
. The expected behaviour should be that callingreset
allows the object to be reused with the same initial state?Comparison of BLAKE2b and SHA512:
BLAKE2b:
SHA512: