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

345 ratings

University of Maryland, College Park

345 ratings

Course 3 of 5 in the Specialization Cybersecurity

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

From the lesson

Week 3

Private-Key Encryption

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

Maryland Cybersecurity Center

[SOUND]

Â In the last two lectures,

Â we have discussed the notion of security against chosen plain text attacks,

Â as well as the important primitive of pseudo-random functions or block ciphers.

Â In this lecture I want to show a construction of CPA ins,

Â secure encryption from pseudorandom functions and

Â give a proof that the construction is indeed secure.

Â Before I do that I just want to give one clarification,

Â regarding something from the previous lecture.

Â We talked there, about how block ciphers,

Â provide a secure instantiation of pseudorandom permutations.

Â And that's still true.

Â What I want to point out here is that for large enough n,

Â a random permutation is indistinguishable from a random function.

Â And so, a pseudorandom permutation is similarly indistinguishable from

Â a pseudorandom function.

Â There's still a difference between the two,

Â because a pseudorandom permutation requires, also, efficient

Â invertibility of f sub k but nevertheless, what this means is that, any pseudorandom

Â permutation is also a pseudorandom function, if n is large enough.

Â Now in practice, what that means is that block ciphers are good

Â pseudorandom functions also.

Â And so we can use them, both whenever we need pseudorandom permutations,

Â as well as when we need pseudorandom functions.

Â So let me now describe for

Â you a, an encryption scheme that we'll prove is CPA secure.

Â Let F be a keyed function.

Â Here we actually don't require for it to be a permutation.

Â We'll define the encryption scheme as follows.

Â The key generation algorithm, will choose a uniform key of length n,

Â where n is our security parameter.

Â To encrypt a message, m,

Â whose length we'll assume is the same as that of the key, we do the following.

Â We choose a uniform n-bit string R, and

Â then we output the cypher text that contains 2 components.

Â The first component is R itself.

Â And the second component contains fk of r, XOR with m, so

Â we apply our pseudorandom function F using key k to the random value r,

Â that we've just chosen, and take the result and XOR it with m.

Â And that gives us the second component of a cipher text.

Â And I want to highlight here, that encryption is randomized.

Â If we encrypt the same m bit string m,

Â twice using the same key, we're going to get in general different results.

Â We're going to get different cipher texts,

Â as long as we choose different values of r each time.

Â To decrypt a cipher text containing two components, C1 and C2,

Â what we do is we simply apply F k to the first component C1 and

Â XOR that with C2, in order to obtain the original message.

Â And you can verify for

Â yourself that correctness here holds with probability one.

Â In pictures what we have is the following.

Â We take our message m and our key K.

Â And to encrypt that message under that key, we choose a uniform string r, and

Â then evaluate our pseudo-random function F on the value r,

Â using our key K, of course.

Â This gives us a pseudorandom value, F K of R.

Â It's a pseudorandom value because F is going to be assumed to

Â be a pseudorandom function.

Â We then exhort that pseudorandom value with our

Â message to obtain the second component of the ciphertext.

Â We send r as the first component of a ciphertext to allow

Â the receiver to decrypt.

Â Now, if you look at part of this this should look exactly,

Â like the pseudo one time pad and it should remind you very much of that scheme.

Â What we have is the exor of a message with a pseudo random value.

Â The key difference here is that rather than having just a single pseudo random

Â value defined by, applying a pseudorandom generator to the key, as in the case of

Â the pseudo-one-time pad, what we have here is the ability to produce multiple

Â independent looking pseudorandom values based on the single key r.

Â And we do that by selecting a uniform value r that identifies,

Â some pseudo random value in the function table for Fk.

Â Maybe we can imagine the value r as specifying which entry in

Â this huge array we're going to select out and

Â use next as the value we're going to XOR with our message to encrypt it.

Â This gives us the ability then, to have access to, as it were,

Â 2 to the n different pseudorandom values that we can use for encryption.

Â And this is precisely why we can use the scheme just

Â described to safely encrypt more than one message.

Â Now one thing I do want to stress here,

Â is that the key is as long as the message, right?

Â We were assuming that the message and the key were both of length n.

Â And you might wonder whether we're really doing anything better

Â than the one-time pad itself.

Â The point here is that the scheme can be used with the same key

Â to safely encrypt multiple messages.

Â So this really is much better than the one-time pad.

Â And further more if we wanted to, we could use it to encrypt longer messages,

Â we'll get into more of a discussion of that in the following lecture What I

