diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-03-27 18:08:19 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-03-27 18:08:19 +0100 |
commit | 2aecdd106f20816cee7e85902d7c517606b1e563 (patch) | |
tree | e423a407a56b87a8e75e0bf7c8884bff74953d54 | |
parent | dbd56ac3969f3d100e945fc27599cf8ccdd098e9 (diff) |
blake2s: remove outlen parameter from final
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | src/cookie.c | 4 | ||||
-rw-r--r-- | src/crypto/include/zinc/blake2s.h | 4 | ||||
-rw-r--r-- | src/crypto/zinc/blake2s/blake2s.c | 11 | ||||
-rw-r--r-- | src/noise.c | 4 |
4 files changed, 11 insertions, 12 deletions
diff --git a/src/cookie.c b/src/cookie.c index bd23a14..a2ddbcd 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 8035cee..2ca0bc3 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 5bf76e2..e9e0bda 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 bf0b8c5..5b073bd 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], |