There are many threads here explaining the need of a random and unpredictable IV for the AES-CBC.
I am building a home automation system with security for a school project where a Raspberry Pi creates a separated WPA2 network to communicate with many ESP8266 Wi-fi modules via HTTP requests. Each new message from the central node is encrypted with a key and a newly generated(using "/dev/urandom") IV.
The message payload structure is:
plain-text IV || cipher-text || HMAC-SHA256
However, the answer of a GET request needs to be encrypted too. From what I read, encrypting the answer with the same IV from the received request may not be the ideal.
So is it okay for the central node to send another IV, which the esp8266 is going to use for encrypting the answer?
And what is the best way to send this IV?
- Inside the encrypted message(cipher), or
As plaintext, making the payload:
IV2 || IV1 || cipher || HMAC(hash of IV2 || IV1 || cipher)