IoT Encryption and Digital Signatures


IoT Encryption and Digital Signatures

Michael
Welcome to our discussion of secure connectivity in IoT devices. We’ll focus on symmetric and asymmetric encryption, and then see how asymmetric cryptography supports digital signatures, key exchange, and entity authentication.

Hope
Let’s start by connecting those tools to the security goals they help achieve. Both symmetric and asymmetric encryption protect confidentiality: they encode data so a third party can’t simply read it.

Michael
Authentication and integrity involve additional mechanisms. Digital signatures and certificates can help with authentication, while message authentication codes—often paired with symmetric encryption—can check that messages are authentic and unchanged.

Hope
And digital signatures also support non-repudiation: they can help provide evidence of a message’s origin and whether it was sent and received. We won’t go deeper into non-repudiation here, but it’s useful to know where it fits.

Michael
Before comparing encryption types, we need to distinguish entity authentication from message authentication. Entity authentication happens at the beginning of a communication session. For example, a sensor checks that it has connected to the real server it intended to reach, rather than an impostor in a man-in-the-middle attack.

Hope
But verifying the other party once doesn’t automatically verify every message that follows. An attacker might insert a message during the conversation, or a message might be corrupted while being transmitted.

Michael
That’s where message authentication comes in. It checks each message to help establish that it came from the party you originally connected to, and that its contents weren’t altered. So entity authentication checks who you’re talking to at the start; message authentication checks the messages throughout the conversation.

Hope
Now let’s take symmetric encryption. It uses one shared secret key at both ends. The endpoint uses that key to encrypt data for the server, and the server uses the same key to decrypt it. The server can also encrypt a reply with that key for the endpoint to decrypt.

Michael
Common symmetric ciphers include AES, DES, 3DES, and ChaCha20. AES is by far the most popular. DES and 3DES are being eliminated in TLS 1.3, leaving ChaCha20 as an alternative to AES in this context.

Hope
Symmetric encryption is especially useful for bulk data encryption because it’s relatively efficient for a processor—much more so than asymmetric encryption. That’s why the great majority of encrypted internet traffic uses symmetric encryption for the data itself.

Michael
Its central challenge is getting the shared key to both parties safely. If an attacker intercepts that key while it’s being exchanged, they could use it to decrypt subsequent traffic. We’ll see how asymmetric cryptography can help solve that key-exchange problem.

Hope
Symmetric ciphers are also commonly paired with message authentication. Examples include AES-GCM and ChaCha20-Poly1305. The authentication mechanism generates a message authentication code, or MAC, to help show that the message hasn’t been tampered with and belongs to the conversation.

Michael
As described here, the MAC is generated using a hash of the message, a sequence or session number, and the symmetric key. Including sequence or session information helps prevent replay attacks, where an attacker tries to reuse previously sent packets. Using the shared key also ties the message to the communication that uses that key.

Hope
So a MAC serves two important checks: the message is unchanged, and it legitimately belongs to the communication rather than being inserted by an unknown third party. That’s message authentication alongside encryption—not just hiding the data.

Michael
Asymmetric cryptography works differently. Instead of one shared key, it uses a public-and-private key pair. In one direction, a server sends its public key to an endpoint. The endpoint encrypts data with that public key, and the server uses the corresponding private key to decrypt it.

Hope
The public key is designed to be shared, so it can be sent openly. The private key must stay secret. If the server also needs to send encrypted data to the endpoint, the endpoint needs its own public-and-private key pair: the server encrypts using the endpoint’s public key, and the endpoint decrypts using its private key.

Michael
That means two-way asymmetric encryption uses four keys in all: a public and private key at each end. The public keys can be shared, but each private key is kept secret and isn’t transmitted. Even so, asymmetric encryption is very compute-intensive, so it isn’t used for bulk data encryption.

Hope
Instead, its main roles are to help exchange a symmetric key securely and to support authentication. It also underlies digital signatures and the public-key infrastructure and certificates we’ll discuss in more detail in the next module.

Michael
Two common asymmetric technologies are RSA and ECC, which stands for Elliptic Curve Cryptography. RSA can perform authentication and key exchange, and historically most certificates used RSA-based signatures. But TLS 1.3 eliminates RSA for key exchange while retaining it for certificate signing.

