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

417 ratings

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

From the lesson

Week 2

Computational Secrecy and Principles of Modern Cryptography

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

Maryland Cybersecurity Center

In the last few lectures we've explored the one-time pad encryption scheme.

Â And shown that it achieves our definition of perfect secrecy.

Â And indeed, the one-time pad has been used in the real world.

Â A famous example is the red phone that connected Washington DC and

Â Moscow in the 1980s, where the keying material was shared by trusted couriers,

Â who would take suitcases full of printouts of bits, as it were and

Â carry them between the two parties.

Â Nevertheless the one-time pad encryption scheme is not used very often nowadays.

Â Why is that?

Â Well in fact there are several limitations that prevent more widespread use of

Â the one time pad.

Â One of these which you may have noticed as we've described the scheme.

Â Is that the key is as long as the message.

Â Remember that in the description of the one-time pad encryption scheme.

Â We had a parameter n that determined both the length of

Â the messages that could be encrypted.

Â As well as the length of the key.

Â Moreover the one-time pad encryption scheme

Â is only secure if each key is used to encrypt a single message.

Â Certainly the proof of perfect secrecy that we gave for

Â the one-time pad relied on the assumption that the key was being used to encrypt

Â only a single message, and we'll see in a few moments that in fact there are some

Â simple attacks on the scheme in case a key is used to encrypt more than one message.

Â What this means is that if you want to use the one-time pad encryption scheme

Â to secure your communication, then parties need to share keys whose total

Â length is equal to the total length of all messages they might ever want to send.

Â That's because each portion of the shared key can be used only once, and

Â must be used to encrypt a message whose length is equal to the length of

Â that portion of the key.

Â It's even worse if the parties don't know in advance how much they're going to

Â want to communicate.

Â In that case they would need to share a total key.

Â Or a key rather, whose total length is at least an upper bound on the total length

Â of all messages they want to send.

Â I want to look in more detail at the problems that might arise in

Â case the one-time pad encryption scheme is used to encrypt two

Â messages using the same key.

Â So let's say we have two parties who share a key k.

Â And use this key to encrypt two messages, m1 and m2.

Â An attacker who observes the two ciphertexts, phi 1 and phi 2, can compute

Â the XOR of those two ciphertexts, and we see by performing the substitution,

Â that that XOR is equal to the XOR of m1 and m2.

Â Right c1 is equal to kx or m1.

Â C2 is equal to KX or M2.

Â And if we if the attacker XOR is C1 and C2 together the key

Â K cancels from the resulting expression and the attacker learns m1 XOR m2.

Â This is information about m1 and m2 jointly, right?

Â It might not be information about m1 or

Â m2 individually, but it does represent information about m1 and m2 jointly.

Â And that's something that should, that would be ruled out by any definition of

Â perfect secrecy for encrypting two messages using the same key.

Â Now, m1 and m1 XOR m2 is indeed some information about m1 and m2.

Â But I want to stress that this is not

Â just a technical point that we've leaked some information but in fact,

Â it can represent some significant information to an attacker.

Â Let me give a couple of examples.

Â So first of all the excor of m1 and

Â m2 reveals exactly where the messages m1 and m2 differ, right?

Â On any positions where m1 and m2 are the same their XOR will be 0.

Â And on any positions where m1 and m2 differ, their XOR will be 1.

Â So the XOR of the ciphertext c1 and c2 which is equal to the XOR of m1 and

Â m2 reveals to the attacker precisely those positions where m1 and

Â m2 differ and that can be a significant piece of information.

Â In addition, it turns out that some former frequency analysis can be applied,

Â even to the XOR of two English language messages.

Â All right. We saw in

Â an earlier lecture that we can take standard letter frequencies of,

Â of standard English text and use that to help cryptanalyze.

Â Encryptions using the vigenere cipher, or the shift cipher, and the same

Â underlying principle can be used when all you have is the XOR of, two messages.

Â It's a little bit more difficult.

Â A lot more difficult,

Â actually, because XORing two plain, two English language messages tends to

Â smooth out the distribution on the possible values of the XOR.

Â Nevertheless, if the plain texts are long enough, it turns out this information can

Â be used to derive lots of information about the underlying plain text m1 and m2.

Â Finally.

Â It turns out that, by exploiting some particular characteristics of

Â the ASCII representation.

