aboutsummaryrefslogtreecommitdiffstats
path: root/update.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-07-08 13:23:00 +0200
committerMattias Andrée <maandree@kth.se>2022-07-08 13:23:00 +0200
commit312a92b5104fd5e9090bc079f458f9105a91e1ea (patch)
treea2f68787a2a3ffaf5ca17661c503daebd96bc453 /update.c
parentUse uint_leastN_t instead of uintN_t (diff)
downloadlibsha2-312a92b5104fd5e9090bc079f458f9105a91e1ea.tar.gz
libsha2-312a92b5104fd5e9090bc079f458f9105a91e1ea.tar.bz2
libsha2-312a92b5104fd5e9090bc079f458f9105a91e1ea.tar.xz
Use SHA extensions1.1
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--update.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/update.c b/update.c
index 4cf31a5..3c46f28 100644
--- a/update.c
+++ b/update.c
@@ -16,17 +16,13 @@ libsha2_update(struct libsha2_state *restrict state, const void *restrict messag
n = msglen < state->chunk_size - off ? msglen : state->chunk_size - off;
memcpy(&state->chunk[off], message, n);
if (off + n == state->chunk_size)
- libsha2_process(state, state->chunk);
- message += n;
+ libsha2_process(state, state->chunk, state->chunk_size);
+ message = &message[n];
msglen -= n;
}
- while (msglen >= state->chunk_size) {
- libsha2_process(state, (const unsigned char *)message);
- message += state->chunk_size;
- msglen -= state->chunk_size;
- }
+ off = libsha2_process(state, (const unsigned char *)message, msglen);
- if (msglen)
- memcpy(state->chunk, message, msglen);
+ if (msglen > off)
+ memcpy(state->chunk, &message[off], msglen - off);
}