 So cryptography. First, let's look at the most common thing we think about with computer and network security is providing confidentiality, sending a secret message to someone. User A wants to send a message to user B. They want user B to be able to read the message, but they don't want anyone else to be able to read the message. We want to send a confidential message from A to B. That's a common thing we want to do in a system. How do we do that? Using encryption. So aim, make sure confidential information is not made available to unauthorized people, unauthorized users. How do we do that? We encrypt the data. We take the original message, encrypt it, send the encrypted form and the receiver, the intended receiver, should be able to decrypt and get the original message back. But anyone else who gets a copy of that encrypted message should not be able to decrypt and get the original message. That's how we'll achieve it. And we use encryption for commonly sending data across networks. I send a message from my laptop to some server. There are many places between my laptop and some server, say my bank website in Australia. There's a server in Australia. Between my computer and that server in Australia, there are many places where some malicious user may try and intercept my data and try and read the messages so they can get access to my bank account. So generally for networks, we cannot trust them because there's people that can get access to those networks and see the messages sent across those networks. A simple case is when I use Wi-Fi, I send a message wirelessly to the access point. It's not very hard for anyone to intercept and receive those messages sent from my laptop to the access point as long as you're within the vicinity. That's very easy to do. So similar, this access point sends via cables down to some server on the second floor, the computer center. What if someone gets access to that server room in the computer center and starts to intercept messages there? Then they can start to see the messages that I send between my laptop and my bank web server. And similar, all the internet service providers that connect between my laptop and the bank web server, do I really trust them? Maybe there's an employee with one of those ISPs that just sits there and has a computer that intercepts all the messages and tries to read the messages. So assuming someone can intercept messages on a network, what we do is we encrypt the data first. So we use encryption for sending data across a network, but we use the same technique for storing data on a computer system. We have a shared computer system. Okay, one computer, multiple users use it. So one way to make sure that other users cannot read your files is to encrypt those files on the hard disk. So we use the same technique in that case. So a model for how we use encryption. Let's say we have a user wants to send data to another user, A to B, the normal users. They send across a network. Then we have a malicious user, an attacker, user C in this case. And we assume that this malicious user can intercept and see everything sent between A and B. So everything that comes out of A's computer and goes into B's computer, we assume C can also see that. That's a normal assumption that we have. So how do we stop C from seeing the contents of the message? We use encryption. And what we do is we have the original message. We call it plain text. It doesn't have to be a text message, but the name we give the original message is plain text. And we apply some algorithm, an encryption algorithm, which transforms this plain text into what we get ciphertext, the encrypted form of the plain text. And we use some key as an input to this algorithm. So the input to this encryption algorithm is the plain text and the key. The output is ciphertext. Instead of sending the plain text, the original message across the network from A to B, we send the ciphertext. User C can still see the ciphertext. That's our assumption. User B receives the ciphertext and they need to read the original message, the plain text. So what they do is they decrypt the ciphertext to get the original plain text and to decrypt, they need some key. And the first cases we'll consider key two will be identical to key one. It will say they need to have the same key, but in general they may be different. We'll see. So what we say is for B to be able to decrypt the ciphertext and get the original plain text, they must have some key. If you don't have the key, but you have the ciphertext, what we'd like is that we cannot get the plain text out. So from C's perspective, the attacker, they know the ciphertext. Even though they know the ciphertext, if they don't have the key, they will not be able to get the original plain text. And that will achieve our goal of A, communicating to B, confidentially. So what we need for this is some encryption and decryption algorithms such that we take some message, apply some key, apply the algorithm. If we get ciphertext, we can only successfully get the plain text out if we have a key. If we don't have a key, we cannot get the plain text out. So we need algorithms that have that property. And that's what we'll go through, what algorithms can achieve that. So that's our typical model that we'll see and applied in many systems. So the terminology, some of it we just mentioned. Plain text is the original message. Ciphertext is the encrypted or coded message, the transformed plain text. Encryption is the process of converting from plain text to ciphertext. Decryption is the reverse. Sometimes called enciphering or deciphering, encrypt or encipher. But we'll usually use encrypt. And we use keys. In many cases, the information known only to the sender or receiver. Although there may be some cases we'll see later that some keys may be known by everyone. We'll get to that later. So often the keys are secret. At least one of the keys must be secret, not known to other people. Just one person or one or two. What algorithm do we use for encryption or decryption? Well, we'll see the algorithms, but what we call them is a cipher. Those algorithms are referred to as ciphers. Cryptography is the study of these algorithms of ciphers. So the studying and designing of ciphers is cryptography. Crypt analysis is the study of the techniques for obtaining a plain text from the ciphertext without the key. That is breaking the ciphers. If we can find a technique for C to use the ciphertext and get the plain text without knowing the key, then our system will not be successful. It'll have a flaw. So crypt analysis is the study of those techniques. How do we break the cipher? How do we get the plain text without the key? Cryptology is the combination of cryptography and crypt analysis. Cryptography is creating the algorithms. Crypt analysis is breaking the algorithms, defeating them. We've introduced symmetric encryption without mentioning it. We'll see in the next slide that the most common form, at least for most of history, of encryption used what we'll call symmetric key encryption. I'll define it in the next slide, but the requirements for it to work is that we need a strong encryption algorithm. What do we mean by strong? If the attacker knows the algorithm, so the algorithm is known, the steps that you take to transform the plain text to the ciphertext is known, and they know the ciphertext, a strong algorithm would be one such that the attacker cannot find the key or the plain text. Because if they find the key, they can automatically get the plain text. And if they get the plain text, then we've been unsuccessful. So a strong algorithm is what we want. The attacker can't find the key or the plain text, even if they know the ciphertext and the algorithm. So we want strong algorithms. And we will use keys, the source and destination, and in symmetric key encryption, we'll use the same key for encrypt and decrypt. So in the previous diagram, key one and key two were the same values. And we require that those keys are kept secret. We don't tell everyone what the key is. If we tell other people what the key is, then they can decrypt. So we assume that it's kept secret. And related to those, generally we assume that the algorithm, the cipher is known by everyone in the world, including the attacker. So I want to encrypt a file and send it to someone. I use some algorithm to encrypt. That algorithm is not secret. Everyone else knows the algorithm, the details and has probably implementations of that algorithm. So the algorithms generally are known. It's hard to keep algorithms secret. Maybe military organizations can do it, but even then it's quite difficult because if you want to try and keep an algorithm secret, you need to implement it in software or hardware. And it takes people to implement the algorithms, stopping people from divulging information about those algorithms is hard. So generally in security we assume the algorithms are known, including by the attacker. Coming back to our picture, in common cases, key one and key two will be the same. That is, user A has a key to encrypt with. User B must have that same key. Let's say user A is the person on my laptop. User B is the person or the bank web server in Australia. To communicate, I encrypt something, send it across the internet, and they decrypt it at the web server. For that to work, we need to have the same key. And we'll see the key is some value, usually some random value. Well, the problem arises is how do I get a key shared between those two entities? I create a key and I send it in an email message to the server or person at the server. Well, that's no good because someone can intercept and receive the key by intercepting across the network. So for both entities to have the same secret key and no one else to have it, we need some way to distribute keys, some secure channels, some secure means. Maybe I send a message in the post or that's if we trust the post offices on the way. Or I go there physically and I type in what the key is. We exchange it physically. We can do that, but very inconvenient. But we need some way to make sure both entities have the key and no one else have the key. We'll mention a few ways later. So cryptography, the study of these algorithms for encryption, how do they work? Well, the basic operations most algorithms use, not all, but many algorithms, they use two simple operations, substitution and transposition. Substitution is you take the input plaintext, say a set of characters, a set of bits, and you replace characters with other possible characters. You substitute one character for another, according to some rules. They're not just randomly, but according to the algorithm. Transposition is that you take the characters, called elements here, generally, and you rearrange them. Let's say the plaintext is hello, five characters, five letters, hello, H-E-L-L-O. And let's say we're using the English language. Substitution would be taking the letter H and replacing it with another letter, maybe the letter Z, according to some rules. Transposition would be rearranging those five letters, swapping the order of H-E-L-L-O. So that's the basic operations we use in many ciphers. Substitute and rearrange. Transposition also called permutate. And in fact, we don't just use those operations on their own, we usually combine them. We take a substitution, a transposition, and then another substitution, another transposition, and so on. And we get multiple stages called product systems. Let's go straight to an example to illustrate those very basic operations. We'll come back to those, maybe, the number of keys and so on later. We use very basic ciphers, and the first one is the Caesar Cypher. It's named after Julius Caesar, a Roman guy, what, thousands of years ago, or 2,000 years ago, I guess, and will operate it on, say, English plaintext. It's for simplicity, say, the plaintext is a set of, or can come from the set of 26 English characters. And the encryption algorithm is you take your character, you have a key, K, and the key tells you that the ciphertext output from the encryption will be the character K positions along, K positions to the right. Let's use an example to illustrate that. And I'll first just remind you, we have 26 characters. Let's consider lowercase characters. That's all our plaintexts can be. Forget about spaces and so on. We can add them if we need. And we'll think about the characters numbered from 0 to 25. Start at 0, we have 26 characters. We'll come back to that. Let's encrypt using the Caesar Cypher an example. And so we'd have some plaintext. What's a plaintext? It's on plaintext P. And I'll just choose a message. Hello. There's our plaintext. We want to encrypt that using a Caesar Cypher. So that's the input. The other input is a key. And I would choose the key and the letter D. Where think of the letters mapped to numbers. So A is 0, B is 1, C is 2, D is 3. D corresponds to the number 3 in this case. I'll just make note of that. That's 3. So to encrypt, we take the plaintext and the key and we get the Cypher text. And what we do is we shift, we take the letter H. The Cypher text output for that input plaintext letter will be the letter 3 positions to the right. What is it? This is easier in this case. So we start from the letter H in the seventh letter in our list. That's the input plaintext letter. The output Cypher text letter will be the letter 3 positions to the right, the letter K. So when we encrypt the letter H, the Cypher text will be K. And the second letter input is E. And the output would be H, 3 positions to the right. Very, very simple. The simplest Cypher that we'll ever see. So H will become K. E will become H and we can go on for the rest. I'll write them down in a moment. You can do them. Or mathematically we can look at it if we allocate letters to numbers, we add 3. H was letter 7. The key was D, or 3. We plus 3 and we get 10, which is K as the output. With the exception, we wrap around if we get to the end. If our input letter was Y, that was a plaintext letter, and our key is 3, then we add 3. What's 3 letters beyond here? 1, 2, 3. The output would be B. We wrap around at the end. Mathematically, if the input plaintext is Y, or 24, 24 plus 3 is 27. We mod by 26. We mod by the number of characters. 27 mod 26 is 1. So the output is 1, or correspond to the letter B. Encrypt our plaintext. This is not going to be so easy because you need to switch back. But I think you can work it out. For example, H would become K. E would become H, and L, O, and so on. The second L would be at O. There are just three positions along. And our resulting ciphertext, you can check. I'll give you the answer. That would be our resulting ciphertext with a key of 3. If we use a different key, like a key of E, or 4, then we take our input plaintext letters and shift them four positions along. So the key is the number of positions we shift. Of course, we could generalize this to different input languages or character sets. So in this example, the character set that we can have is the 26 lowercase English letters. But you can have any character set. Tie any language. You can include punctuation marks. They just map to different numbers instead of 0 to 25, 0 to 30, or however many we want. Any problems? And of course, what we do now is send this ciphertext across our network. The receiver must also have the same key. The receiver must know that the key is D or 3. The receiver receives this ciphertext, and they must decrypt. What's the decrypt operation? How do we decrypt that? If you only know the ciphertext and the key, how do you get the plaintext? What's the steps? You go backwards. That is, you shift to the left. K-H-O-O-R. K, if you shift to the left, three positions bring us to H. So that's the first plaintext. H, shift to the left. E-O becomes L, L, and what was the other one? R becomes O. So decrypt in this case is just shift to the left three positions. Or subtract 3 mathematically. And mod 26 where necessary. The mod 26 is to handle the case when we wrap around. So your first cipher, Caesar cipher, is a good key. The key is the letter K. What's the plaintext? Ciphertext, you receive a message. Key is the letter K. So this means key. This is the actual value. K or 10 in the list of letters. What's the plaintext? So Coke, B-S-D-I. Maybe this is a bit easier for you. If you can't remember the letter positions. First letter of the plaintext. The first letter of ciphertext was C. M. The first letter was C. The key was K, meaning the key is 10. The key is 10. So I think we need to shift by 10 positions. Shift which way? We're decrypting, we shift left. To encrypt, we shift to the right. To decrypt, we do the opposite. To get the original plaintext back, we must be able to decrypt the ciphertext and get the original plaintext. So if our ciphertext started with the letter C, and the key was 10 or K, to decrypt the letter C would go back to the left 10 positions. Which would wrap around and bring us to S. 18. So decrypting C gets to S. What's the next letter? Ciphertext, C-O-K-E. First four, some people have got it. Did I do something wrong? I think I've made a mistake, but you'll get the plaintext. It wasn't what I expected. C-O-K-E. There's a mistake in this one. What's the answer? Some people have got S-E-A-U-R-I-T-Y. I made a mistake. I did it this morning, but maybe I wasn't awake. That was supposed to be a C, but it's in fact an A if you decrypt that. So it was supposed to be security plaintext. But you're right, that K takes us to A, not to C. I encrypted wrongly that third character. We're not going to focus on so much on the algorithms. We're going to use the algorithms to talk about their characteristics and principles. What's the last thing to say? Is this algorithm good? If you're an attacker and you know the ciphertext but you don't know the key, can you get the plaintext? How? Try all possible keys. How many keys are there? How many possible keys? 26, because there's only 26 letters here. Because if we treat the key as a number and we had the number 27 the shift by 27 positions is the same as a shift by just one position because we wrap around. So there are just 26 possible keys. One of them is not a good key because it doesn't shift anything. So all we do is try all possible values. An example is some ciphertext. What's the plaintext? So there's the ciphertext. It's hard to read, I know. So what you do, if you know it's encrypted with a Caesar cipher then you just decrypt it with all 26 possible keys. I've done it and these are all the potential plaintext values. What's the key? It's hard to see. 11. Why? Because that's the only plaintext that makes sense. Assuming we know that we're communicating in English that the original plaintext is in English what we do is we decrypt the ciphertext with all possible keys one of them makes sense, the rest will not. Very, very low chance that others will make sense. So the attacker now doesn't need the key they just do what we call a brute force attack try all possible keys. And in this case there are only 26 keys. I did this, you can do it manually in a few minutes. It's not hard. Computers do it instantly. So that's one reason this is a terrible cipher but for 2000 years ago it was used but there's another reason we'll see as well a bit later that even without a brute force attack and our first example we'll point to it one of the other problems is that each letter on input each letter maps to the same output letter look at E, E and E all mapped to H, H and H So that's the characteristic of this cipher Now we can take advantage of that as an attacker because the plaintext always has some structure If you think of English messages the most frequent letter in English is E it turns out. I'll show you some statistics later but the letter E occurs the most frequently in all words in English So what we do as the attacker we look at the ciphertext and we look at what's the most frequent letter here it's H Well possibly that means that that actually was E in the plaintext because the most frequent letter in plaintext will produce the most frequent letter in the ciphertext in this case So in fact there are ways to attack this and find the solution without trying all possible keys So even better We'll continue and look at some other ciphers and see how we can make them better next week What will you do for homework? Still, website So there will be no online quiz just yet But look at the website Make sure you're aware of everything that you need to do to pass the course and try the virtual networking software So there's instructions printed out in the handout and that's actually just a print out from a website So you can find the website and just follow the instructions there Try it on your own laptop and try it on the Macintosh lab We'll continue this next week