aboutsummaryrefslogtreecommitdiffstats
path: root/libblake_internal_blake2xs_init0.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-01-08 22:57:27 +0100
committerMattias Andrée <maandree@kth.se>2022-01-08 22:57:27 +0100
commit12abd974fdf8362d41d688c478528c6b8047fa87 (patch)
tree096ace7f908e66089f379248e9fe036a85e4a1cb /libblake_internal_blake2xs_init0.c
parentAdd last_node parameter to libblake_blake2[sb]_digest (diff)
downloadlibblake-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_internal_blake2xs_init0.c')
-rw-r--r--libblake_internal_blake2xs_init0.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/libblake_internal_blake2xs_init0.c b/libblake_internal_blake2xs_init0.c
new file mode 100644
index 0000000..92cb7bf
--- /dev/null
+++ b/libblake_internal_blake2xs_init0.c
@@ -0,0 +1,46 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+void
+libblake_internal_blake2xs_init0(struct libblake_blake2xs_state *state, const struct libblake_blake2xs_params *params)
+{
+ state->b2s.h[0] = UINT_LEAST32_C(0x6A09E667);
+ state->b2s.h[1] = UINT_LEAST32_C(0xBB67AE85);
+ state->b2s.h[2] = UINT_LEAST32_C(0x3C6EF372);
+ state->b2s.h[3] = UINT_LEAST32_C(0xA54FF53A);
+ state->b2s.h[4] = UINT_LEAST32_C(0x510E527F);
+ state->b2s.h[5] = UINT_LEAST32_C(0x9B05688C);
+ state->b2s.h[6] = UINT_LEAST32_C(0x1F83D9AB);
+ state->b2s.h[7] = UINT_LEAST32_C(0x5BE0CD19);
+
+ state->b2s.t[0] = 0;
+ state->b2s.t[1] = 0;
+ state->b2s.f[0] = 0;
+ state->b2s.f[1] = 0;
+
+ state->b2s.h[0] ^= ((uint_least32_t)params->digest_len & 255) << 0;
+ state->b2s.h[0] ^= ((uint_least32_t)params->key_len & 255) << 8;
+ state->b2s.h[0] ^= ((uint_least32_t)params->fanout & 255) << 16;
+ state->b2s.h[0] ^= ((uint_least32_t)params->depth & 255) << 24;
+ state->b2s.h[1] ^= params->leaf_len & UINT_LEAST32_C(0xFFFFffff);
+ state->b2s.h[2] ^= params->node_offset & UINT_LEAST32_C(0xFFFFffff);
+ state->b2s.h[3] ^= (uint_least32_t)(params->xof_len & UINT_LEAST16_C(0xFFFF)) << 0;
+ state->b2s.h[3] ^= ((uint_least32_t)params->node_depth & 255) << 16;
+ state->b2s.h[3] ^= ((uint_least32_t)params->inner_len & 255) << 24;
+ state->b2s.h[4] ^= ((uint_least32_t)params->salt[0] & 255) << 0;
+ state->b2s.h[4] ^= ((uint_least32_t)params->salt[1] & 255) << 8;
+ state->b2s.h[4] ^= ((uint_least32_t)params->salt[2] & 255) << 16;
+ state->b2s.h[4] ^= ((uint_least32_t)params->salt[3] & 255) << 24;
+ state->b2s.h[5] ^= ((uint_least32_t)params->salt[4] & 255) << 0;
+ state->b2s.h[5] ^= ((uint_least32_t)params->salt[5] & 255) << 8;
+ state->b2s.h[5] ^= ((uint_least32_t)params->salt[6] & 255) << 16;
+ state->b2s.h[5] ^= ((uint_least32_t)params->salt[7] & 255) << 24;
+ state->b2s.h[6] ^= ((uint_least32_t)params->pepper[0] & 255) << 0;
+ state->b2s.h[6] ^= ((uint_least32_t)params->pepper[1] & 255) << 8;
+ state->b2s.h[6] ^= ((uint_least32_t)params->pepper[2] & 255) << 16;
+ state->b2s.h[6] ^= ((uint_least32_t)params->pepper[3] & 255) << 24;
+ state->b2s.h[7] ^= ((uint_least32_t)params->pepper[4] & 255) << 0;
+ state->b2s.h[7] ^= ((uint_least32_t)params->pepper[5] & 255) << 8;
+ state->b2s.h[7] ^= ((uint_least32_t)params->pepper[6] & 255) << 16;
+ state->b2s.h[7] ^= ((uint_least32_t)params->pepper[7] & 255) << 24;
+}