diff options
author | Mattias Andrée <maandree@kth.se> | 2022-07-08 13:23:00 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-07-08 13:23:00 +0200 |
commit | 312a92b5104fd5e9090bc079f458f9105a91e1ea (patch) | |
tree | a2f68787a2a3ffaf5ca17661c503daebd96bc453 /update.c | |
parent | Use uint_leastN_t instead of uintN_t (diff) | |
download | libsha2-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.c | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -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); } |