This course will introduce you to the foundations of modern cryptography, with an eye toward practical applications.

Loading...

From the course by University of Maryland, College Park

Cryptography

415 ratings

This course will introduce you to the foundations of modern cryptography, with an eye toward practical applications.

From the lesson

Week 6

Key Exchange and Public-Key Encryption

- Jonathan KatzProfessor, University of Maryland, and Director, Maryland Cybersecurity Center

Maryland Cybersecurity Center

[SOUND] In this lecture we'll look at public-key encryption schemes,

Â and we'll start by just showing how public-key encryption

Â can be used to ensure secrecy in the public-key setting.

Â So just like in the public-key setting more generally.

Â We'll begin with a party who locally generates public and private keys.

Â When another party comes along and wants to communicate with this first party,

Â the first thing they need to do is to obtain a copy of that user's public key.

Â In this figure for concreteness we've just assumed that the party is able to

Â look up the other person's public key in some public directory.

Â And so now they have an authentic copy of the public key of the person with whom

Â they wish to communicate.

Â They can take a message m that they wish to send to the recipient.

Â And they can then encrypt that message using the public key that

Â they've just obtained.

Â This gives a ciphertext c which they can then send onto the recipient.

Â At the other end the recipient can use the private key to decrypt the ciphertext and

Â recover the message.

Â And one thing I want to stress here is that we have asymmetry.

Â Because the keys being used by the sender and the receiver are different.

Â And this is contrast to the case of private key encryption

Â where encryption and decryption both use the same key.

Â Here encryption uses the public key and decryption uses the private key.

Â Now from the point of view of an attacker,

Â note that only does the attacker get to observe the ciphertext, but we'd have to

Â assume that the attacker is also able to get a copy of the recipient's public key.

Â After all, if the public key is being stored in some public directory, it's

Â reasonable to assume that the attacker is able to get its hands on it also.

Â Nevertheless, even for an attacker who obtains the public-key of

Â the recipient and can observe the cipher text,

Â we would like the contents of the message being communicated to remain secret.

Â More formally a public-key encryption scheme consists of

Â three probabilistic polynomial time algorithms.

Â The first algorithm is the key-generation algorithm,

Â that on input the security parameter outputs the public and private keys.

Â The encryption algorithm, as we've just seen, takes as input a public key and

Â a message, and outputs a ciphertext c.

Â The decryption algorithm takes as input the private key and the cipher text.

Â And it outputs either a message m or

Â a special symbol that we use here to denote an error.

Â And of course we have the standard correctness requirement that for

Â all messages m and for

Â all public, private key pairs, output by the key generation algorithm.

Â If you decrypt using the private key, something that was

Â encrypted using the public key, you should get back the same results in the end.

Â We can define CPA security for public encryption scheme's in a way that's very

Â analogous to the definitions that we've seen already in the private key settings.

Â So let's fix a public-key encryption scheme Pi and some attacker a.

Â And then we can define the following experiment.

Â The first thing we do is to run the key generation algorithm to obtain public and

Â private keys.

Â And we give the public key to the attacker.

Â Right, this just models what we talked about earlier.

Â Namely that the attacker is assumed to be able to see the public key of

Â the recipient.

Â The attacker then outputs two messages, m0 and m1 of the same length.

Â And the experiment then chooses a uniform bit b and

Â encrypts the message mb using the given public key to obtain a ciphertext c.

Â And we give the ciphertext to a.

Â Finally, a outputs a guess, b prime.

Â Representing its best guess as to what message was encrypted.

Â And the attacker succeeds, i.e.

Â the experiment evaluates to one, if and

Â only the attackers guess, b-prime, was correct.

Â In the usual way, we then define that a public encryption scheme is CPA-secure.

Â If for all probabilistic polynomial time adversaries a, the probability with which

Â a succeeds in the experiment we just saw is at most one half plus negligible.

Â Now I want to make a couple of observations about the definition.

Â One thing you might have been surprised about is the fact that the definition,

Â although it talked about CPA security.

Â Did not include an encryption oracle.

Â But the reason for that is simple.

Â If the attacker has the public key, it has no need for an encryption oracle.

Â Given the public key,

Â the attacker can use the public key to encrypt messages of his choice.

Â And therefore, unlike the private key setting, the attacker doesn't need access

Â to an encryption oracle in order to obtain encryptions of messages of his choice.

