aboutsummaryrefslogtreecommitdiffstats
path: root/libblake_blake2s_init.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-01-19 22:39:52 +0100
committerMattias Andrée <maandree@kth.se>2022-01-19 22:39:52 +0100
commitcb9fd292424291ef4927f5bceb5910bf52a88a58 (patch)
tree83c6eadf1986d16c87941396accfba360ea4648c /libblake_blake2s_init.c
parentAdd todos about more tests being needed (diff)
downloadlibblake-cb9fd292424291ef4927f5bceb5910bf52a88a58.tar.gz
libblake-cb9fd292424291ef4927f5bceb5910bf52a88a58.tar.bz2
libblake-cb9fd292424291ef4927f5bceb5910bf52a88a58.tar.xz
Fix warnings
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libblake_blake2s_init.c')
-rw-r--r--libblake_blake2s_init.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/libblake_blake2s_init.c b/libblake_blake2s_init.c
index fae7e0c..e9eacb8 100644
--- a/libblake_blake2s_init.c
+++ b/libblake_blake2s_init.c
@@ -33,17 +33,24 @@ libblake_blake2s_init(struct libblake_blake2s_state *state, const struct libblak
state->f[0] = 0;
state->f[1] = 0;
- if (offsetof(struct libblake_blake2s_params, inner_len) == 17) {
- state->h[0] ^= le32(((uint_least32_t *)params)[0]);
- state->h[1] ^= le32(((uint_least32_t *)params)[1]);
+ if (CODE_KILLER(offsetof(struct libblake_blake2s_params, inner_len) == 17)) {
+#if defined(__clang__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wcast-align"
+#endif
+ state->h[0] ^= le32(((const uint_least32_t *)params)[0]);
+ state->h[1] ^= le32(((const uint_least32_t *)params)[1]);
state->h[2] ^= le32((uint_least32_t)(params->node_offset >> 0));
- state->h[3] ^= le32(((uint_least32_t)(params->node_offset >> 32) & UINT_LEAST64_C(0xFFFF)) |
+ state->h[3] ^= le32(((uint_least32_t)(params->node_offset >> 32) & UINT_LEAST32_C(0xFFFF)) |
((uint_least32_t)params->node_depth << 16) |
((uint_least32_t)params->inner_len << 24));
- state->h[4] ^= le32(*(uint_least32_t *)&params->salt[0]);
- state->h[5] ^= le32(*(uint_least32_t *)&params->salt[4]);
- state->h[6] ^= le32(*(uint_least32_t *)&params->pepper[0]);
- state->h[7] ^= le32(*(uint_least32_t *)&params->pepper[4]);
+ state->h[4] ^= le32(*(const uint_least32_t *)&params->salt[0]);
+ state->h[5] ^= le32(*(const uint_least32_t *)&params->salt[4]);
+ state->h[6] ^= le32(*(const uint_least32_t *)&params->pepper[0]);
+ state->h[7] ^= le32(*(const uint_least32_t *)&params->pepper[4]);
+#if defined(__clang__)
+# pragma clang diagnostic pop
+#endif
} else {
state->h[0] ^= ((uint_least32_t)params->digest_len & 255) << 0;
state->h[0] ^= ((uint_least32_t)params->key_len & 255) << 8;