From 12abd974fdf8362d41d688c478528c6b8047fa87 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 8 Jan 2022 22:57:27 +0100 Subject: Add BLAKE2X MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libblake_blake2xs_digest.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 libblake_blake2xs_digest.c (limited to 'libblake_blake2xs_digest.c') diff --git a/libblake_blake2xs_digest.c b/libblake_blake2xs_digest.c new file mode 100644 index 0000000..0d4ffea --- /dev/null +++ b/libblake_blake2xs_digest.c @@ -0,0 +1,23 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + +void +libblake_blake2xs_digest(const struct libblake_blake2xs_state *state, + uint_least32_t i /* start 0, increase by 1 until i * 32 >= desired hash length */, + uint_least8_t len /* desired hash MIN(length - i * 32, 32) */, + unsigned char output[static len] /* output for hash offset by i * 32 */) +{ + struct libblake_blake2xs_state xstate; + struct libblake_blake2xs_params xparams; + + xparams = state->xof_params; + xparams.node_offset = i; + xparams.digest_len = len; + + libblake_internal_blake2xs_init0(&xstate, &xparams); + + xstate.b2s.f[0] = UINT_LEAST32_C(0xFFFFffff); + xstate.b2s.t[0] = (uint_least32_t)state->xof_params.digest_len & UINT_LEAST32_C(0xFFFFffff); + libblake_internal_blake2s_compress(&xstate.b2s, state->intermediate); + libblake_internal_blake2s_output_digest(&xstate.b2s, (size_t)len, output); +} -- cgit v1.2.3-70-g09d2