Skip to content

Commit

Permalink
Only increment nonce on successful decryption
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Dec 4, 2017
1 parent b8b2be5 commit fb8c835
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/protocol/cipherstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,11 @@ int noise_cipherstate_decrypt_with_ad
/* Decrypt the ciphertext and check the MAC */
err = (*(state->decrypt))
(state, ad, ad_len, buffer->data, buffer->size - state->mac_len);
++(state->n);
if (err != NOISE_ERROR_NONE)
return err;

++(state->n);

/* Adjust the output length for the MAC and return */
buffer->size -= state->mac_len;
return NOISE_ERROR_NONE;
Expand Down

0 comments on commit fb8c835

Please sign in to comment.