I am implementing a radio protocol and trying to prevent replay attacks. It is an embedded system so storing nonce values is not an option, as each node in the system may talk to each other.
My plan is to implement a challenge response system to authenticate both ends of the communication. Instead of separately generating a unique value for the challenge, my intention is to use the nonce as the challenge and then encrypt the nonce using ChaCha20 and the pre-shared key for the challenge response.
Is it safe to encrypt the previous nonce? This will not be a random unpredictable value, but it will be unique and it wont be the same nonce that is used to encrypt the current packet. The attacker will know both the plain text and the encrypted form (is they know the protocol), but this only helps for a brute force attack, I believe?
The packets are authenticated with poly1305 using the same key.