Â That means that even if we wanted to define a relatively weak

Â notion of security against a completely passive attacker,

Â there's sort of no way to get around automatically including the ability

Â to mount a chosen plain text attack in the public-key setting.

Â And that's something that's in contrast to what we've seen as we've

Â discussed already in the private key setting.

Â Now this fact has a number of consequences.

Â The first is that there's no such thing as perfectly secret public-key encryption.

Â At least not in any of a setting where the attacker's able to get a copy of

Â the recipient's public key.

Â And this follows really from the fact that as we've just said given

Â the public key the attacker effectively has access to an encryption oracle.

Â Which means that given any ciphertext corresponding to some unknown

Â method the attacker could always try to encrypt every possible message under

Â the public key repeatedly until it obtains the same ciphertext.

Â And therefore, if you allow attackers with unbounded running time, they'll always be

Â able to figure out the message that corresponds to a given ciphertext.

Â Alternately, the attacker could also run the key generation algorithm over

Â and over again.

Â Until it obtains a private key matching the observed public key.

Â Another consequence, is that no public encryption scheme

Â with a deterministic encryption algorithm can possibly be CPA-secure.

Â And this is exactly like what we've seen already in the setting of

Â private-key encryption.

Â If you have a deterministic encryption scheme.

Â Then given an, given a ciphertext feed,

Â which is an encryption of one of two possibilities, either of zero or of one.

Â The attacker that could simply encrypt them zero encrypt in one, and

Â compare both of those results to the observed ciphertext and

Â figure out exactly which message was encrypted.

Â What this means is that we should never use a deterministic public-key

Â encryption scheme.

Â They simply won't satisfy even the most basic notion of security.

Â Finally, if we defined a notion of security for

Â the encryption of multiple messages.

Â Then, just as in the private key setting where we observed that

Â CPA security implies security for the encryption of multiple messages.

Â The same will hold, will hold true in the public key setting as well.

Â That is the definition of CPA security that we gave on the previous slide.

Â We'll also imply the secrecy of encrypting vectors of message as well.

Â Now we can often define, or

Â consider, the notion of chosen-ciphertext attacks in the public key setting.

Â So here we have an attacker who's observed the ciphertext c, and it's implicit even

Â though I haven't shown it here that the attacker knows the public key as usual.

Â The attacker might then be able to inject ciphertext c prime,

Â that is to send the ciphertext to the recipient.

Â And, receive in return the resulting decryption, m prime,

Â corresponding to the ciphertext that it sent.

Â Now, this is so far, just like what we saw in the private-key case.

Â But, I want to make the point here, that chosen-ciphertext attacks.

Â Can arguably be even a greater concern in the public key setting than they were in

Â the private key setting.

Â And the reason for that fundamentally is that in the private key setting,

Â the recipient shares the key, shares their key, with one other sender.

Â And so when they receive a ciphertext, they will assume that it

Â came from the legitimate sender, the single legitimate sender.

Â With whom they've shared their key.

Â In contrast, in the public key setting,

Â almost by assumption, anybody in the world who's ob, able to obtain a copy of

Â the public key is a legitimate sender with respect to that receiver.

Â And so it's not at all unusual for

Â the receiver to receive ciphertexts from many different senders.

Â And so it would be much easier in this case number one for an attacker to

Â send a ciphertext that wouldn't immediately get rejected by the recipient.

Â And number two it would be easier for the attacker to potentially receive and

Â return the entire decryption of the ciphertext that it sends to the receiver.

Â So the point of all of this is that if you thought that chosen ciphertext were

Â a problem in private key setting, and

Â indeed they are, well they're even more a concern in the public key setting.

Â A very related concern that we've spoken about earlier in the private key

Â setting as well is that of malleability.

Â And remember that this informally refers to the property that

Â given the ciphertext c that is the in the encryption of some unknown message m.

Â It might be possible for an attacker to produce a ciphertext c

Â prime that decrypts to a related message m prime.

Â And again this is likely to be even more problematic in the public key

Â setting than it is in the private key setting.

Â And, we'll show an example, in fact,

Â in the next lecture, I, that I think really highlights this point.

Â Just as in the private-key case, we're not going to define a notion of malleability.

Â But, I can tell you that malleability and

Â chosen-ciphertext security are very related.

Â And, in particular, any scheme which is malleable will not be

