aboutsummaryrefslogtreecommitdiffstats
path: root/update.c
diff options
context:
space:
mode:
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);
}