From dbf07c027699b95984fcdb53808d0f58316f7424 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 5 Nov 2014 20:15:56 +0100 Subject: add libkeccak_state_reset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libkeccak/state.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/libkeccak/state.h b/src/libkeccak/state.h index 7f4f3b6..e11ac80 100644 --- a/src/libkeccak/state.h +++ b/src/libkeccak/state.h @@ -111,6 +111,20 @@ __attribute__((leaf, nonnull)) int libkeccak_state_initialise(libkeccak_state_t* restrict state, const libkeccak_spec_t* restrict spec); +/** + * Reset a state according to hashing specifications + * + * @param state The state that should be reset + * @return Zero on success, -1 on error + */ +__attribute__((nonnull, nothrow, unused)) +static inline void libkeccak_state_reset(libkeccak_state_t* restrict state) +{ + state->mptr = 0; + __builtin_memset(state->S, 0, sizeof(state->S)); +} + + /** * Release resources allocation for a state without wiping sensitive data * -- cgit v1.2.3-70-g09d2