Â want to do next is, explore the security of the construction we've just given.

Â And what I really want to do is to prove the following theorem.

Â If our keyed function, F, is indeed a pseudorandom function,

Â then the scheme we've just presented, that I'll refer to as pi, is CPA-secure.

Â And as previously, we're going to prove this theorem by reduction [BLEEP].

Â What that means is, we'll assume we have some attacker, depicted here as a devil,

Â attacking our encryption scheme, our encryption scheme pi.

Â And what we're going to then do is use that attacker as a subroutine,

Â to construct a distinguisher D that's going to distinguish or

Â try to distinguish between two cases.

Â When it's given access to a random function, or

Â when it's given access to F sub k for a uniform key k.

Â Right this is the definition of security for F, the definition of it means for

Â F to be a pseudorandom function,

Â is that no efficient d should be able to tell these apart.

Â So our distiguishier d has to be able to stimulate for

Â our attacker, the effects of interacting in the CPA security experiment.

Â So this means, first of all,

Â that we need a way to, emulate, the encryption oracle for this attacker.

Â That is, the attacker might request encryption of some message m,

Â and we have to provide that attacker in return, with a simulated encryption of m,

Â with respect to some key.

Â The way we do that is as follows [BLEEP].

Â What D will do, is choose a random uniform value, r, query that value r,

Â to its function oracle, and get back, some value that I'll call here f(r).

Â It takes that value f(r).

Â And x soars it with m and then provides to the attacker the simulated

Â ciphertext containing two components, r and f of r x soar with m.

Â And it continues to do this, for

Â each encryption Oracle query that this attacker makes [BLEEP].

Â At some point later the attacker outputs two messages, m0 and m1.

Â And what's supposed to happen in the CPA security experiment,

Â is that one of the those is chosen and encrypted.

Â And our distinguisher D is going to have to simulate that as well.

Â To do that, it does what really should look like the obvious thing.

Â It's going to sample a uniform value that I'll call r* here.

Â And it's going to submit r star to its function oracle and

Â get back a value f of r star.

Â it's then going to also sample a uniform bit b,

Â that it's going to use to select between, those two messages m0 and m1.

Â It then takes Mb, and x or

Â is that with the value F of r start that it received from its function oracle.

Â And it gives the to the attacker the challenge cypher text containing the two

Â components r star and F of r star x ored with m sub b.

Â The attacker can continue to query the encryption oracle, but

Â those queries will be simulated just like on the previous slide.

Â Eventually, A, or this attacker, outputs a guess,

Â b prime, as to the message that was actually encrypted.

Â What we do then, is simply look, whether the attacker's guess was correct.

Â If the attacker's guess was correct, that is,

Â b is equal to b prime, then we output one, and otherwise, D will output zero.

Â What we need to do now is to analyze the probability with which D

Â outputs one when it's interacting with, a random function and the probability that

Â D outputs one when it's interacting with F Sub k for uniform key k.

Â Let's just define for convenience.

Â Mu of n to be the probability that our attacker, the devil in the previous slide,

Â that the attacker succeeds in the CPA experiment, right?

Â So mu of n, we'll just define as the probability that A succeeds in

Â the CPA experiment when interacting with the encryption scheme pi.

Â We'll also let q of n.

Â Denote a bound on the total number of encryption queries that

Â the attacker ever makes.

Â Now with that in place we can first look at the case of or look at the behavior of

Â D in case it's function oracle is F sub k for uniformly chosen key k.

Â Well, if the function that D is interacting with is S sub K for

Â uniform K, then you can go back and check that the view of

Â the attacker is identical to its view in the CPA, experiment.

Â Right? The encryption inquiries of

Â the attacker are answered exactly as they would be in that experiment.

Â And the challenge cypher is constructed exactly as it would be in that experiment.

Â What that means, is, that if the function article with which D is interacting

Â contains F sub K for a uniform choice of K, then the probability that

Â D outputs 1 is exactly the probability with which the attacker succeeds.

Â In this CPA experiment involving pi,

Â because D only outputs one exactly when the attacker succeeds.

Â That just means that the probability that D outputs one in that case

Â is precisely mu of n.

Â On the other hand, what happens when the function oracle with,

Â with which D is interacting, is chosen by picking a uniform function F and

Â placing that inside the function oracle.

Â Well in that case there are two interesting subcases we can analyze.

Â The first thing we can look at, or the first event, is that the random value,

Â r* that was used by D, to generate the challenge cipher text is.

Â Was queried at some other time.

