Fix decryption failed issue by nonce overwrite

If the first packet is less than nonce length, then the chunk nonce data will be overwrote by next packet and result in decrypt failed
This commit is contained in:
Zou Yong
2017-04-28 19:35:42 +08:00
committed by Max Lv
parent c6bc21bc1a
commit 0559d8ce2e
+1 -1
View File
@@ -493,7 +493,7 @@ stream_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)
ciphertext->len);
if (left_len > 0) {
memcpy(cipher_ctx->chunk->data, ciphertext->data, left_len);
memcpy(cipher_ctx->chunk->data + cipher_ctx->chunk->len, ciphertext->data, left_len);
memmove(ciphertext->data, ciphertext->data + left_len,
ciphertext->len - left_len);
cipher_ctx->chunk->len += left_len;