diff options
author | Mattias Andrée <maandree@kth.se> | 2022-01-08 22:57:27 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-01-08 22:57:27 +0100 |
commit | 12abd974fdf8362d41d688c478528c6b8047fa87 (patch) | |
tree | 096ace7f908e66089f379248e9fe036a85e4a1cb /libblake_blake2xb_digest.c | |
parent | Add last_node parameter to libblake_blake2[sb]_digest (diff) | |
download | libblake-12abd974fdf8362d41d688c478528c6b8047fa87.tar.gz libblake-12abd974fdf8362d41d688c478528c6b8047fa87.tar.bz2 libblake-12abd974fdf8362d41d688c478528c6b8047fa87.tar.xz |
Add BLAKE2X
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libblake_blake2xb_digest.c')
-rw-r--r-- | libblake_blake2xb_digest.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libblake_blake2xb_digest.c b/libblake_blake2xb_digest.c new file mode 100644 index 0000000..b9a65ec --- /dev/null +++ b/libblake_blake2xb_digest.c @@ -0,0 +1,23 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + +void +libblake_blake2xb_digest(const struct libblake_blake2xb_state *state, + uint_least32_t i /* start 0, increase by 1 until i * 64 >= desired hash length */, + uint_least8_t len /* desired hash MIN(length - i * 64, 64) */, + unsigned char output[static len] /* output for hash offset by i * 64 */) +{ + struct libblake_blake2xb_state xstate; + struct libblake_blake2xb_params xparams; + + xparams = state->xof_params; + xparams.node_offset = i; + xparams.digest_len = len; + + libblake_internal_blake2xb_init0(&xstate, &xparams); + + xstate.b2b.f[0] = UINT_LEAST64_C(0xFFFFffffFFFFffff); + xstate.b2b.t[0] = (uint_least64_t)state->xof_params.digest_len & UINT_LEAST64_C(0xFFFFffffFFFFffff); + libblake_internal_blake2b_compress(&xstate.b2b, state->intermediate); + libblake_internal_blake2b_output_digest(&xstate.b2b, (size_t)len, output); +} |