From 7973cc5a378687f21c29fcfa04975e2ded6456ff Mon Sep 17 00:00:00 2001 From: Pantelis Antoniou Date: Tue, 12 Sep 2023 11:08:43 +0300 Subject: [PATCH] Fix expected zeroes at output When buffer sizes are small in streaming mode the partial output must have the rest of the buffer filled with zeroes. Signed-off-by: Pantelis Antoniou --- c/blake3.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/c/blake3.c b/c/blake3.c index 512adda..3fdec6c 100644 --- a/c/blake3.c +++ b/c/blake3.c @@ -64,7 +64,9 @@ INLINE output_t make_output(const uint32_t input_cv[8], uint8_t flags) { output_t ret; memcpy(ret.input_cv, input_cv, 32); - memcpy(ret.block, block, BLAKE3_BLOCK_LEN); + // copy out what's there and fill the rest with zeroes + memcpy(ret.block, block, block_len); + memset(ret.block + block_len, 0, BLAKE3_BLOCK_LEN - block_len); ret.block_len = block_len; ret.counter = counter; ret.flags = flags;