From bb1b27fa36751eb8d58b74c9a093e676c699626d Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Mon, 18 Sep 2017 18:55:56 +0200 Subject: [PATCH] Improve readability --- .../xchacha20poly1305/secretstream_xchacha20poly1305.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c b/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c index 49ef411e..bdca9c63 100644 --- a/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c +++ b/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c @@ -79,10 +79,12 @@ crypto_secretstream_xchacha20poly1305_rekey crypto_stream_chacha20_ietf(new_key_and_inonce, sizeof new_key_and_inonce, state->nonce, state->k); - memcpy(state->k, new_key_and_inonce, sizeof state->k); - memset(STATE_COUNTER(state), 0, crypto_secretstream_xchacha20poly1305_COUNTERBYTES); - memcpy(STATE_INONCE(state), new_key_and_inonce + sizeof state->k, + memcpy(state->k, new_key_and_inonce, crypto_stream_chacha20_ietf_KEYBYTES); + memcpy(STATE_INONCE(state), + new_key_and_inonce + crypto_stream_chacha20_ietf_KEYBYTES, crypto_secretstream_xchacha20poly1305_INONCEBYTES); + memset(STATE_COUNTER(state), 0, + crypto_secretstream_xchacha20poly1305_COUNTERBYTES); } int