aboutsummaryrefslogtreecommitdiffstats
path: root/hmac_digest.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-02-10 17:54:09 +0100
committerMattias Andrée <maandree@kth.se>2019-02-10 17:54:09 +0100
commit6e3af681aa5927d2ab2861e94c0cfea6fa42c0ab (patch)
treedc14cf6beeab03da867e7946bd6ab3601a66d370 /hmac_digest.c
parentlibsha2.h.0: securely erasing the state (diff)
downloadlibsha2-6e3af681aa5927d2ab2861e94c0cfea6fa42c0ab.tar.gz
libsha2-6e3af681aa5927d2ab2861e94c0cfea6fa42c0ab.tar.bz2
libsha2-6e3af681aa5927d2ab2861e94c0cfea6fa42c0ab.tar.xz
Minor improvement and man pages for HMAC
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'hmac_digest.c')
-rw-r--r--hmac_digest.c20
1 files changed, 8 insertions, 12 deletions
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;
}