diff options
author | Mattias Andrée <maandree@kth.se> | 2019-02-10 20:21:19 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2019-02-10 20:21:19 +0100 |
commit | ed0296b9055713df0d910e4e7528ffe6fc539514 (patch) | |
tree | 8cbf8ecc9b6352257d6bc4946ff75cb8a4b484c0 /hmac_update.c | |
download | libsha1-ed0296b9055713df0d910e4e7528ffe6fc539514.tar.gz libsha1-ed0296b9055713df0d910e4e7528ffe6fc539514.tar.bz2 libsha1-ed0296b9055713df0d910e4e7528ffe6fc539514.tar.xz |
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'hmac_update.c')
-rw-r--r-- | hmac_update.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/hmac_update.c b/hmac_update.c new file mode 100644 index 0000000..40528a4 --- /dev/null +++ b/hmac_update.c @@ -0,0 +1,23 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +/** + * Feed data into the HMAC algorithm + * + * @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, this must be a multiple of 8 + */ +void +libsha1_hmac_update(struct libsha1_hmac_state *restrict state, const void *restrict data, size_t n) +{ + if (!state->inited) { + libsha1_init(&state->sha1_state, state->sha1_state.algorithm); + libsha1_update(&state->sha1_state, state->ipad, state->sha1_state.chunk_size * 8); + state->inited = 1; + } + + libsha1_update(&state->sha1_state, data, n); +} |