Â Particularly to answer some other encryption oracle query.

Â And we'll call this event repeat, so we'll say that repeat occurs,

Â if the value r* used to answer the, to construct the challenge cipher

Â text is ever used in answering some encryption oracle query.

Â The other event, or

Â the other sub case is that r* was not quarried, at any other time.

Â And this will just be the complimentary event to event repeat [BLEEP].

Â And we can then express the probability that D outputs 1 when it's interacting

Â with a uniform function f have been bounded by the probability that D outputs

Â 1, conditioned on Repeat not happening, plus the probability that Repeat happens.

Â I've done some simple algebraic simplifications here

Â nothing very complicated, just straightforward probability.

Â We can bound the probability of Repeat by q of n over 2 to the n.

Â But why is that?

Â Well, we can imagine, conceptually, that the value r* is chosen at the beginning of

Â the experiment, which doesn't, doesn't change the probability space at all.

Â Doesn't matter when we choose it.

Â Then, we can look at, the probability with which the event repeat happens,

Â in any particular encryption oracle query.

Â Well, for any particular encryption Oracle query,

Â we choose a value r uniformly at random from the set of n-bit strings.

Â So the probability in that particular query that that r happens to

Â be equal to r* is exactly 1 over 2 to the n.

Â And so the probability that in

Â any of the at most q of n encryption Oracle queries that any of those values r,

Â is equal to our value r* is at most q of n over two to the n [BLEEP].

Â What about the probability that D outputs one, conditioned on no repeat occurring?

Â So here's where things get interesting.

Â Well, if repeat did not occur, then what we know is that the value r*,

Â was never queried to the encryption oracle,

Â in answering any of the encryption oracle queries.

Â That is, a value r* was only submitted, to the function oracle of D exactly one.

Â Now because the function in this case is a uniform function,

Â the value f of r star is a uniform ended value.

Â Moreover because repeat did not occur, that value, F of r* is uniform and

Â independent of the entire rest of the experiment.

Â Right? The whole point of saying that F

Â is a uniform function is that the value of F of r* is independent of

Â the value of F on any other input.

Â So what were doing in that case, is were XOR the uniform value

Â F of R star, with M sub B.

Â But because F of R star, is uniform and independent of the rest of the experiment,

Â that is equivalent to XORing M sub B, with a uniform and

Â independent, string which is exactly like what we do, in one time pat encryption.

Â And so there's no way whatsoever, for the attacker to determine, with probability

Â better then one half, whether m0 was encrypted or whether m1 was encrypted.

Â And so the probability with which D outputs one in that case,

Â conditioned on repeat not happening, is equal to the probability with

Â which the attacker, guesses correctly, namely guesses the value,

Â of the bid B correctly, which is exactly one half [BLEEP].

Â So, now just going through the rest of the math, because we

Â know that F is a pseudorandom function, this was the assumption of the theorem,

Â we know that the difference in the probabilities, with which D outputs one

Â in both of those cases, i.e, when given access to a completely random function or

Â when given access to F sub k for uniform k, that difference must be negligible.

Â So we know, therefore, that mu of n minus the probability,

Â that D outputs 1 when interacting with a random function, must be negligible.

Â And this tells us that the probability,

Â sorry that mu of n is bounded by the probability with which D outputs 1,

Â when accessing a random function, plus a negligible value.

Â On the previous slide we showed that his is in turn,

Â bounded by one half plus q of n over 2 to the n plus epsilon n.

Â Now the key point here, is that for any polynomial Q that is

Â regardless of the running time of the attacker, all right we know that Q of n

Â must be polynomial because we're concerned only with polynomial time attackers.

Â For any polynomial Q, the additive term Q of N divided by 2 to the N is negligible.

Â Right this is a polynomial divided by 2 to the n.

Â A polynomial divided by an exponential.

Â And that is an example of a negligible function.

Â Furthermore the sum of two negligible functions is again a negligible function.

Â So we can just represent the terms q of n divided by 2 to

Â the n plus epsilon n, by the single negligible function epsilon prime of n.

Â And then we have that the probability with which the attacker succeeds,

Â in the CPA experiment when interacting with pi.

Â Is at most one half plus epslon prime of n.

Â And that completes the proof because what we wanted to show, remember, is that,

Â pi is secure, that pi is CPA secure and what that would mean is that for

Â every polynomial time attacker A, the probability with which that

Â attacker succeeds is bounded by one half plus a negligible function.

Â And that's exactly what we've shown here.

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