diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-01-06 16:59:01 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-01-06 17:28:13 +0100 |
commit | 0a0cea209c0daecfb32e78bd4078221e882e2d1e (patch) | |
tree | 1432dc57a1ef7b49852bd75477be04cef69cf606 /installer | |
parent | global: use strings.Cut where possible (diff) | |
download | wireguard-windows-0a0cea209c0daecfb32e78bd4078221e882e2d1e.tar.xz wireguard-windows-0a0cea209c0daecfb32e78bd4078221e882e2d1e.zip |
fetcher: only write 32 bytes to hash output
Current binaries overflow into `wchar_t total_bytes_str[22]`, which is
not used anywhere after the overflow, so no harm done thankfully.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'installer')
-rw-r--r-- | installer/fetcher/crypto.c | 4 | ||||
-rw-r--r-- | installer/fetcher/crypto.h | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/installer/fetcher/crypto.c b/installer/fetcher/crypto.c index 880cff30..e924ec02 100644 --- a/installer/fetcher/crypto.c +++ b/installer/fetcher/crypto.c @@ -2239,7 +2239,7 @@ void blake2b256_update(struct blake2b256_state *state, const uint8_t *in, state->buflen += inlen; } -void blake2b256_final(struct blake2b256_state *state, uint8_t *out) +void blake2b256_final(struct blake2b256_state *state, uint8_t out[32]) { state->t[0] += state->buflen; state->t[1] += (state->t[0] < state->buflen); @@ -2247,6 +2247,6 @@ void blake2b256_final(struct blake2b256_state *state, uint8_t *out) memset(state->buf + state->buflen, 0, 128 - state->buflen); blake2b256_compress(state, state->buf); - for (int i = 0; i < 8; ++i) + for (int i = 0; i < 4; ++i) store_le64(out + i * sizeof(state->h[i]), state->h[i]); } diff --git a/installer/fetcher/crypto.h b/installer/fetcher/crypto.h index 51691a46..d5f846fc 100644 --- a/installer/fetcher/crypto.h +++ b/installer/fetcher/crypto.h @@ -21,7 +21,7 @@ struct blake2b256_state { void blake2b256_init(struct blake2b256_state *state); void blake2b256_update(struct blake2b256_state *state, const uint8_t *in, unsigned int inlen); -void blake2b256_final(struct blake2b256_state *state, uint8_t *out); +void blake2b256_final(struct blake2b256_state *state, uint8_t out[32]); bool ed25519_verify(const uint8_t signature[64], const uint8_t public_key[32], const void *message, size_t message_size); |