 So of our classical ciphers, Caesar ciphers easy, okay? That's the easy one. We saw the easiest so far We saw a brute force is simple brute force try all keys 26 keys try them all you'll get the one of those Potential plain text will make sense and you'll have the the key in the plain text Then we last week we introduced a mono-alphabetic cipher where We simply to define the key as the mapping from one letter to one of the other possible letters And I didn't write it in full, but an example We choose a mapping from letter a to any of the possible 26 letters and from letter B to any of the other 25 letters and C to any of the other 24 letters and that mapping however we choose it is the key in fact So when we equip we just do a mapping from plain text to the corresponding ciphertext if I choose a different mapping it's a different key and With this simple scheme of mapping one of the possible input plain text letters to one of the One other letter in the character set If we have our 26 lowercase English letters, we get 26 factorial possible keys or 26 factorial possible mappings That goes a can map to 26 possible values b to 26 minus 1 because we just use one for a and C to 26 minus 2 of 24 because we've already used two of the 26 for a and b So we get if you keep doing that 26 times 25 times 24 26 factorial Possible keys if we did had a different character set Maybe we included uppercase and lowercase characters treat them different Then we have 52 factorial factorial possible mappings depends on the size of the character set brute force attack not boss not possible But I pointed to a web page that shows that It's very easy to do an attack on a mono alphabetic cipher Based upon the statistics of the input plain text We exploit the regularities of the language every language has some structure Some letters are more frequent than others some Words are more frequent than others by using that structure. We can Defeat a mono alphabetic cycle That's crypt analysis and we pointed that this is just an example if we take some English text count all the letters in that English text Then it turns out for this example English text in this case. There are 12 percent ease nine percent T's and Almost zero Z's and so on so we can use those statistics to do an analysis I will not go through an attack for this in the class But you should read the website which is pointed to from our course homepage that the Documents an attack on a mono alphabetic cipher and you can see see it in progress It's quite easy to do we'll return to this after we look at some other cycles Well, actually we can say something quickly about it now and then return So if we think of English 26 letters we said in typical English text plain text some letters occur Accur more frequently than others E is more frequent than Z Okay What this plot shows is that in order of the most frequent so the most frequent letter through to the least frequent letter Normalized between zero and one so the most frequent letter is one The least frequent letter is zero and the others in between Normalized based upon their their values or the frequency compared to the most frequent and the least frequent If we look at the solid line, which is marked plain text That comes from some typical plain text or a set of plain text So what you could do is maybe collect a hundred books Long books in English count all the letters count all the A's B's C's and so on Work out the percentage of each letter and that tells you the frequency What this shows is that for the most frequent letters All right, there's the most frequent and then the second most frequent and the third most frequent and so on and then the least Frequent letters in typical plain text. So there's some letters which occur much more often than the rest There's some structure in the plain text What we want with a cipher is to take that plain text which has structure Encrypted and get cipher text that doesn't have that structure that doesn't exhibit this structure and the perfect case is If you take the plain text encrypt and you get cipher text, which we say is random Random and We'll talk about random in detail in one topic, but we can say random would be of all those 26 letters They occur about equally in frequency The letter a occurs as often as the letter letter z and of course also not in sequence, so it's not all A's and then all B's and so on so random would be this horizontal line because the one letter Would have the same frequency as the all other letters. That's what the horizontal line shows and With 26 letters, what do we get? one divided by 26 in this case, what do we get? I'll check the numbers later all letters the same Frequency that's what we desire for a perfect cipher Because that means that the cipher text Doesn't exhibit the characteristics of the original plain text There's no structure and if there is structure in the cipher text That can be mapped back to the plain text then the attacker can take advantage of that So what we want is no structure in the cipher text so that the attacker cannot take advantage and work back to get the plain text So this is an example of typical plain text Showing that some letters are more frequent than others the horizontal line is our ideal cipher the output cipher text All letters occur with the same frequency We're going to go through some different ciphers and compare them and we'll return to that after we go through these other cycles So we've got two or three other ciphers Classical ciphers there are many more, but we're just covering several to illustrate some different concepts So far we looked at Caesar And we're looking at substitution ciphers. We take one letter and replace it with some other letter from the character set So with Caesar the character set is a through to Z We take our letter in plain text and replace it with some other letter to get the cipher text How do we replace it? Well, we follow this Caesar cipher algorithm of doing this shift to the right or in math add the key value mod 26 We replace one letter with one other letter in Caesar cipher similar in monoathletic cycle to encrypt The word bad VAD we take B and replace it with Z A with D and D with L in this example key We don't have to replace one letter with one other letter. We can look at groups of letters at a time and The play fair cipher does that let's go through and see how it works and then we'll look at some characteristics of it what we do is we we Assuming the 26 English letters as the character set we write a 5 by 5 matrix So we have a 5 by 5 matrix 25 elements 26 letters 25 elements We're going to treat the letters i and j as the same we'll see how it works in a moment, but let's say i and j at the same letter So it gives us 25 letters to start with What we do is we have a keyword That's going to be our key. We have a keyword you choose your secret keyword You write that keyword in the matrix row by row So you fill out the first row then if there's letters remaining in the keyword the second row and so on and then the remaining Elements in the matrix you finish with the rest of the alphabet in order So that none of the letters are repeated inside that 5 by 5 matrix We'll do that and then we'll encrypt and the example we're going to encrypt plain text with the keyword Generate or draw the matrix So there are our rules. Let's try and do that So we write our keyword In a 5 by 5 matrix which is 5 rows 5 columns So there's our five columns in the first row and we move on to the second row and We don't repeat letters because what we want to do is fill in this matrix with The entire alphabet now I say the entire alphabet 26 characters, but let's treat i and j the same So in fact this i I'll note here also as a j Come back to that So Thailand is our keyword. We already have the letter a So that's the next letter is n So we write our keyword and now for the remaining elements of the matrix fill out the rest of the alphabet in order So we have the letter a already. So the next one is B. We have D. I usually make a mistake with this Let's see how we go fg We have h ij We have t already There's our 5 by 5 matrix for our play-fair site. So we have a secret. That's the keyword so the The entity that's going to encrypt and the one that's going to decrypt must know the keyword for this to work No one else knows it. So we write the keyword down and then fill out the rest of the matrix Now we take our plain text and encrypt using this matrix and the rules to encrypt We operate on a pair at a time a pair of letters in the plain text. So a diagram is a pair of letters so we break our plain text into pairs of letters and We look up the matrix using those pairs of letters. We find those that pair in the matrix and we do a replacement so what we do is The plain text So we have a pair two letters in the matrix. We find in the matrix the ciphertext output Will be the value on the same row as the first letter and the same column as the second letter We'll see some special cases. So we'll come back to the special cases in a moment. What's our? Sorry, what's our? plain text hello We're going to operate on pairs of letters. Hello, so we can remember and operate on pairs of letters So we have five letters in this case. We're going to need six So we need to do deal with some special cases sometimes the first So the first pair is going to be he The second pair is LL, but there's a special case first We cannot have a pair with the same letter Otherwise the algorithm won't work so when we have a pair that then the two letters are the same we insert a special character a special letter and The simplest one is to say X But any letter that we can we can define to be the special letter But we'll use X because X is not very common in between two two letters Okay, so we define instead of having LL. Let's split LL into LXL Okay, to separate the two where X is our special character. So it'll become LX Really, I've inserted an X in here and so he LX and then LO Convenient brings us to six characters or three pairs or three diagrams So we have some special cases for this algorithm to work One of them is if you have a pair we break the plain text into pairs if we have a pair That has the same letter Then split it up by inserting some special letter and Both the encryptor and decryptor must know what that special letter is they must agree upon that So usually it's the part of the algorithm So let's say it's X If we had a letter remaining we'd add that special letter at the end to Pat it out to be an even number of letters in this case. We're up to six characters. So we're fine But if we had a seventh character Then we'd have to add an X to the end. So we've got another pair Now what we do is consider a pair at a time He is the first pair to encrypt We look up in the matrix the letters H and E and The output ciphertext is the letter on the same row as the first so we'll get two letters out Consider letter H. The output ciphertext is the letter on the same row as it on this first row and In the same column as its partner E in this case. So the same row as H The same column as E the output will be L And then because we're dealing with a pair of letters We have H E then we consider E the same row as E The same column as H the output will be D So the output pair will be LD in this case that will encrypt and I'll write it in uppercase although our characters are Always lowercase just to distinguish. That's the ciphertext LD do it for the last or the next two pairs LX and LO so encrypt LX the next pair and then encrypt LO the third pair. How come I got D? Because remember we operate on a pair at a time the input pair was H E Okay, that was our plain text so the output pair the output ciphertext what we do is can For H the first letter in the pair look at the row of H the first row and Look at the column of its partner The column of its partner is this fifth column its partner letter is E in the pair So the output is L. It's on the same row as H and the same column as E That's the first output letter L But then for the second output letter we had H E. So we look at E Same row as E Same column as its partner the partner of E is H We get D the next pair So H E L X L X becomes L X becomes a Yep Okay, good. Okay, let's try and go let's Look at this. So our input in the first instance is what do we have H E? We deal with a pair at a time So here's H Here's E Consider the first letter in the pair H look at the collar of the row the same row as H and Look at this column of its partner letter the partner letter of H is E. So the row is The top row and The column is the last column So we end up with the element in the same row as H and the same column as E and Then we do it again, but from E's perspective the same row as E This row the same column as H. We get D and that's the ciphertext Then we have and a few of you have done it H E L X L and X same row as L same column as X we get a Then the partner letter the same row as X the same column as L. We get Z and what's the last one? What do we have? Hello, what's the answer? Hello, this one doesn't work. We need a special case because L and O are in the same column So if they're in the same column Shift down to get the ciphertext. That's the rule. So L and O in the same column So it doesn't make sense to look at the the pairs in a normal way. So what we do is L becomes E and O becomes U. So if they're on the same column We take this we have a special rule that shift down But I get that right shift down or shift up. I've got a right good If they're on the same column then the output ciphertext so L and O is the ones below it and When we need to we wrap around So if the input was for example EZ Then the output would be O and wrap around to L Okay, so we wrap around where necessary if they're on the same row. So if the input was MO The output would be M becomes O. O becomes F on the same row Move to the right wrap around if necessary on the same column move down wrap around if necessary So the ciphertext becomes L D A Z E U Just repeat that here. Just a different cipher So we get our six characters of ciphertext and that's on the pre on the slide in our lecture notes Decrypt essentially do everything backwards. So someone receives the ciphertext L D A Z E U They generate the same matrix So the person who receives the ciphertext knows the keyword Thailand they write the keyword they fill out The decryptor gets the same matrix and then they do a lookup LD Okay, LD What's the input plaintext if LD is the? the ciphertext first same rule here H E Okay, same row same column But for L O so they receive ciphertext EU They receive EU on The same column therefore to decrypt they move up not down and they'll get L O back as the output and When someone decrypts if they follow those rules when they decrypt What would I get as the plaintext if you decrypt the ciphertext LD A Z E U? You'll get and you can check So the person receives the ciphertext decrypts and they get H E L X L O Does it make sense? we're not quite and then The the decryptor needs to recognize that okay. This X is probably a special character And in most cases you'll be able to recognize that because in very few words Does X become come between two letters like that? So it needs a little bit of post-processing to recognize that this X was inserted as a special character Just to make the algorithm work. So they'd remove the X and they get hello It works much better when you have longer plaintext because you can see those words any questions on how it works We go through these ciphers reasonably quickly. We'll give an example of each You should be able to work them out decrypt and encrypt After a simple example any questions play fair so you know Caesar when you do the quiz this week you'll do Caesar mono-alphabetic Play fair Easy so far now the point about play fair cipher. We're operating on a pair of letters at a time with with our Caesar mono-alphabetic ciphers we encrypt one letter at a time and it turned out that That one input plaintext letter always mapped to the same ciphertext letter It's not necessarily the case with play fair if you have in our case Go back to our slides our input was H e l l o the two L's in there if We use Caesar or mono-alphabetic those L's would map to the same ciphertext letter but with play fair they don't that is Just because there are two L's here doesn't mean that it has very two characters of the same Two same characters in the ciphertext and they're not in this case So what play fair does by operating on a pairs pair of letters at a time is it spreads out these statistics of the Frequency of letters occurring in the ciphertext Even though there are two L's in the plaintext there are not two characters of the same In the ciphertext. Yep an odd number of characters in our input We've had out the end with a special character. So we add an X at the end for example. So if we have Steve Steve five characters none of the diagrams are the same character We'd have to add an X to the end at the plaintext because the play fair cycle works on a pair of letters at a time So it's padding that's called padding Turns out we need that in many algorithms including practical algorithms because they usually operate on fixed size Blocks if we have something of a different size we need to pad out to make the algorithm work play fair by operating on pairs of letters makes The statistics about the frequency of letters in the ciphertext to be more spread out than in the plaintext making it harder to analyze But it's still relatively easy if you have computer support I don't have an example of breaking it, but you can do it with a bit of effort because still diagrams still Have some frequency in the ciphertext So every pair of letters in the input plaintext In many cases will map to the same pair of letters in the output ciphertext So by using analysis of the language structure, you can break the cipher So that's just a different example from what we've seen So yes, it's breakable quite easy with language analysis or the frequency of diagrams Trigrams and expected words Most of the examples I go through a short Are the words or short phrases just for simplicity on the board In real communications usually we have longer plaintext Sentences usually large large files or large documents to communicate a lot large stream of values And in those cases the statistics are much more accurate in terms of frequency of letters diagrams and trigrams so We've seen three Caesar monoalphabetic play fair another general type of cypher is polyalphabetic use different Different Substitutions for the character set don't necessarily have a one-to-one mapping of Encrypt one letter and always get the same ciphertext letter like in Caesar and monoalphabetic and there's some examples of cypher's vision air vernam and one-time Pat and we Textbook has this one. I've never covered it as an example. We'll look at vision air and one-time Pat and we see their advantages and the problems Vision air is easy It's an extension of the Caesar Cypher It's really the set of 26 general Caesar Cypher's What we do is we have some plaintext With a Caesar Cypher with that plaintext we chose a single letter key and And that led a map to a number with the Caesar Cypher and that number determines how many characters we shift by that was the Caesar Cypher With a vision air Cypher what we do is we have a key word in this example, sirindore and what we do then is We repeat that keyword As many times as necessary such that the key which is made up of the keyword is as long as the plaintext So this simple example Here's my plaintext internet technologies my keyword sirindore. I need to repeat it so that I have the same number of letters That's the rule for this cycle if I Had some more characters here. I just keep repeating si are until I get the same number of characters as the input plaintext Repeat the keyword and then I encrypt using the Caesar Cypher where here's the input plaintext to the Caesar Cypher I and the key is s or 18 and Encrypt I with key s you get a as an output and just to remind you of the Caesar Cypher or the mappings Let's bring you the the letters just remember the mapping from Letters to numbers and text is I The key is s So we look them up. We start with I eight Key is s so 18 8 Plus 18 is 26 26 mod 26 is 0 So the output Cypher text is 0 or the letter 8 So it's just applying the Caesar Cypher then the next letter in plaintext is n But we have a different key. We don't reuse the key across each letter. We now you have the key I n and I N is 13 I is 8 13 plus 8 is 21 the output is a V and we get our Cypher text value V and we do that for the rest of the letters So we're just using the normal Caesar Cypher, but instead of using the same key letter For every input plaintext letter. We use a different key letter Where the key letter comes from the key word? Repeat it as long as necessary any questions on how to encrypt and decrypt with Vision air Cypher. Let's look at some Advantages of this compared to Caesar and a mono-alphabetic when we have Letters, which are the same on the input plaintext. We don't necessarily get the same letters in the output Cypher text That's the advantage. So Here we have n and n in the input We get V and Q as the output or if you look at the ease in the input We have which is normally the most frequent letter. We have e e E for ease the outputs for those ease are M, L, R and V So if we have a long plaintext and we'd expect for a long plaintext about 12% of the letters would be E that comes from our typical analysis In most cases ease the most common. Let's say 12% of the letters on the input at E using the Vision air Cypher What we'd expect is that the output Cypher text letters Would be all different when we encrypt that E Which means we wouldn't necessarily have 12% of one particular letter in the output Cypher text So there's not a one-demand mapping of plaintext to Cypher text letters One plaintext can become one of Many possible Cypher text letters. That's because we change our key letter So that's the key advantage or the important advantage of the Vision air Cypher But if we have an input plaintext Because we repeat the keyword There still may be a chance of repetitions in the output Cypher text. Do we get one in this case? We see in this case we have a T Encrypted with an R to get a K and another T encrypted with a R to get K so in this case Input letters T become the same output Cypher text letter, although this T is different if we extend The plaintext and keep going and make it long, which is typical Then there's more chance that same letters in the plaintext will map to same letters in the Cypher text And that opens up a chance for the attacker to take the Cypher text Look at the frequency of letters in the Cypher text and try and map that back to what the plaintext is So it makes it vulnerable to an attack What we want in the Cypher text remember is an even distribution of the letters with no relationship to the No visible relationship to the input plaintext Visionary Cypher almost does this except the fact that we repeat the keyword Therefore there may be repetition or structure in the Cypher text What do we do to improve? suggestions comments questions You have a question because you asked him He can tell you the answer and then he can tell me the answer and I'll explain to everyone problems It's okay. It's all right if you have a question. Let's solve it because you have a quiz this week this one Okay, we just use The Caesar Cypher on each instance, let's go backwards the last Letter s Okay, look at s is the plaintext the key is n where did n come from? Well, what we did is we took our key word our secret and just repeat it s is The plaintext n is the key we use the Caesar Cypher remember take s as the plaintext and Shift it by n or 13 positions So you go to the right 13 positions and you end up at is it f I think in that case Yeah, because if you look one two three four five six seven eight nine ten eleven twelve thirteen positions to the right of s is f Because we wrapped around so when we encrypt s with n We get f as the Cypher text The Caesar Cypher so you need to know how Caesar Cypher works to to understand this The problem with the vision air cipher is that we have a key word which is usually short relative to the input plaintext Now consider a long plaintext we'd have to repeat sear and horn many times Why do we have a short key word why? Why have a short key word? Easy to remember. Okay, remember the key word is some secret that we need to communicate between the two entities and they need to be able to remember it or use it Imagine we don't have computer support. This is 50 60 years ago or earlier. We want to encrypt on pen and paper I need to remember the key word is sear and horn So we usually we use a word or a phrase something we can remember easily and It's usually short If my plaintext was a megabyte a megabyte text file I usually have a short keyword as the as the secret and That leads to the problem with this cypher because with a long plaintext and a short keyword we repeat the keyword many times and We still get many chances of repetition in the ciphertext When we have repetition in the plaintext we get some repetition in the ciphertext We get some structure not not random ciphertext, which is a problem So how do we fix it? easy how randomize the keyword and even better So instead of syrin hole, and I choose a zq x Fg right. I can't remember it, but it's random. That's gonna help because there's no structure in the keyword. What else? Hmm change the frequency. Well, we can't change the frequency of the input plaintext Assuming we want to work with any input plaintext. We don't control that We could use a longer keyword a long random keyword and The ideal case is as long as the input plaintext so with my plaintext of whatever it is 20 characters Instead of choosing syrin horn. What would be better is to choose a 20 character random keyword because then We'd do the same a play our Caesar cipher When we have all our ease If the keyword is random Then it will map to a one of the to a random letter and the output ciphertext would be random Double encrypting encrypting again Yes, it helps it helps We'll see an example of that later Yep, so encrypting again. We'll see is a principle that's used in many practical cycles or encrypting multiple times This one though, of course encrypting again Halves the performance takes more time to encrypt For this one a Simple extension choose a keyword which is random and is as long as the input plaintext So is this vision air cipher breakable? Yes It's harder than the others, but it's still possible The weakness is the repeating structured keyword the solution choose a non-repeating Unstructured keyword that is a long random keyword and That's where we get what's called the one-time pad That's the same as the vision air cipher, but use a long random key and it's perfect in terms of security It's unbreakable Do we have an example See if we can find an example Maybe one I've done before I think I've given you a printout that Is in your lecture notes. I'll see if I can find that Rather than having to do one on the board on the screen You should have this printer Somewhere behind the towards the end of the election. I'd see if it's not there Then it's just a printout of one of the web pages linked to from our course website It looks at the one-time pad gives an example. I will see another one in the the lecture notes But just bring up the example I'll go straight to it So the one-time pad we can think as the vision air cipher, but with a long random keyword And it doesn't show very good, but it's here and it's run off the screen We zoom in a little bit here. I use some software to encrypt some plaintext the internet is a global system of interconnected and it kept going I use the vision air cipher, but I chose the keyword to be random There's no structure. I generated a random keyword and it turned out the keyword was as long as many characters as the input plaintext Sorry, there's something missing there. Not very good example because it runs off the screen What you see here is the output cipher text. Sorry, you don't see the keyword because Done the keyword was this That was the random keyword and this was the resulting output cipher text The input plaintext had frequencies as shown here So the plaintext message had 10 percent T's 10 percent or ten and a half percent E so E and T the most frequent in this selected plaintext and Then O was the next frequent and then N and then we go down. So that was the plaintext We see some are much more frequent than others Which is what we expect in any plaintext when we encrypt Then look at the frequency of letters in the cipher text We see most of them are about the same. Okay, these are a little bit more frequent just 5% with 26 characters We'd expect what about 4% for each character about 1 in 1 in 26 so with a hundred characters and We have 26 different letters. We'd expect about four of each Four out of a hundred so about four percent would be Even for all the characters or these some are five many of four some are close to four There are a few others down the bottom This is was an example where we use the one-time pad and the resulting cipher text Some letters are a little bit more frequent than others but not much The cipher text it's as if all the output letters are random And therefore occur about same frequency That example is probably not so good to show on the screen have a read through in the election notes to see that Let's go back to this plot This plot shows for a selected plaintext and then encrypted using some of our different classical ciphers the plaintext Frequent letters Shown here the least frequent the 26th here We want to encrypt such that we get an even distribution of the letters in the cipher text so that there's no structure in the cipher text and Some analysis in this example shows that okay With Caesar cipher and a mono-alphabetic cipher. We get the same frequency of letters as the plaintext That doesn't help in that case Play fare spreads them out a little bit Okay, so that there are some letters much more frequent than others still Visionaries better in that the frequency of letters is much more lower compared to the rest So the most frequent letter is a little bit more than average Whereas with plaintext, it's much more and The ideal case is that every letter occurs equal number of times the horizontal line and in fact That's what one-time pad achieves The one-time pad achieves this ideal case with long enough inputs. It will produce the same number of a's same number as the number of z's in the output cipher text and Cues and ours and bees and teas and so on approximately the same number in the cipher text and random random arrangement of those characters Therefore the cipher text has no structure and Therefore the attacker cannot do any any analysis to determine the original plaintext Crypt analysis is impossible with a one-time pad. So the one-time pad is perfect in terms of Crypt analysis, there's no way for the attacker to give in the cipher text if they don't have the key to work out the original plaintext What about brute force attack one-time pad? How do we brute force it? Try all the keys. How many keys are there if my plaintext is 10 characters long 10 to the power of 26 other way around How many keys if it's if my plaintext is 10 characters long? Well, if my plaintext is 10 characters long My key will be 10 characters long and The way I choose my key is randomly choose like the first character will be one of 26 The second character will be one of 26 and the third character one of 26 and so on so Let's go back To our example, how many characters do we have in our plaintext here? There's 21 characters or about plaintext 21 characters here What can the key be if I use a One-time pad not serent horn a one-time pad the first letter of the key can be a through to Z 26 possible values the second letter of the key can be a through to Z and The third a through to Z. So each letter of the key can be one of 26 values so what we get is 26 so how many possible p's 26 times 26 times 26 21 times so 26 to the power of 21 in that case So depends upon the length of the plaintext So how many keys is that 26 to the power of 21? Calculator time that many keys. Okay. What's that? Can we make it into something? And I guess It's about 5 by 10 to the power of 29 Okay, that is this number is 26 to the power of 21 26 to the power of 21 divided by 10 to the power of 29 is 5 so the answer this number there's about 29 digits there 30 digits So that's the the number of keys if my plaintext is 21 characters What if I have a longer plaintext? maybe I Don't know and I'm one of the handouts. I did an example with 370 characters for some reason I think just a long sequence Well, the more characters the not more possible keys. I think it was 370 something Okay, you count the zero the number of digits there 10 to the power of whatever 200 or 300. I don't know How many is that? If I could do decryption at a rate of 10 to the power of 20 decryptions per second Okay, so how many seconds would it take to do a brute force attack? Well, if this is the number of keys and I could decrypt it 10 to the power of 20 per second Then the answer of this would be the number of seconds okay all right divide by 60 the number of minutes to convert minutes to hours divided by another 60 to convert hours to days divided by 24 days to years and What's bigger than years years to centuries right by 100? well That so here's the number here this many centuries to do a brute force attack big number, okay? so brute force against this simple 370 character plain text a short plain text in this case is impossible. It's not possible for a one-time pad So one time pad Is not possible in practice It turns out it's not possible in theory either even if we had the Computer with infinite power It turns out if we could calculate at this speed and get an answer the Result would have many plain text values Many of those plain text values that would make sense there'd be English phrases and sentences With our brute force on the Caesar Cypher remember we had 26 plain text values only one of them made sense But if you did a brute force attack on a one-time pad you'd have many possible plain text values that make sense Only one of them is the real one So as an attacker there's no way to know of those many possible plain text values, which one mate is the real one You just have to guess and of course that's It turns out Almost impossible to guess especially when you have billions and billions of possible plain text that makes sense So it turns out the one-time pad you cannot do crypt analysis against and You cannot even with an infinite power computer Do a brute force attack against and of course we don't have an infinite power computer. So we should stop our course Because we have a cypher. It's relatively easy to implement. We have a cypher. That's perfect in terms of secrecy What's the problem? Why do we keep going? Well, it relies on having a key which is as long as the plain text So if I want to encrypt a DVD Okay DVD what about five gigabytes? I Want to encrypt a DVD file and then I want to make that available to someone so I choose a key Which must be also five gigabytes So I have to have the DVD and a key both five gigabytes So I must somehow distribute that five gigabyte key to the next person so they can decrypt Very inconvenient and very wasteful of resources because we doubled the amount of storage or transmission bandwidth It's very hard to Deal with such long keys and the keys must be random And it turns out to be secure. We must every time we encrypt something we must use a different random key So we must be able to generate random numbers Which don't repeat because if they repeat it's no longer random We've got a topic on random numbers later It turns out that generating long random numbers is Not very easy quite impractical to generate random numbers with a computer so One time pad we say is provides perfect security It is unbreakable in terms of brute force attack or crypt analysis, but it's very impractical Dealing with long keys is not convenient generating long random keys is very difficult So in fact has very limited practical use despite its security Here's an example taken from the textbook the case where the attacker knew this ciphertext so they had the ciphertext and Let's say the attacker did try to brute force attack Not possible, but let's say they could do a brute force attack. So they try all the keys It turns out that there are two keys These two that I've selected of all the possible keys. I've just chosen chosen two keys this key that they tried produced this plain text and This second key produced this plain text now as the attacker With a brute force attack you take the ciphertext try all keys and then you must recognize Which potential plain text is the correct one? Which of these two is the correct one does anyone know You cannot know you cannot know for sure Because they both make sense And in fact if you try to all the keys in the case you'd get many many more Plain text that makes sense. So the attacker even if they do a brute force They'll get many potential plain text that makes sense And therefore they will not be able to determine which one's the real plain text. And that's why we say that the one-time pad is Unbreakable in terms of the brute force attack. There was a mistake in this just as an aside. There was a mistake Did I fix it? Anyone see the mistake? Remember, this is the one-time pad Just using the Caesar cipher. Did I fix it or not? Let me check your lecture notes Is it the same? Okay, I fixed mine yours is different What's the mistake in your lecture notes the printed ones the first three letters of key to are wrong in your lecture notes I fixed it on here. So I think you have M something MF something correct. It should be PFT So in key to the first three letters two of them are wrong in your lecture notes And I've corrected them here If you look in the textbook I Copied from the textbook the textbook was wrong. I'm not blaming the textbook But the textbook has what do you see on yours? And it was maybe not last year the year before in this class one of the students pointed out there's a mistake there and In fact confirmed it was and we we told the textbook author and now he's fixing the textbook based upon Some of your senior students feedback during the lecture Okay, so you can pick up some errors and influence the textbook and other sources So fix PFT is key to the correct start of key to How do you how did I detect that or how did the student detect that? It wasn't me What we do is Take the plain text Encrypt with P using a Caesar cypher we get the letter a Take the plain text here Encrypt with P M with P. We must get the same letter a whereas in your lecture notes I think you had here M encrypted with M Cannot get the letter a if M encrypted with P gives to that a So in fact It's quite easy to detect that mistake Okay, we've gone through a number of classical ciphers going from a very simple Caesar cypher from 2,000 years ago move to monoalphabetic and Then we looked at play fair where we operate on two characters at a time as a way to distribute the statistics of the cipher text Then we looked at vision air which just extends upon the Caesar cypher and a modification of vision air is instead of using a fixed length keyword use a Random keyword, which is as long as the plain text and we get the one-time pad and the one-time pad is perfect in terms of security But in practical in terms of performance and convenience These were all substitution ciphers In the last 10 minutes, let's look at just two transposition ciphers Substitution we took one letter from the character set and replaced it with some other letter from the character set so in Hello H e l l o with a Caesar cypher. We replaced H with some other letter from the alphabet of a through to Z transposition just rearranges the letters in the plain text It doesn't replace first one rail fence transposition take the plain text and write it row by row so in the example we say The number of rows the depth is three So what we do is we take the plain text and write I on the first row and on the second row T on the third row and then e back to the first row Let's try what we have internet technologies and applications. You'll do that Let's try a shorter example. I've got one not much shorter, but a little bit We have our plain text I've just chosen some words to make long enough We choose a key the key for the rail fence is the depth or the number of rows Let's choose a key of three Which means we write this plain text in three rows and you'll see what that means here H E L L O and keep going So just write the plain text in three rows and read row by row to get the ciphertext the first row H L T E C I and Then the second row E O E S U T and then the third row We just rearranged according to this algorithm of the rail fence No substitutions The set of letters in the plain text are the same as the set of letters in the ciphertext Let's try the next one And then we'll do a little bit of analysis Another one just another rearrangement the rows column We choose instead of a depth a single value for the number of rows we choose a key as a set of Intages Which will determine some way that we rearrange the columns We'll do that one security and cryptography three one five six two four So the plain text crypto Was it three one five six two four What we do is we write the plain text in rows and columns so write the first row the second row and Then the third row and the number of columns is determined by the key in this case. We have six integers in the key so we'll have six columns and move on to the next row that's a why and Because we need to fill out the rows. Let's add some padding and let's just add some special character. I'll choose x Now how do we get the ciphertext? We use the key and the key tells us which columns to read first So we have a key of three one five six two four. I'll write it again three one five six Four we read column by column Column one first column two column three So our ciphertext column one According to our key is E y y a column two R do y column three four five is CAPP and the last column is UNTH So again, it's just a different way to rearrange our plain text same Set of characters in the ciphertext as there are in the plain text. There's no substitution just rearrangement or called transposition or Sometimes called permutation a permutation of our plain text Make sure you know how to encrypt and decrypt these two Encrypt is quite simple this one You need a little bit of thought to decrypt make sure you can remember how to decrypt Just think how to do it such that you get the original plain text back You'll always see in an exam. Here's some ciphertext Decrypt using rows and columns for a particular key or even one year. I asked here's the ciphertext no key Find the plain text So with some intelligence you can start to guess words guess the arrangement of columns and See some patterns and work out what the key is and then what the plain text is How to decrypt that's a good question you'll work it out You decrypt think about going backwards start with this You have a key you Need to get the plain text the key tells you there are six columns Therefore how many characters here? 24 characters six columns So you're going to write Break it into chunks of four So this would be a column these four a column s t r r is a column So you can write them in the columns, but the arrangement of the columns must be based upon the key So this will be a column e y y a Do y will be another column and then use use the key to work out what the arrangement of those columns are try try that if you can decrypt these two and encrypt all the classical ones we've covered and decrypt the classical ones we've covered so far then you Understand the basics Let's stop there We'll talk about the the advantages and disadvantages and how these can help In real cypher's how these concepts can help in real cypher's on the Thursday You have an online quiz to do And it's open now and it closes At I think 1 p.m. Next Tuesday, so you have about a week to do it It closes before the first lecture next week next week Do the online quiz which has some cypher questions and some concepts from what we've covered so far