I have two nodes that need to communicate, A is sending data to B. We just assume that AES-256 key is already shared across the nodes.
The only data being sent from A to B are a few bytes commanding a light bulb:
- Light ON: 08 09 0A 01 [8 byte counter]
- Light OFF: 08 09 0A 00 [8 byte counter]
Now, to protect the communication against replay attacks, I have appended that counter which is being incremented with step by 1 every time a command is sent.
The whole packet including the counter is being encrypted with AES-256 using the shared secret key and then it is being send to B.
Is this kind of protocol safe to be used in practice? Assuming that the attacker can see the encrypted traffic and its effect (light ON/OFF), is there any chance that he can generate a new valid command/string given that he don't posses AES key?
The counter will never be repeated.
A potential bad actor knows everything about my system except private key used to encrypt the string that I am writing on the wires.
Node B will only accept commands only if the counter is incremented in respect to the last one received.
We assume that implementation is ok.
I don't want to append a MAC or a random nonce to the packet. I only want to keep the packet as it is.