From 179063dcbd425bf8003a26637a966cb116b3a3d0 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 13 Jan 2022 00:15:11 +0100 Subject: Add *_force_update for BLAKE2[X] (intended for parallel hashing) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libblake_blake2s_force_update.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 libblake_blake2s_force_update.c (limited to 'libblake_blake2s_force_update.c') diff --git a/libblake_blake2s_force_update.c b/libblake_blake2s_force_update.c new file mode 100644 index 0000000..925d381 --- /dev/null +++ b/libblake_blake2s_force_update.c @@ -0,0 +1,19 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + +size_t +libblake_blake2s_force_update(struct libblake_blake2s_state *state, const void *data_, size_t len) +{ + const unsigned char *data = data_; + size_t off = 0; + + for (; len - off >= 64; off += 64) { + state->t[0] = (state->t[0] + 64) & UINT_LEAST32_C(0xFFFFffff); + if (state->t[0] < 64) + state->t[1] = (state->t[1] + 1) & UINT_LEAST32_C(0xFFFFffff); + + libblake_internal_blake2s_compress(state, &data[off]); + } + + return off; +} -- cgit v1.2.3-70-g09d2