I am planning to build temperature sensor nodes for my home heater control. Central device will control the heater using temperature data read by nodes. These nodes will send temperature data to central device over RF communication periodically. There will be no acknowledge from central device to nodes. I want to learn something about encrypted communication at the same time. I have little general knowledge and no experience about encryption.
It is common that today microcontrollers have built-in cryptographic engine supporting AES with ECB, CBC, OFB, CTR and CFB128 modes with true random number generator. (ref)
I have two goals:
- Communication should be encrypted. Attacker can't read the temperature value by sniffing.
- Once a node sends a encrypted message, this messages should become invalid for retransmission. For example, each message should be different even if a node transmits the same temperature value. Attacker can't act as a true sensor node by transmiting false temperature values to my heater.
My questions are: (Please consider that I have no background in cryptography.)
Encryption is not so hard. For example, I may use AES-128. But simple ECB mode doesn't satisfy my goal #2. If temperature doesn't change, AES-128 output will also be the same. AFAIU I should use encryption + authentication. I have to ensure that encrypted message is sent from a valid node not from an attacker. Is authentication term is the correct one for this case? For example, does AES-CCM overcome this problem? I read several sources about AES-CCM and other encryption + authentication methods and I couldn't correlate my problem with the authentication term used in cryptography.
Let's say that node increments a counter by one at each transmission. Plain data is now value of counter + temperature. Plain data is encrypted and sent. Counter ensures that data changes even if temperature is the same. Receiver now tracks value of the counter and ignores the message if it is not incremented by one (or within a range). It should help me to satisfy goal #2. I think this approach is similar to Keeloq algorithm. Attacker shouldn't guess the next encrypted text easily. Does it make sense?
Hardware has true random number generator. Can it be used somehow to make communication more "secure"? For example plain text = value of counter + data + some random bits. Does random bit stuffing make any improvement?
Probably my ideas are the worst ones. What would you suggest for data validation? How can a node "sign" its data?