diff --git a/src/protocol/cipherstate.c b/src/protocol/cipherstate.c index 3c839f11..2f484388 100644 --- a/src/protocol/cipherstate.c +++ b/src/protocol/cipherstate.c @@ -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;