aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-03-27 18:08:19 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-27 18:08:19 +0100
commit34171de2868063bc2945340a388f7f45081821ed (patch)
tree36d2d349a9bc4d7055c8732f0e147e489a6d446f
parentblake2s: simplify (diff)
downloadWireGuard-34171de2868063bc2945340a388f7f45081821ed.tar.xz
WireGuard-34171de2868063bc2945340a388f7f45081821ed.zip
blake2s: remove outlen parameter from final
-rw-r--r--src/cookie.c4
-rw-r--r--src/crypto/include/zinc/blake2s.h4
-rw-r--r--src/crypto/zinc/blake2s/blake2s.c11
-rw-r--r--src/noise.c4
4 files changed, 11 insertions, 12 deletions
diff --git a/src/cookie.c b/src/cookie.c
index bd23a14f..a2ddbcd2 100644
--- a/src/cookie.c
+++ b/src/cookie.c
@@ -38,7 +38,7 @@ static void precompute_key(u8 key[NOISE_SYMMETRIC_KEY_LEN],
blake2s_init(&blake, NOISE_SYMMETRIC_KEY_LEN);
blake2s_update(&blake, label, COOKIE_KEY_LABEL_LEN);
blake2s_update(&blake, pubkey, NOISE_PUBLIC_KEY_LEN);
- blake2s_final(&blake, key, NOISE_SYMMETRIC_KEY_LEN);
+ blake2s_final(&blake, key);
}
/* Must hold peer->handshake.static_identity->lock */
@@ -111,7 +111,7 @@ static void make_cookie(u8 cookie[COOKIE_LEN], struct sk_buff *skb,
blake2s_update(&state, (u8 *)&ipv6_hdr(skb)->saddr,
sizeof(struct in6_addr));
blake2s_update(&state, (u8 *)&udp_hdr(skb)->source, sizeof(__be16));
- blake2s_final(&state, cookie, COOKIE_LEN);
+ blake2s_final(&state, cookie);
up_read(&checker->secret_lock);
}
diff --git a/src/crypto/include/zinc/blake2s.h b/src/crypto/include/zinc/blake2s.h
index 8035cee3..2ca0bc30 100644
--- a/src/crypto/include/zinc/blake2s.h
+++ b/src/crypto/include/zinc/blake2s.h
@@ -29,7 +29,7 @@ void blake2s_init(struct blake2s_state *state, const size_t outlen);
void blake2s_init_key(struct blake2s_state *state, const size_t outlen,
const void *key, const size_t keylen);
void blake2s_update(struct blake2s_state *state, const u8 *in, size_t inlen);
-void blake2s_final(struct blake2s_state *state, u8 *out, const size_t outlen);
+void blake2s_final(struct blake2s_state *state, u8 *out);
static inline void blake2s(u8 *out, const u8 *in, const u8 *key,
const size_t outlen, const size_t inlen,
@@ -47,7 +47,7 @@ static inline void blake2s(u8 *out, const u8 *in, const u8 *key,
blake2s_init(&state, outlen);
blake2s_update(&state, in, inlen);
- blake2s_final(&state, out, outlen);
+ blake2s_final(&state, out);
}
void blake2s_hmac(u8 *out, const u8 *in, const u8 *key, const size_t outlen,
diff --git a/src/crypto/zinc/blake2s/blake2s.c b/src/crypto/zinc/blake2s/blake2s.c
index 5bf76e21..e9e0bdaf 100644
--- a/src/crypto/zinc/blake2s/blake2s.c
+++ b/src/crypto/zinc/blake2s/blake2s.c
@@ -194,10 +194,9 @@ void blake2s_update(struct blake2s_state *state, const u8 *in, size_t inlen)
}
EXPORT_SYMBOL(blake2s_update);
-void blake2s_final(struct blake2s_state *state, u8 *out, const size_t outlen)
+void blake2s_final(struct blake2s_state *state, u8 *out)
{
- WARN_ON(IS_ENABLED(DEBUG) &&
- (!out || outlen < state->outlen));
+ WARN_ON(IS_ENABLED(DEBUG) && !out);
blake2s_set_lastblock(state);
memset(state->buf + state->buflen, 0,
BLAKE2S_BLOCK_SIZE - state->buflen); /* Padding */
@@ -219,7 +218,7 @@ void blake2s_hmac(u8 *out, const u8 *in, const u8 *key, const size_t outlen,
if (keylen > BLAKE2S_BLOCK_SIZE) {
blake2s_init(&state, BLAKE2S_HASH_SIZE);
blake2s_update(&state, key, keylen);
- blake2s_final(&state, x_key, BLAKE2S_HASH_SIZE);
+ blake2s_final(&state, x_key);
} else
memcpy(x_key, key, keylen);
@@ -229,7 +228,7 @@ void blake2s_hmac(u8 *out, const u8 *in, const u8 *key, const size_t outlen,
blake2s_init(&state, BLAKE2S_HASH_SIZE);
blake2s_update(&state, x_key, BLAKE2S_BLOCK_SIZE);
blake2s_update(&state, in, inlen);
- blake2s_final(&state, i_hash, BLAKE2S_HASH_SIZE);
+ blake2s_final(&state, i_hash);
for (i = 0; i < BLAKE2S_BLOCK_SIZE; ++i)
x_key[i] ^= 0x5c ^ 0x36;
@@ -237,7 +236,7 @@ void blake2s_hmac(u8 *out, const u8 *in, const u8 *key, const size_t outlen,
blake2s_init(&state, BLAKE2S_HASH_SIZE);
blake2s_update(&state, x_key, BLAKE2S_BLOCK_SIZE);
blake2s_update(&state, i_hash, BLAKE2S_HASH_SIZE);
- blake2s_final(&state, i_hash, BLAKE2S_HASH_SIZE);
+ blake2s_final(&state, i_hash);
memcpy(out, i_hash, outlen);
memzero_explicit(x_key, BLAKE2S_BLOCK_SIZE);
diff --git a/src/noise.c b/src/noise.c
index bf0b8c5a..5b073bd3 100644
--- a/src/noise.c
+++ b/src/noise.c
@@ -40,7 +40,7 @@ void __init wg_noise_init(void)
blake2s_init(&blake, NOISE_HASH_LEN);
blake2s_update(&blake, handshake_init_chaining_key, NOISE_HASH_LEN);
blake2s_update(&blake, identifier_name, sizeof(identifier_name));
- blake2s_final(&blake, handshake_init_hash, NOISE_HASH_LEN);
+ blake2s_final(&blake, handshake_init_hash);
}
/* Must hold peer->handshake.static_identity->lock */
@@ -389,7 +389,7 @@ static void mix_hash(u8 hash[NOISE_HASH_LEN], const u8 *src, size_t src_len)
blake2s_init(&blake, NOISE_HASH_LEN);
blake2s_update(&blake, hash, NOISE_HASH_LEN);
blake2s_update(&blake, src, src_len);
- blake2s_final(&blake, hash, NOISE_HASH_LEN);
+ blake2s_final(&blake, hash);
}
static void mix_psk(u8 chaining_key[NOISE_HASH_LEN], u8 hash[NOISE_HASH_LEN],