Â The XOR of m1 and m2 can reveal lots more information.

Â I want to go through that in more detail next.

Â So here's the ASCII table that we've seen in a previous lecture, and

Â I've highlighted that portion of the table that illustrates the correspondence

Â between the letters of the English alphabet, both upper and

Â lower case, and their askew equivalent.

Â If you look at this table, what you can notice is that all letters

Â begin with 01, or rather the ASCII representation of all letters,

Â whether they're upper or lower case begin with the two bits 01, right?

Â Every letter corresponds to a single bit, to a single byte, rather, or eight bits.

Â And if you look at the eight bits that correspond to every letter,

Â you'll see that they all share the prefix 01.

Â In contrast to that, the space character begins with the prefix 00.

Â What this means is that if we have the XOR of any two letters, we get some byte.

Â With prefix 00.

Â But, if we have the XOR of a letter, and

Â a space character, then we get the prefix 01.

Â And, this allows an attacker to identify the XOR of a letter and a space.

Â Right, if the attacker has the XOR of two messages it can look byte by byte.

Â And it can guess that any byte with a prefix of

Â 01 corresponds to the XOR of a letter and a space.

Â Now this is not perfect, right it's possible to have two

Â space characters that XOR to a byte with prefix 00.

Â It's possible to have punctuation characters as

Â well that might mess this up.

Â Nevertheless, punctuation characters and pairs of spaces are expected to be

Â much less frequent than pairs of two letters and pairs of a letter and a space.

Â Just to go through this in pictures to illustrate the point more clearly.

Â So here we have, for example, two ciphertexts.

Â That were both encrypted using the one time pad and the same key.

Â And I just highlighted here the initial two bit prefix of every byte.

Â So the rectangles they represent bites, and

Â the bits that are displayed there are the two bit prefix of each bite.

Â If the attacker XOR's these two cypher text together.

Â Then it obtains what, what I've displayed on the bottom here.

Â And what you can see, right,

Â is that the two bit prefix of the first three bytes is 00.

Â And the two bit prefix of the fourth byte is 01.

Â So the attacker can guess here that the first three bytes of each of these,

Â the underlying plain text corresponding to these two initial ciphertexts.

Â Are letters.

Â But in the fourth position we have a pairing of

Â a space character, and a letter.

Â Right, the, again, the attacker doesn't know whether the first plain-text has

Â the letter and the second plain-text has the space or vice versa.

Â But it can guess, with high confidence, that one of

Â those blue shaded bytes corresponds to a letter in the underlying plain-text.

Â And the other one corresponds to a space.

Â Now given that, the attacker can look at the full byte,

Â the full value of the fourth byte in the XOR of the two cipher texts, and it then

Â knows that that byte is equal to the XOR of a space character with some other.

Â Plain text character with, with the ASCII representation of some letter.

Â You can easily solve this in this particular example to

Â see that the letter is the letter p, the lower case letter p.

Â So again, that means that the attacker has now learned that one of the blue-shaded

Â regions corresponds to a space character in the underlying plain text.

Â And the other blue shaded region corresponds to a lower case letter p in

Â the underlying plain text.

Â And if you extend this, where you can imagine that the attacker can

Â learn lots of information about each of the underlying plain text.

Â Things get even worse if multiple plain texts are all encrypted using the same key

Â because then the attacker can apply the same analysis.

Â To each possible pair, of cipher-texts.

Â Now what we've said is that the one time pad has

Â these two key drawbacks first of all that the key is long as the message, and

Â secondly that the one time pad encryption scheme is only secure,

Â if a particular key is used to encrypt only a single plain text.

Â Now it turns out that these limitations or these drawbacks are not something specific

Â to the one time pad encryption scheme, but they're in fact inherent limitations for

Â any encryption scheme achieving perfect secrecy.

Â Right, we might have thought that the one time pad encryption scheme has these

Â drawbacks, but we can hope to do better by designing some

Â other perfectly secret encryption scheme that doesn't suffer from these drawbacks.

Â But that's not the case.

Â All right. These two drawbacks are inherent for

Â any scheme achieving perfect secrecy.

Â I want to prove this for the particular case of the key links.

Â That is, I want to show that the one-time pad is, in fact, optimal as far as

Â perfectly secret schemes go, when it comes to the length of the key.

Â And the theorem I want to prove is the following.

