I have a hub that communicates with an IoT device and needs to change the encryption key on that device at frequent intervals.
Messages are AES-256-CBC encrypted using the old key, and the new key is included in those messages.
Once the new key is sent, I need to be absolutely sure that the hub and the device are in sync on what key is being used. Why? The connection can drop at any time.
Given that, here are some things I've thought of:
- Hub sends key, updating its own, then the device updates to the new key if it receives it. (What if the device doesn't receive the key?)
- Hub sends key, waits to update, then the device updates its key, then sends back a 'Key received', upon which the hub updates its own. (What happens if the device's message back never gets received?)
It seems to me that no matter what, there's a final communication that can cause a party to not confirm an update. Is there a way to make sure?