summaryrefslogtreecommitdiffstats
path: root/src/blake2s.c
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@mail.noconroy.net>2019-08-12 22:52:40 +1000
committerMatt Dunwoodie <ncon@mail.noconroy.net>2019-08-12 22:52:40 +1000
commit6455074122da594d20ec8c83c8f1e7f717e7843f (patch)
tree9cf455db9a0c3e95204358fabacc145758b0a87c /src/blake2s.c
parentPrevent peer from using local key (diff)
downloadwireguard-openbsd-6455074122da594d20ec8c83c8f1e7f717e7843f.tar.xz
wireguard-openbsd-6455074122da594d20ec8c83c8f1e7f717e7843f.zip
Make compilable on octeon
# Conflicts: # src/if_wg.c
Diffstat (limited to 'src/blake2s.c')
-rw-r--r--src/blake2s.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/blake2s.c b/src/blake2s.c
index d39685693a4..f9f98ea915e 100644
--- a/src/blake2s.c
+++ b/src/blake2s.c
@@ -14,11 +14,6 @@
#include <crypto/blake2s.h>
-#define htole32_array(a) for(int i = 0; i < (sizeof(a)/sizeof(a[0])); i++) \
- (a[i]) = htole32((a[i]))
-#define le32toh_array(a) for(int i = 0; i < (sizeof(a)/sizeof(a[0])); i++) \
- (a[i]) = le32toh((a[i]))
-
static inline uint32_t
ror32(uint32_t word, unsigned int shift)
{
@@ -127,7 +122,8 @@ static inline void blake2s_compress(struct blake2s_state *state,
while (nblocks > 0) {
blake2s_increment_counter(state, inc);
memcpy(m, block, BLAKE2S_BLOCK_SIZE);
- le32toh_array(m);
+ for(i = 0; i < (sizeof(m)/sizeof(m[0])); i++)
+ (m[i]) = le32toh((m[i]));
memcpy(v, state->h, 32);
v[ 8] = blake2s_iv[0];
v[ 9] = blake2s_iv[1];
@@ -208,13 +204,16 @@ void blake2s_update(struct blake2s_state *state, const u_int8_t *in, size_t inle
void blake2s_final(struct blake2s_state *state, u_int8_t *out, const size_t outlen)
{
+ int i;
/*WARN_ON(IS_ENABLED(DEBUG) &&
(!out || !outlen || outlen > BLAKE2S_HASH_SIZE));*/
blake2s_set_lastblock(state);
memset(state->buf + state->buflen, 0,
BLAKE2S_BLOCK_SIZE - state->buflen); /* Padding */
blake2s_compress(state, state->buf, 1, state->buflen);
- htole32_array(state->h);
+ for(i = 0; i < (sizeof(state->h)/sizeof(state->h[0])); i++)
+ (state->h[i]) = htole32((state->h[i]));
+
memcpy(out, state->h, outlen);
explicit_bzero(state, sizeof(*state));
}