Â If we have an encryption scheme defined by the algorithm Gen, Enc, and

Â Dec, and with message space M.

Â And if that encryption scheme is perfectly secret, then it must be

Â the case that the size of the key space is at least the size of the message space.

Â And that means that if we represent keys and messages.

Â Using some fixed length bit strings.

Â That the length of the key.

Â Must be at least the length of the messages that can be encrypted.

Â It turns out that the intuition for the theorem is actually very simple.

Â The basic idea is that given any ciphertext,.

Â An attacker can simply try decrypting that ciphertext using every possible key in

Â the key space.

Â We've seen this before for the example of the shift cipher, where we mentioned that

Â given a ciphertext, an attacker can just decrypt using all 26 possible keys.

Â If the attacker does this, then it obtains a list.

Â Of possible messages that can correspond to that cypher text.

Â All right, the only messages that can possibly correspond to that cypher text,

Â are the ones that can be obtained by decrypting that cypher text,

Â under every possible key.

Â Now the point is that that list can contain at most,

Â the size of the key space number of messages.

Â Each time I decrypt with some key.

Â I get one message.

Â It's possible that two different keys map onto the same message, that's fine.

Â But the point is that the list of possible messages can have

Â a size at most the size of the key space.

Â Now if the size of the key space is smaller than the size of

Â the message space.

Â Then that means that there's some message not on that list.

Â If a message is not on the list, it means that that message could not possibly have

Â been the one that the parties encrypted and

Â commu, and wanted to communicate with each other.

Â And that's already a leakage of information to the attacker.

Â Let's turn now to the formal proof.

Â We're given some private key encryption scheme defined by algorithms Gen, Enc and

Â Dec, and with message space M.

Â Let's assume that the key space is smaller than the message space.

Â We'll argue that this implies that the scheme can not be perfectly secret.

Â So what we need to do to show that the scheme is not perfectly secret is to

Â show some distribution over the message base, some message m,

Â and some ciphertext c such that the probability that the message is m,

Â conditioned on observing the ciphertext c.

Â Is not equal to the a priori probability with which the message was equal to M.

Â So let's take the uniform distribution on the message space.

Â In fact the exact distribution is not really important for this proof.

Â What's important is just that every message in the message space can occur

Â with some non zero probability.

Â In any event, we'll take the uniform distribution for completeness.

Â Take any ciphertext c in the ciphertext space.

Â Now, consider the set M(c) which is just the decryption of

Â that ciphertext c using all possible keys in the key space.

Â That is we take the cypher text and we decrypt using every possible key.

Â And each of those goes into our set M(c).

Â The key observation that we had before was that

Â these are the only possible messages that could've yielded the ciphertext c.

Â Now the size of this set.

Â Which corresponds to the list we talked about on the when we

Â discussed the intuition for the proof.

Â The size of the set is at most equal to the size of

Â the key space which by assumption was strictly smaller than the message base.

Â Now, that means that there's some message in the message base.

Â Which is not in this set.

Â And therefore could not have been

Â the message that the parties were communicating.

Â So that means that the probability that the message was equal to

Â that message M which is not on not in that set.

Â Conditioned on observing the ciphertext c is 0.

Â It's simply not, possible.

Â For the parties to have been encrypting that message M and then obtain,

Â to obtain the ciphertext c.

Â Simply because there's no key, for which the encryption of m using that key,

Â would result in ciphertext c.

Â So again, the probability that the message was equal to M,

Â conditioned on observing the ciphertext c, is 0.

Â And that's different from the priority probability that the message was

Â equal to M which we said was non-0.

Â So this concludes the proof that the encryption scheme, having a key

Â space smaller than a message space, could not possibly be perfectly secret.

Â So where do things stand?

Â Well we've defined perfect secrecy,

Â we've also shown that the one-time pad achieves it.

Â And we've just now shown that the one-time pad is optimal,

Â at least as far as its key length is concerned.

Â Does this mean we're done?

Â Well, I hope not because we've got several weeks left in the class.

Â In fact, we're not done at all and things are just starting to get interesting.

Â What we'd like to do is to now relax the definition of perfect secrecy.

Â And obtain a definition which is still meaningful and

Â useful in practice, but allows us to circumvent these inherit draw backs of

Â perfect secrecy that we've discussed in this lecture.

Â And this is what will occupy us for the next few lectures.

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