From e40e0f6ddbba0b0a11435c4274f822ce47c23b91 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 26 Aug 2017 17:46:49 +0200 Subject: [PATCH] Adjust secretstream_..._rekey() after e84336ac --- .../xchacha20poly1305/secretstream_xchacha20poly1305.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c b/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c index 1207b5d8..1a8f71f8 100644 --- a/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c +++ b/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c @@ -78,10 +78,10 @@ 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); - memcpy(state->nonce, new_key_and_inonce + sizeof state->k, + memset(state->nonce, 0, crypto_secretstream_xchacha20poly1305_COUNTERBYTES); + memcpy(state->nonce + crypto_secretstream_xchacha20poly1305_COUNTERBYTES, + new_key_and_inonce + sizeof state->k, crypto_secretstream_xchacha20poly1305_INONCEBYTES); - memset(state->nonce + crypto_secretstream_xchacha20poly1305_INONCEBYTES, 0, - crypto_secretstream_xchacha20poly1305_COUNTERBYTES); } int