aboutsummaryrefslogtreecommitdiffstats
path: root/libblake_blake2b_update.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-01-07 19:52:35 +0100
committerMattias Andrée <maandree@kth.se>2022-01-07 20:21:49 +0100
commit6adc0e6c6c378b5438533bdf55636ef049c1b956 (patch)
treeea55a4f54d7d190a1634c0a7ec8054fa2cdf47fd /libblake_blake2b_update.c
parentlibblake_decode_hex: verify input (diff)
downloadlibblake-6adc0e6c6c378b5438533bdf55636ef049c1b956.tar.gz
libblake-6adc0e6c6c378b5438533bdf55636ef049c1b956.tar.bz2
libblake-6adc0e6c6c378b5438533bdf55636ef049c1b956.tar.xz
Add BLAKE2b and BLAKE2s + add salt support to BLAKE + m
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libblake_blake2b_update.c')
-rw-r--r--libblake_blake2b_update.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libblake_blake2b_update.c b/libblake_blake2b_update.c
new file mode 100644
index 0000000..cbd38f2
--- /dev/null
+++ b/libblake_blake2b_update.c
@@ -0,0 +1,19 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+size_t
+libblake_blake2b_update(struct libblake_blake2b_state *state, const void *data_, size_t len)
+{
+ const unsigned char *data = data_;
+ size_t off = 0;
+
+ for (; len - off > 128; off += 128) {
+ state->t[0] = (state->t[0] + 128) & UINT_LEAST64_C(0xFFFFffffFFFFffff);
+ if (state->t[0] < 128)
+ state->t[1] = (state->t[1] + 1) & UINT_LEAST64_C(0xFFFFffffFFFFffff);
+
+ libblake_internal_blake2b_compress(state, &data[off]);
+ }
+
+ return off;
+}