aboutsummaryrefslogtreecommitdiffstats
path: root/libblake_blake2b_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'libblake_blake2b_init.c')
-rw-r--r--libblake_blake2b_init.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/libblake_blake2b_init.c b/libblake_blake2b_init.c
index f07d1ef..cf5f35f 100644
--- a/libblake_blake2b_init.c
+++ b/libblake_blake2b_init.c
@@ -37,15 +37,22 @@ libblake_blake2b_init(struct libblake_blake2b_state *state, const struct libblak
state->f[0] = 0;
state->f[1] = 0;
- if (offsetof(struct libblake_blake2b_params, inner_len) == 17) {
- state->h[0] ^= le64(((uint_least64_t *)params)[0]);
- state->h[1] ^= le64(((uint_least64_t *)params)[1]);
+ if (CODE_KILLER(offsetof(struct libblake_blake2b_params, inner_len) == 17)) {
+#if defined(__clang__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wcast-align"
+#endif
+ state->h[0] ^= le64(((const uint_least64_t *)params)[0]);
+ state->h[1] ^= le64(((const uint_least64_t *)params)[1]);
state->h[2] ^= le64(((uint_least64_t)params->node_depth << 0) |
((uint_least64_t)params->inner_len << 8));
- state->h[4] ^= le64(*(uint_least64_t *)&params->salt[0]);
- state->h[5] ^= le64(*(uint_least64_t *)&params->salt[8]);
- state->h[6] ^= le64(*(uint_least64_t *)&params->pepper[0]);
- state->h[7] ^= le64(*(uint_least64_t *)&params->pepper[8]);
+ state->h[4] ^= le64(*(const uint_least64_t *)&params->salt[0]);
+ state->h[5] ^= le64(*(const uint_least64_t *)&params->salt[8]);
+ state->h[6] ^= le64(*(const uint_least64_t *)&params->pepper[0]);
+ state->h[7] ^= le64(*(const uint_least64_t *)&params->pepper[8]);
+#if defined(__clang__)
+# pragma clang diagnostic pop
+#endif
} else {
state->h[0] ^= ((uint_least64_t)params->digest_len & 255) << 0;
state->h[0] ^= ((uint_least64_t)params->key_len & 255) << 8;