Hope
ECC is used for authentication methods such as digital signatures, and it can be paired with Diffie-Hellman for key exchange. Names beginning with “EC”—such as ECDH, ECDHE, and ECDSA—refer to elliptic-curve cryptography. ECC has smaller keys and better performance than RSA, and it scales better as key sizes grow.

Michael
Let’s make digital signatures concrete with an over-the-air software update. Imagine an update image that’s 300 kilobytes. Rather than applying an asymmetric operation to the whole image, the sender first hashes it. The resulting hash is much shorter, so it’s faster to use in creating the signature.

Hope
Hashing the entire update also provides an integrity check: if the image changes, its calculated hash won’t match the original one. In this example, the chosen hash algorithm is SHA-256. SHA-256 or stronger is the generally accepted secure choice; MD5 and SHA-1, although common in the past and sometimes supported by hardware accelerators, are no longer considered secure.

Michael
The update server then uses the private key reserved for code signing to sign the hash, using an asymmetric technique such as ECDSA or RSA. That produces the digital signature. The server sends the update image to the IoT device accompanied by that signature.

Hope
The device has the corresponding public key. It uses that key to verify the signature and recover or check the signed hash value, then calculates a fresh hash from the update image it received. If the two hash values match, the device can be confident that the update came from the expected signing source and wasn’t tampered with in transit.

Michael
A second major use of asymmetric cryptography is solving the shared-key problem. Diffie-Hellman, abbreviated DH, lets two parties derive the same symmetric key without sending that key over the network. That avoids an attacker intercepting the shared key in transit.

Hope
The variant emphasized going forward in TLS 1.3 is Diffie-Hellman Ephemeral, or DHE. “Ephemeral” is important: a new key is calculated for each communication session rather than being stored permanently on the server.

Michael
That gives DHE forward secrecy. With older Diffie-Hellman implementations and RSA key exchange, the server’s certificate public key could be used as a basis for deriving the shared key. If the server’s private key were compromised later, an attacker who had recorded old communications might be able to derive those keys and decrypt the recordings.

Hope
With DHE, the key used for each session isn’t stored on the server. So compromising the server’s private key later doesn’t give an attacker that session key for decrypting earlier communications. The past sessions remain protected in that way.

Michael
In an ECDHE exchange—Elliptic Curve Diffie-Hellman Ephemeral—the server and endpoint exchange random values and Diffie-Hellman parameters. Each side uses the received values and parameters to derive a pre-master key, then derives the session key from that.

Hope
The underlying mathematics is complex, but the key practical point is that the session key isn’t sent over the connection. Both sides can calculate it in parallel, which also helps speed up the process.

Michael
There’s an authentication requirement during key exchange, too. Each party signs the data it sends with its own private key, allowing the receiving party to authenticate that the data came from the party it believes it’s communicating with.

Hope
And that connects to entity authentication. Suppose an IoT endpoint wants to check that it’s really connected to the intended server. The server sends a certificate containing a public key. The endpoint verifies the certificate through a chain of trust, a topic we’ll cover in the next module.

Michael
The endpoint also needs proof that the server possesses the private key associated with the public key in that certificate. Once it verifies that proof, it can be confident it’s communicating with the correct server. The certificate helps establish identity; the private-key proof helps show the server actually holds the matching key.

Hope
Let’s recap the connections. Symmetric encryption is efficient for bulk data but requires a safely shared secret, and it’s commonly paired with a MAC for message authentication and integrity checks. Asymmetric cryptography uses public-and-private key pairs, is too compute-intensive for bulk encryption, and is useful for signatures, authentication, and key exchange.

Michael
And digital signatures combine asymmetric cryptography with hashing: the sender signs a hash, and the receiver checks it against a hash of the received content. We’ve also separated entity authentication—checking the party at the start—from message authentication—checking each message during the conversation.

Hope
The next module is an introduction to digital certificates, including the certificate chain of trust. For anyone ready to develop a secure connected application on a TI SimpleLink Wi-Fi device, the source points to SimpleLink Academy, which offers hands-on training on secure connectivity, secure storage, and cryptography.

Ask anything
We've read this whole study set, so questions about it get the best answers.