From 6e3af681aa5927d2ab2861e94c0cfea6fa42c0ab Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 10 Feb 2019 17:54:09 +0100 Subject: Minor improvement and man pages for HMAC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- hmac_digest.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'hmac_digest.c') diff --git a/hmac_digest.c b/hmac_digest.c index caee756..9cc4271 100644 --- a/hmac_digest.c +++ b/hmac_digest.c @@ -10,28 +10,24 @@ * `libsha2_hmac_update` and `libsha2_hmac_update` * can be called again * - * @param state The state of the algorithm - * @param data Data to feed into the algorithm - * @param n The number of bytes to feed into the algorithm - * @param output The output buffer for the hash, it will be as - * large as for the underlaying hash algorithm - * @return Zero on success, -1 on error + * @param state The state of the algorithm + * @param data Data to feed into the algorithm + * @param n The number of bytes to feed into the algorithm + * @param output The output buffer for the hash, it will be as + * large as for the underlaying hash algorithm */ -int +void libsha2_hmac_digest(struct libsha2_hmac_state *restrict state, const void *data, size_t n, void *output) { if (!state->inited) { - if (libsha2_init(&state->sha2_state, state->sha2_state.algorithm)) - return -1; + libsha2_init(&state->sha2_state, state->sha2_state.algorithm); libsha2_update(&state->sha2_state, state->ipad, state->sha2_state.chunk_size * 8); } libsha2_digest(&state->sha2_state, data, n, output); - if (libsha2_init(&state->sha2_state, state->sha2_state.algorithm)) - return -1; + libsha2_init(&state->sha2_state, state->sha2_state.algorithm); libsha2_update(&state->sha2_state, state->opad, state->sha2_state.chunk_size * 8); libsha2_digest(&state->sha2_state, output, state->outsize, output); state->inited = 0; - return 0; } -- cgit v1.2.3-70-g09d2