I am currently working with a symmetric algorithm which requires a nonce for encryption, and logically for decryption as well.
However, I am a bit confused about how I would go and synchronize the nonce on both clients.
Let's say my nonce is starting at 0 and is hardcoded on both sides.
I would then encrypt my data, and increase the nonce to avoid leakage through reuse. The encrypted value will be sent to my client, which decrypts the data and increases the nonce as well. Now both parties have a nonce of 1, ready for the next encryption/decryption cycle.
This works well, as long as there are no unexpected things happening.
Let's say the server is now encrypting with a nonce of 5. It increases the nonce to 6 afterwards, but somehow the connection failed, and the value is never transmitted. The other participant does not receive an update and his nonce will stay at 5.
The next time we encrypt something, the encryptor now uses the nonce 6, increases it and sends the value. The decryptor side however is still at a nonce of 5 and the decryption will therefore fail.
How do I get out of this cycle? How can I securely synchronize the nonces, so I can avoid complete failure if the connection will fail at least once? Is it secure to just transmit the current nonce with every data package? Are there any other approaches?