From eb30a3d16105eefd388b119dde989940f9fd83b6 Mon Sep 17 00:00:00 2001 From: Zou Yong Date: Sun, 30 Apr 2017 20:51:06 +0800 Subject: [PATCH] Fix losing data issue of SALSA20 cipher If nonce received in more than one packet under some network condition, the salsa20 cipher decryption will lose cipher->nonce_len - left_len bytes of data. --- src/stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stream.c b/src/stream.c index 5d999bb0..e9612a05 100644 --- a/src/stream.c +++ b/src/stream.c @@ -505,7 +505,7 @@ stream_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity) uint8_t *nonce = cipher_ctx->nonce; size_t nonce_len = cipher->nonce_len; - plaintext->len -= nonce_len; + plaintext->len -= left_len; memcpy(nonce, cipher_ctx->chunk->data, nonce_len); cipher_ctx_set_nonce(cipher_ctx, nonce, nonce_len, 0);