1. Home
  2. Explore
  3. Computer Science
  4. IoT Encryption and Digital Signatures

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

IoT Encryption and Digital Signatures

Transcript

Hi, I'm Nick Lethaby, the IoT Ecosystem Manager at Texas Instruments. I'm presenting a series called Understanding Secure Connectivity in IoT and embedded system devices. This module is entitled, How Symmetric and Asymmetric Encryption and Digital Signatures Work. Now, we'll focus on explaining symmetric encryption, asymmetric encryption, and then multiple use cases in asymmetric encryption including key exchange authentication and how asymmetric encryption can

be combined with secure hashing to create digital signatures. Before we dive into the specifics of these different types of encryption, I'd like to relate them to the core security concepts we mentioned earlier. Confidentiality can be preserved by both asymmetric and symmetric encryption since they encrypt the data so it cannot be looked at by a third party. Authentication is delivered by digital signatures, certificates-- which we'll cover in the next module--

and message, or authentication codes which are associated with symmetric encryption. These each cover different aspects of authentication. And we'll break those down in more detail later in this module. Integrity is handled by both digital signatures and message authentication codes, again. And finally, non-repudiation is handled by digital signatures which help prove the origin of a message and whether it was sent and received. We won't be covering non-repudiation any further in this module.

Before we jump into the specifics of any particular type of encryption, I'd like to cover and explain one more important concept, that's the difference between entity authentication and message authentication. In entity authentication you have your end device, such as a sensor contacting a server. And the end device wants to know it's connecting to the real server it meant to connect to and not to some imposter, for example who's mounting a man-in-the-middle attack.

So entity authentication is a one-time operation done at the start of a communication session to establish, yes, I am connecting to the right party. Once you've established that you're talking to the correct party, there is still a risk of sometime during the conversation, an attacker might insert messages into the conversation that you would then assume were coming from the correct party. This is where message authentication comes in. With message authentication you are

checking that the actual message you received came from the party you connected to. In addition, message authentication will check the integrity of any message to deal with issues such as corruption due to transmission errors during the sending of the message. So hopefully this is clear. Entity authentication is saying it's done just at the start of a communication session when you validate that the party you're connecting with is who they say they were. Message authentication validates every message in that conversation came from the party you originally connected to. We're now going to look at some specific encryption technologies starting with symmetric encryption. In symmetric encryption, a single key is exchanged between both the endpoint and the server. The same key is used at both ends to encrypt and decrypt data. So one key is needed for data to be encrypted by the endpoint, sent to the server and decrypted by the server.

And then that same key is used by the server to encrypt its data, send it to the IoT endpoint, which again uses that same key to decrypt it. So a single key. Some of the ciphers you'll encounter that's used in symmetric encryption are AES which is by far the most popular, DES, 3DES, and then ChaCha20. DES and 3DES are both being eliminated in TLS 1.3. So ChaCha20 is really the only alternative to AES. The main use of symmetric encryption is for bulking corrections.

So the great majority of encrypted traffic going over the internet is encrypted using symmetric encryption. And the reason why that is, is because symmetric encryption is relatively CPU efficient, and certainly much more so than asymmetric encryption as we'll discuss in subsequent slides. The key weakness of course is symmetric encryption, which you may have already realized that you have to exchange the secret key between the endpoint and the server. And the question then becomes, how do you get that key from one party to the other without it being intercepted by an attacker who can then decrypt all subsequent traffic. We'll explain approaches to exchanging this key in a safe manner later on in this section. Symmetric encryption ciphers are typically associated with message authentication. And if you look at common symmetric encryption cipher such as AES, they are often paired with some form of message authentication.

So you'll see combinations like a AES, GCM, or ChaCha20, Poly1305. The purpose of message authentication is as we described earlier to verify that the messages have not been tampered with and that they are coming from the original entity you authenticated early on in the communication. So how they work is simply this. It's that they generate a message authentication code. And that's computed by taking a hash off the message and combining it with some form of sequence or session number

to make sure that replay attacks cannot reuse packets and also uses the symmetric encryption key as part of the message authentication code generation process, which then proves that it's part of the message stream you are using. Because obviously, that message stream also uses the symmetric encryption key. So to summarize, symmetric encryption ciphers are typically paired with message authentication techniques. And a message authentication code proves,