Â secure against chosen-ciphertext attacks.

Â And conversely, a scheme that is secure against chosen cipher text

Â attacks will not be malleable.

Â Now, we can define formally a notion of CCA security for public key encryption.

Â Again, by analogy to the definition we've seen already for

Â the case of private encryption.

Â And I'm going to skip that here for simplicity.

Â Now one very important paradigm I want to introduce is that of hybrid encryption.

Â Let's imagine we want to use a public key encryption scheme

Â to encrypt a very long message m.

Â Now one thing we can do of course is to simply use the encryption algorithm as is

Â with the public key.

Â And the message m, as input to obtain a ciphertext c.

Â And in this diagram,

Â I've just indicated that by the triangle, where the key is going into the algorithm.

Â So this just indicates which input is the key and

Â which is the message being encrypted.

Â Now, we can do that, and

Â that will work, but remember that we said earlier in a previous lecture.

Â That public key encryption is relatively inefficient,

Â at least as compared to private key encryption.

Â So we can use a different approach instead in order to obtain better efficiency.

Â What we'll do is to select a random key k for some private key encryption scheme.

Â And, then, rather than encrypting m,

Â using the public-key scheme, what we'll do is to encrypt k, itself.

Â And, obtain a ciphertext that we'll call here an encapsulated key.

Â We can then just use the key that we've just chosen as the key to

Â a private-key encryption scheme Enc prime.

Â And use the private key encryption scheme to encrypt our bulk data m.

Â This will result in a ciphertext for the underlying private key encryption scheme.

Â Decryption can be done in the obvious way.

Â So the ciphertext now will consist of both components, both the encapsulated key

Â that we got by running the public key scheme, as well as the ciphertext that

Â we got by encrypting the bulk data using the private key encryption scheme.

Â What the recipient can do is they can use their private key

Â to decrypt the encapsulated key.

Â And recover k.

Â And, then use the decryption algorithm for the private-key encryption scheme

Â to recover m from the first portion of the ciphertext.

Â Now, note, that by just putting a box around both of those algorithms together,

Â and by grouping the two ciphertexts that we obtained, and

Â referring to those as a single ciphertext.

Â We obtain something with the functionality of a public key encryption scheme.

Â We have a public key going in at the bottom, a message coming in at the left,

Â and a ciphertext coming out at the right.

Â What this means is that we have something here which is

Â giving us the functionality of public key encryption.

Â It's allowing us to transmit a message to a recipient using knowledge only of

Â their public-key.

Â But the efficiency here is asymptotically the efficiency of

Â the private-key encryption scheme, because we're using the private-key encryption

Â scheme to encrypt the bulk data.

Â And the public-key scheme is only being used to encrypt a very short key.

Â What this means also is that it suffices to consider public key

Â encryption schemes that can encrypt only relatively short values.

Â Like 128 bit keys.

Â And we can then take those and bootstrap them into public key

Â encryption schemes supporting encryption of arbitrary length data.

Â What can we say about the security of the approach on the previous slide?

Â Well, let's let Pi denote the public-key component and

Â Pi prime denote the private-key encryption scheme being used.

Â And we'll let Pi hybrid, denoted here by Pi sub hy,

Â denote the combination of the two as on the previous slide.

Â Well, it's possible to prove that if Pi is a CPA-secure public-key encryption scheme.

Â And Pi prime is a CPA-secure private-key encryption scheme.

Â Then the hybrid encryption approach resulting from the combination of the two

Â is itself a CPA-secure public-key encryption scheme.

Â And one can show a similar result for CCA security as well.

Â We've already seen examples of private-key encryption schemes that are both

Â CPA or CCA-secure.

Â And what that means is again if we can design public key encryption key

Â schemes that can encrypt only relatively short values like 128 bit keys.

Â Then we can couple couples those with the private key encryption schemes we've

Â seen earlier and obtain efficient public key encryption schemes for

Â arbitrary length messages.

Â The hybrid encryption approach is one that is used all the time in practice and you

Â never want to use a public key encryption natively to encrypt large volumes of data.

Â In the next lecture we will see our first concrete examples of public key

Â encryption schemes.

Â When will, when will we examine public key encryption schemes based on

Â the discrete-logarithm assumption and the Diffieâ€“Hellman assumption.

Â Coursera provides universal access to the worldâ€™s best education,
partnering with top universities and organizations to offer courses online.