Browse Source

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.
pull/1494/head
Zou Yong 7 years ago
committed by Max Lv
parent
commit
eb30a3d161
1 changed files with 1 additions and 1 deletions
  1. 2
      src/stream.c

2
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);

Loading…
Cancel
Save