A, that your message is not being tampered with, and B, it is legitimately part of the conversation you've been having. And it hasn't been inserted by an unknown third party. The second form of cryptography is asymmetric cryptography. The reason why it's asymmetric is because it does not use a single key at both ends to decrypt and encrypt data. Instead, it uses a key pair to exchange data in one direction. So let's take this example here where we have a server that wishes to get encrypted data

from the endpoint. The server will send what's known as its public key to the endpoint. The endpoint will then encrypt the data it wishes to send with the public key. It sends the encrypted data back to the server. And then the server uses a different private key to decrypt the data. So in asymmetric cryptography, there is a public and private key pair which is used to encrypt and decrypt data. Now, this key pair works in just one direction.

So the public key is sent out to the endpoint in this case so the endpoint can send encrypted data back to the server. If you wish to have the server send encrypted data to the IoT endpoint, then the IoT endpoint will also have a public/private key pair. And it will send its public key to the server, which will then encrypt the data, send it to the endpoint, which will then decrypt it using its private key. So you can see here that we actually need four keys to do the two-way communication.

That's a public and private key pair at each end of the connection. Now, one important thing about asymmetric encryption is the public key is designed not to be a secret. So there's no problem in sending a public key out in the open over a connection. However, the private key must be kept secret. But because you never need to transmit it anywhere, it's much easier to keep it secret than in the case of symmetric encryption where a key must be shared between the two.

So talk a bit more about asymmetric cryptography. It has one big weakness compared to symmetric cryptography, and that is that it's very, very compute intensive. As a result, asymmetric cryptography is not used with bulk data encryption. It's primarily used for two functions. One is key exchange. So you can exchange a symmetric encryption key over a network connection in a secure manner. The second use is authentication. And asymmetric cryptography techniques backup both digital signatures and

the public key infrastructure and certificates. And we'll go into both those uses in more detail in the subsequent slides. There are two common asymmetric cryptography technologies. One is RSA. And the other is ECC, which stands for Elliptical Curve Cryptography. We'll briefly discuss those before we go into exactly how asymmetric cryptography is used for authentication and key exchange. The two principle asymmetric cryptography technologies you'll encounter are RSA and ECC.

RSA is able to perform both authentication and key exchange. And historically, the great majority of certificates issued use RSA-based signatures. However, TLS 1.3, which is the latest release of the key internet security protocol is eliminating the use of RSA for key exchange and retaining it only for certificate signing. ECC is a slightly newer asymmetric cryptography technology. ECC on its own is simply used for authentication methods such as digital signatures.

But it's paired with an algorithm called Diffie-Hellman to perform key exchange. So when you see ciphers that start EC, that means Elliptical Curve. So ECDH, ECDHE, ECDSA, all those things are based on elliptical curve cryptography. Elliptical curve cryptography is likely to see growing use in the future because it has smaller keys and better performance in RSA and scales better as the key size grows. Because TLS 1.3 will not be using RSA for key exchange, our examples of key exchange are just

going to use something called ECDHE as this is now going to be the common mechanism used going forward. One common use of asymmetric encryption is digital signatures. Digital signatures are used to prove that content coming over a network connection such as a software update or a certificate or data packet of some form did in fact originate from where it said it came from and was not tampered en route. We're going to walk through an over-the-air update example,

so you can understand how digital signatures are used to authenticate content. We're starting off with an OTA update image of let's say 300 kilobytes in size. To make that easy to encrypt, the first thing we do is we perform a hash operation on it. Hashing is important for a number of reasons but especially that the resulting signature is much, much shorter than the original data packet and therefore much faster to encrypt. In addition, since hashing is performed on the entire update,

it also serves as an integrity check to prove there was no data transmission corruption in transit. Once we have the hash done, and the hash can vary in size depending on the hashing algorithm chosen, here we've chosen SHA256, we then encrypt the hash using an asymmetric encryption operation, such as ECDSA or RSA. And that produces a digital signature. You'll notice here that the encryption is done using the private key of a key that's specifically used for code signing.

To make some general comments about hashing functions, going forward, SHA256 or greater will be the generally accepted secure hashing method. You may well have seen accelerators on microcontrollers or microprocessors for MD5 or SHA-1 as these were commonly used in the past. But they're now not regarded as secure. Once the digital signature is being created, the over-the-air update server can now send the OTA update image accompanied by the digital signature to the IoT endpoint.

If you recall in our earlier discussion of asymmetric encryption, it's based on key pairs where a public key can be used to decrypt information, encrypted originally with the private key of the same path. In this case, the digital signature was encrypted using the private key held on the OT update server. Each IoT endpoint has the public key. And it uses it to decrypt the signature to reveal the hash value sent. It then takes the OTA update image

and then performs the same hash function on that image. It then checks that the hash it just calculated, the image that was sent, matches the hash value that was encrypted in the digital signature. If these match, the IoT endpoint can be confident that the OTA update did in fact come from the OTA update server and was not tampered with during transmission. Another important function performed by asymmetric encryption is key exchange. You'll probably recall that one of the challenges

of symmetric encryption is that it needs to exchange a shared key between the two communicating entities. If it passes that shared key over an unsecured connection, an attacker can get hold of that key and then compromise all further communication. Asymmetric encryption provides a way to exchange the shared key safely. The main algorithm that is used in key exchange today is Diffie-Hellman, which is abbreviated to DH. Diffie-Hellman enables both sides

to derive the shared symmetric key without actually passing it over the wire. This has the advantage of forestalling any attempt to intercept it in transit. The main variant used today and the one that will be emphasized going forward in TLS 1.3 is Diffie-Hellman Ephemeral. An important difference between DHE and the earlier Diffie-Hellman implementations, and also the RSA key exchange implementations, is that a new key is calculated for every communication session.

That means it's never stored permanently on the server. This has a tremendous advantage in providing something called forward secrecy. Previous Diffie-Hellman implementations and also RSA used to use the public key in the service certificate as a basis for calculating the shared key. This meant that if the servor's private key ever became known at a later date, an attacker could then derive the shared key and play the recorded past communications between the two parties, they would then

be able to decrypt them. Since DHE does not store the key use for any session on the server, it provides what is known as forward secrecy. Which means that compromising the servor's private key is no use in decrypting earlier communications between it and other parties. Let's briefly walk through an example of key exchange using ECDHE, which is elliptical curve Diffie-Hellman Ephemeral. The IoT server and the IoT endpoint begin by exchanging a random value and the Diffie-Hellman parameters.

Then each side uses the random, the Diffie-Hellman parameters they receive to derive a pre-master key. And from that, they then derive the session key. There's a lot of complex mathematics behind how the actual pre-master and session keys are derived, which you really don't need to concern yourself with from an embedded security standpoint. As I mentioned earlier, since the keys are not actually exchanged over a connection, they can be computed in parallel speeding up the process.

You may be asking, what exactly does asymmetric encryption contribute to key exchange? During the key exchanges, it's necessary for each communicating party to authenticate the data it's receiving from the other. And this is done by each party signing the data it sends with its own private key which enables the receiving party to authenticate that it is indeed getting the data from the party it believes it's communicating with. The final common use of asymmetric encryption

I want to discuss is entity authentication. This is typically done by exchanging certificates. I'm going to cover digital certificates in a lot of detail in the next section. I just wanted to show the relationship to asymmetric encryption here and how it gets used. If the IoT endpoint device for example, wishes to authenticate, it really is connecting to the server it thinks it is, the server will send its certificate to the IoT endpoint. And this certificate contains a public key.

At this point, the IoT endpoint verifies the service certificate via something called the chain of trust, which we'll discuss later. It now needs to prove that the server also possesses the private key associated with the public key that was sent in the certificate. Once the IoT endpoint proves this, it can be confident it is indeed communicating with the correct server. In this module we discussed symmetric and asymmetric encryption in some detail, along with digital signatures

which involves secure hashing. We showed how these encryption technologies related to the core security concepts of authenticity, integrity, and confidentiality. We also explained the differences between entity authentication and message authentication. Asymmetric encryption can be used in a number of ways. And we walked through examples of digital signatures, entity authentication and key exchange. The next module in this series is entitled, An Introduction to Digital Certificates.

And a number of the things you have learned in this presentation will be applicable there. By some point it's likely you'll want to do some actual software development of a secure connected application. I've put a few links here to enable you to get the appropriate software and valuation modules to develop secure connected applications on a TI simple-linked Wi-Fi device. We have an extensive set of hands on training modules called SimpleLink Academy. As you go there and select, you'll see a number of examples that deal with secure connectivity, secure storage and cryptography.

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent