 Okay, last time we talked about symmetric encryption and we finished that, and we dived into asymmetric encryption. So what was symmetric encryption? Anybody remember? Yeah. Do you use the same key? Yes, two. Yeah, and? Do you use the same key? Yes. So we used the same key to encrypt and decrypt the message. And we started doing the asymmetric encryption. What was the difference? More than one key. So what were they? Public and private. Public and private. So like we were using public, like we were using one of them to encrypt and the other one to decrypt. So it's like we are using public to encrypt and private to decrypt, like that, so. And so did we start with the public key properties? Anything? From here? Okay. What, so with symmetric encryption, what were the problems? So yeah. You needed a way to... Yes. Security. Okay. What about another one? So did we have a way to prove that somebody sent something? No, right? So like, and do you remember what that was called? Non-repudiation? Yeah. Sorry. Okay. So let's start talking about public key properties. So it allows us to have confidentiality, which we had with the symmetric encryption. Okay. So what was confidentiality in terms of Alison Bob sending message to each other? Yeah. I want you to read the message. Yes. So if it is intended for Bob, then Bob can only read that message, right? For confidentiality. What about non-repudiation? What do we want? Again? Yes. But so Bob can know, will know that it's sent from Alice, right? So and Alice cannot say, cannot deny that I didn't send that message, right? So that was non-repudiation. So we will have these with public key in crypto, right? So and it requires for us to easy to generate public and secret keys, but it's very hard. It should be very hard to derive the secret key from the public key. And each party will have their private keys, right? And they are not supposed to give them to anyone else. So they cannot share this one. But public one will be known by everyone, right? That is the property of public key crypto. And everybody includes the EVE like an attacker. So attacker will know the public key. So we need a way to do this like properly. Let's go into encryption now. So how can we ensure confidentiality with public key and private keys? So let's say if Alice wants to send a message M to Bob, how can we encrypt this message? How should we? What should we use? The keys. Yes. So if you use Bob's public key, what happens? Yes. So and which is known to Bob only. So that is why we are having the confidentiality here. Yes. You are talking about both of them, right? Non-repudiation and confidentiality. We will come to that soon. Yeah. We will come to that. So yeah. So this is it. So like Alice encrypts it with Bob's public key. Then after that Cypher takes that Cypher text and he decrypts it with his secret key. This is how it's done for confidentiality. So what does Bob know here? For certain? Yes. So he knows for sure that it's intended for him. But what about does he know that it's coming from Alice? No. So we don't have the non-repudiation like this, like this way. So what does Eve know, the attacker? Can she retrieve the message? Why? Yes. So Bob only knows that. So even if she uses the public keys that she knows, nothing will happen. So she will have nothing, right? So then non-repudiation. So how can we ensure just non-repudiation for now? So let's say Alice is making a public statement, right? But we must know that it's coming from Alice, yes, but she doesn't care if it's known to everyone. Yeah. Because Alice knows that key only. So the other party, anyone, can decrypt that and they will know that it's coming from Alice. Yes, that's non-repudiation. So it's like this, right? So what does Bob know for certain now? Yes. And also, what else? So he has the ciphertext, right? He has the ciphertext. But Bob doesn't know. Like Bob, Bob, so the person who decrypts the message does not know it's intended for them. Yeah. I'm going to say that. They knew it was from Alice and that wasn't it. It wasn't tampered with? Yeah. Okay. They can't know for sure. So it's because they can't just flip the key a bit since that. So I mean, yeah. So that's another thing. So message integrity is related to hash functions. He may come to that today, but I don't know if he can touch it. So we will come to that. But he knows for sure that it's coming from Alice. And what does Eve know here? You already saw it, but yeah. So can she retrieve the message? Yes. So everybody can. So it's not confidential. So how can we make this like together? So Alice wants to send the message and to Bob, Bob will only decrypt it. And also he will know that it's from Alice. Just like you said. Could you repeat that? So outer layer, right? Two layers of encryption. Yes. Okay. Okay. Yeah. First, decrypts is with his private key, right? Because he only knows it. So it will be intended and he can only decrypt it. Then inside he will see that it's coming from Alice. Like you said. But so there's another thing. So what if you reverse those? So reverse means we are like Alice is decrypting with secret key first. Then inside, like again with a public key of Bob, what will this give us? Will it be the same? So outer layer is the secret key. And inside, like so first, she is encrypting with Bob's public key. First, then after that, her private key, no, no, no, her private key. So now we will know, like Bob will know that it's coming from Alice, right? So and Bob can only decrypt it because inside there is Bob's public key. So what is the problem here? Exactly. So like, Bob will receive the message, but he cannot be sure that we've got who was sent it from. So like maybe you sent it, maybe someone else sent it, but Bob will think that it's coming from Alice. Because he doesn't know for sure, like he cannot know like who is coming from the message, right? Okay. But like in this like situation here, first secret key, then public key, then you cannot know anything. And we have the non-repudiation and confidentiality together. Yes. So any questions up till now? Anything that is not clear? Yeah. Yeah. Yeah. Here, so you see that PB on the other side, what is that? Public key of Bob's, right? And inside Alice's secret key. So if we put Alice's secret key to the outside and first encrypted with Bob's public key, what happens? Could you walk me through like the outer layer will be as a secret key of Alice's. So outside, if it is secret key, right? Anybody can decrypt that. Because everybody has public key of Alice's, right? So our outer layer. But inside, who can decrypt that? Just Bob, right? So confidentiality is there. We can think of non-repudiation is there, but the attacker can decrypt it and they can encrypt it with their private key and send it to the other side. Other party. So you can encrypt it again with her private key. So non-repudiation is lost now, right? Okay. Cool. Okay. So we will dive into another thing now. But I mean, it's public key crypto, but it's different. So like this text here is not related to crypto right now. So it's from 1874. Okay. And let's read. So the same difficulty arises in many scientific processes. This is, he will talk about it. Given any two numbers, we may buy a simple infallible process, obtain their product. So multiplication is very easy, right? We can multiply anything. I mean, yeah. So, but it is quite another matter when a large number is given. And we are to determine its factors, which is like harder than the multiplication, right? So if you have a large number, like though that one, 8 billion, so it's hard to find the factors. Can the reader say what two numbers multiplied together will produce the number 8 billion, 600 million something? It is very hard to find the factors. I think it is unlikely that anyone but myself will ever know because they used prime numbers there. Large prime numbers. So it's very hard to find. If it is an even number, it's easier to find, but this is a prime number. And it's large numbers. So it's very hard to find. So can only be rediscovered by trying in succession a long series of prime divisors until the right one be fallen upon. The work will probably occupy a good computer for many weeks. So this computer is not a machine. It's a human being because it's 1874. So but it did not occupy me many minutes to multiply the two factors together. So like he can manually multiply those prime factors, but he cannot find the factors. Yeah, those prime numbers, but he cannot find the factors that easy, right? So we will use this easiness of multiplication and the difficult like aspect of finding factors in like future topics. So future key exchange or another like public key crypto systems. We will use these factoring. So let's go over history of public key cryptography like fast. So let's talk about public first. So 1976 with Phil Diffie and Martin Hellman published a way to exchange keys. Why did they do this? Why did they need a way to exchange keys? Let's go back to symmetric encryption. What did we need? Yes. Yes. So like an inner transmission, right? So because the only way was like I mean one of the ways that we can like do Alice and Bob can meet and they can just exchange the keys local like face to face or something. So it was hard. A secure channel was hard. So they needed a way to exchange keys for this. Then after one year revest. I don't know the pronunciation, but Shamir and Adelman created RSA. This is a general public key crypto system, right? But behind the curtains again classified government was like UK British cryptographers. They were they started working on this. They found this in 1970. Like six years before that public. So and they were he was working on a non-secret encryption. So don't get confused now. So it's like it's not non-secret. All the encryption is not non-secret. It's like some components are known to the attacker. Just that. Okay. Some of them. So we will talk about that. So and after three years Clifford Clifford Cox James Collette implemented RSA before the public like four years before that. You know, and they didn't know about it. So. So let's talk about Diffie Helman key exchange. So this is taken from Wikipedia. Okay. This figure image. So and this is like very easy way to understand like Diffie Helman key exchange. Okay. So let's talk about let's let's think about not numbers but paints now. Okay. So Alice and Bob they are agreeing on a shared color. Okay. Which is yellow now. Right. You can see that and this shared color is known to everyone. So Eve knows that color. Okay. But they also have secret colors. So you can see like on the left side, I don't know like how it looks like, but oh my God, that's okay. So on the left side, it looks like a reddish one. And the on the right side, it looks like a greenish one. Here. So and when you mix those, you are getting something like bluish on the right side and something orangey orangey on the left side. Okay. So this is like mix of paints. You can think of mixing paints. But the left side and the right side is only known to left side is only known to Alice and right side is only known to Bob. So nobody else knows that. And after that, they publicly transport this. So everybody sees this. Okay. Everybody sees blue. Everybody sees orange. Okay. Then after that, we are assuming that if you have a color, if you have a jar, like if you put the paints in it, right? So if you mix them, can you separate them easily? No. So that is hard. So the attacker cannot find the secret color there. You can only see or she can only see the mixture. So after that, when they apply their paints again, they will have the common point paint, which is brown. This is how it works in a high level. So let's talk about numbers now. Any questions? Did I lose you? Did I lose you? No. Okay. Cool. Okay. We talked about two... Sorry. Okay. So that P, Alice and Bob agrees to two numbers. Okay. This is one of them is 23. The other one is nine. This is known to everyone. He even knows that. Those numbers. Okay. Then after that, those secret colors we talked about. So Alice's secret number is four, and Bob's secret number is three. Okay. And they will do something with 23, nine and four, three. So it's like mixing the paints, right? So yeah, these are the equations. So I won't go into detail about equations. Okay. This is how it's done. So and these numbers are so simple. So this is just an example. Don't think that is like so simple to derive this. Okay. So you can see that here A and B, right? So that nine, they already know and everybody knew, right? But to the power of their secret numbers. So nine to the power of four. Mod 23, which is known to everyone. They are finding a number six. Alice finds a number six. And Bob now finds a number 16. So those are six is the orangey on the left and 16 is the blue one. Right. So and Bob sends 16 to Alice and Alice sends six to Bob. And they are doing the exactly the same thing. So they are doing the to the power like 16 to 16 is the one that Alice got from Bob. So they do 16 to the power of four mod 23. And Bob does the same thing with his private number. Okay. And they find the same number nine. Okay. And that becomes their secret. Okay. But this is used just to exchange keys. Because if they wanted to transmit the message itself with this technique, they don't know the outcome of the number like they don't know what will happen. They cannot control the result. Okay. Resulting number because they just like, yeah, they are taking different like random numbers. So they cannot control it. The outcome here, the result. Okay. Any questions? Cool. Okay. It's just random numbers. They just agree on it and everybody knows them. Yes. Yes. Yeah, don't get confused. It's like they can be different. So that yellow color consists of 23 and nine. Yeah. Yeah. Was G in this case like secret? No. Don't get confused with that too. It's just a coincidence. Okay. Yeah. It's just a coincidence. It came up with nine. So like, I don't know. But this is how it's done. So what was the secret that they were trying to exchange? The secret is nine. So they are agreeing on nine. And nine is not known to anyone because of the secret numbers, right? Yes. They are not the same thing. Yeah. Yes. So in the case of nine, I need to look at it. I'm not sure. Okay. I believe it's the key. I believe it's the key. Yeah. I believe it's the key, but I'm not sure. Okay. Yeah. Yes. But probably think about this. So what if they encrypt the key with this number? They can exchange the key like that, right? Nobody knows the key that was encrypted. Nobody knows that number. So they can also exchange like that. They can encrypt the key with this number probably. Yeah. So, yeah, let's continue. So, okay. So RSA. Okay. We will dive into RSA and RSA is more complicated. Okay. So compared to Diffie-Hellman. So, but we talked about prime numbers, right? We talked about two prime numbers multiplying them together. So we are getting an N here. And those prime numbers, think about them as like large prime numbers. So we cannot, finding N is easy. But going back to P and Q, if you don't know that, it's hard. Okay. And for any A and an E, just don't get confused. Like just look at the equation. So basically N is greater than A and E is greater than one and everything is given to us. So finding like, we know A, we know E, we know N. So we can find C easy. This is just an equation, right? We are just fine. We are doing the mod and we are doing to the power like we are rising it. But if you are giving C, E and N, it is hard to calculate A from there. This is mathematically, like it's hard to calculate. Then after that, there are like several steps. So like this is how it's done. I say I won't go into detail. So like N is found by P minus one multiplied by Q minus one. Then we are finding, we are choosing an E such as such that is M is greater than E. And we are finding a D, E to the power of minus one mod M. So why are we finding these numbers anyway? Because we need, what do we need for public key? Cryptography. We needed two things. What were they? Exactly. So we are going to use these numbers. Some of them for private keys. Some of them is for public key. So we are trying to generate those. So generation was easy, you remember? So like we are just generating them and we are going to use them. So like, and this is like easy to do. And like at the end, this is our public key. N and D. We knew N, that's the multiplication of prime numbers. And we know D, right? We just computed it. Then after that, we are generating our secret key which is N and E. So basically P, public key is known to everyone. So everybody knows that D over there. But they cannot derive, we just like talked about it. They cannot derive E from there. That's the whole point. So let's think about it. So Alice sends a message M to Bob, right? Okay. So Alice sends a message M to Bob. They must have the public key, correct? Right. Okay. Like everybody needs to know the public key. Then we are turning M into an integer M. And this is less than, like the number is less than N. So what does this tell us here? What is the, let's say limitation here about the message itself. Yes. So the integer that we are using to wrap it up, the message has to be smaller than... Yeah. Okay. Yeah. So what does this tell us? So what happens then? If N is small? If N is small, then the message has to also be small. Exactly. So you need to have an N that is very large to send a very large message. So this is like the problem of RSA. It's the main problem. And like this is how it's done. So like Alice is doing the M, D, so the public key, right? She's creating the ciphertext. She's passing it. Bob is using the private key. We can decrypt it. And Eve has C and public keys. She cannot see anything. Right? Yeah. So properties. We talked about send numbers less than N. Right? So how do we turn this to a cryptosystem if that's the case? How would that work? Yeah. So what about applying encryption to each letter? Yeah. I mean, it's expensive, right? The calculation. What else? Like what is the problem with encrypted? If we did it. If we did encrypt each letter. No. You are doing each letter with the same one, right? The same RSA. Same. Like it's like, do you remember like ECB? It's like that. The symmetric one encryption. So blocks will be encrypted with the same RSA keys. Same RSA. What is it? Same word. Yes. So and what if an attacker changes the location of the letters? Can we stop that? No. So basically we have the same limitation that we had with ECB. Similar limitation. So this won't work. Each letter won't work. Just like you said, we can use RSA to encrypt the key of AES. So like of the symmetric encryption that we did. So we are using AES to encrypt our message with the key. Then we are passing the key with the RSA. So it will be small, right? It will be short. So we are removing that limitation from there. So it becomes a crypto system, right? Okay. So any questions up to now? So I am so clear. Okay. That's good. I will talk about message integrity like very fast, but I will not go into detail. Okay. So message integrity. So we talked about, okay, let's continue first. I will go back if I have time. Okay. Let's talk about public key crypto system weaknesses now. So, okay. Again, what do we use for public key crypto systems? Two things. Again. Anyone? Exactly. So what is the problem there? What can be the problem here? What are some weaknesses, yes? If the key space is a margin. Yeah, that can happen. Let's assume that you cannot drive it from there. Because that's our main assumption, right? It should be hard to derive that from public key. Yeah. Okay. So let's have a box here, right? We have a box. And what's your name? Soham. Soham. Soham. Okay. You are coming here. You are bringing something, right? So like you are putting your public key, right? So, and what's your name? Moment. So you are coming and you are seeing that key. How do you know that it's his key? Can you trust that key? No. So nobody knows who put that there. Nobody acknowledges it. So someone needs to be there to verify that, right? So, and what can happen here? So what can happen like if you don't know? So like for example, if Eve comes there, if someone comes there and changes that key, what happens? What can happen at the end with the encryption? The person with the brand key. Yes. What about non-repudiation? Okay, but Eve replaced those keys. So Alice came, she found your key, right? But you replaced it. And she took that key and encrypt that message, send it to Bob. What happens then? Yeah. So, but let's think about Eve is in the middle of the transmission. She took it, right? And she decrypted it. Exactly. And she can temper it with the message. She can change it, right? She can send it and Bob will think that it's coming from Alice. So everything is broken here. Just like this. So Alice mistakenly like, she didn't know. She encrypted the public key of Eve's. Then she created the ciphertext. And Eve took that, decrypted it, encrypted it with her, with Bob's public key, then sent it to Bob. But the message was different. Okay. And also like, okay, let's continue. So how do we, how should, how will we trust public keys? How are we going to do it? What are some ways that we are thinking like, yeah, yeah. That can work. Like an authority, right? Okay. So when you apply, like when you register for a site like Amazon or Spotify or something, like how do they know that you're a student? Yes. But who gave that email to you? You're right. So like there is a centralized authority that gives you that ID, right? Or think about the box, right? I was here, right? And Alice came, put the key inside. I saw it. Then Bob came. He will take that. So how can he be sure that is Alice's key? I'm there. I'm watching everything. Yes, I did. So I am, I can verify that it is coming from Alice. I can't say it. So delegation or centralization. We talked about, we just talked about this. So and there are like several, like there are public key infrastructures. We will talk about those soon. And there's another one, decentralization. So we talked about centralization and there's another one, decentralization. So this is called Web of Trust. So when I buy something like from Amazon, I'm reading reviews, right? Or when I like want to watch something, I'm reading reviews. We don't know like if they are like so trustable, but I choose to trust them, right? So let's think about, again, in terms of Alice and Bob, right? Alice, Bob and Eve, okay? Alice trusts Eve. She won't trust. Okay. She will trust me. Okay. If Alice trusts me, okay? And so Bob will ask me if I trust Alice, then he will have the same trust as me to Alice. Yeah? Did you guys get this? No. Okay. So I'm talking to Bob, okay? And I trust Alice. And I trust Alice like, I trust the people who Alice trusts too, right? This is like a Web of Trust. We can think of it. Then Bob comes to me. Bob asks like, oh, do you trust Alice? And I'm saying, yeah, I do. So basically he will have the same trust that I have for Alice. So but, yeah, kind of, yeah, but that's an organization. So I don't know, like, I mean, it can be, it can be, but it can be centralized too. I'm not sure. Yeah, because it's a centralized organization. So like, they are telling us, but we are, yes, we are like trusting them in a way. They can. They can. But it's like just pure trust, yeah? People faith. So it's like that. It's Web of Trust. Yeah. Yes. So if you, if, yeah, so if I trust Alice and if I tell, yeah, you can trust Alice, then Bob trusts everyone that Alice trusts. Right? It's like going like this. Web. So let's talk about PPKIs. Let's get the time. Yeah, we are doing fine. Okay. So we talked about authorities, right? You said authorities. Like these authorities are verifying identities, right? So how does this work? What do you think? Yeah. Yes. But so how do they do that exactly? Do you know? Yeah. No, like the encryption itself. No. Yeah. Yes. Yeah. So what they can do is that they can encrypt the public key. So Alice is applying for a certificate authority. She's saying that, okay, just verify my public key. Certificate authority takes that public key of Alice's, encrypts it with their private key. So everybody knows their public key, right? Certificate authority. And they will take that public key. Bob will take that public key from the box. And he will be able to decrypt it with the certificate authority's public key. So what that means? So certificate authority did that. Like he will understand that, okay, I can trust this public key now. Yes? So. And also like, but there's a problem here. So there are like billions of people in the world. And billions of like maybe, I mean, public keys. There are a lot of public keys. So one certificate authority cannot do this by itself, right? So what can they do? And also like think about politics. So if there's one certificate authority in the world, countries, they won't accept this, right? They will want their own CAs. So what will happen here? What they can do. Yeah. I mean, and there can be like delegated trusted CAs. And this can be like, it can go deep and deep. So like one CA is encrypting the encrypting with the, their secret key. The other one, secret key, secret key, secret. It goes like this. And they can, the one that receives, they can decrypt this with public keys. And they can see like all trusted CAs there. So that they will trust that public key. So this is how they sold it. But there's another problem here. So that they're like their security goals, they shouldn't, certificates. But there's the problem of revocation here. So like, for example, if Alice forgot about it, like the key, or like she lost it, or it was stolen, what would happen? So it'd be like a trash of public keys everywhere, right? So they need to have a way to keep a list of it. And this is a problem because, but they have ways to do this. So they are just like keeping probably like, they are just keeping them somewhere, and they have maybe expiration times. So it's just expires automatically sometime after. So nobody needs to contact them and say, okay, like my certificate, I want to rebook it. And they will say, oh, it's expired already. Something like that. You know, they have ways to do this. Okay. So let's talk about modern web now. Any questions up till now? Am I going so fast? A little? Okay. So what is HTTPS? Anybody know? Okay. What does it provide? Yeah. I mean, what does it provide regarding the transmission? So wait, I couldn't hear you. So you said the encryptions cannot be seen by anyone? Yeah. The transmission can be seen by anyone. Yeah. So it's basically HTTPS secure. Okay. I believe so. And, but it uses PKI. So we talked about transmission being encrypted and nobody can see that. But there's another one. So it can tell you the domain name, like type to someone. So those like verifiers. So PKI is used there. So, and there are root CAs. Okay. This is like burned into operating systems or browsers, like all like softwares. I mean, some softwares, I don't know, but it is burned into them. So they have a way to use those CAs to verify if the identity is correct. Right. So there are different types of certificates, validation levels. So these are levels. First one is domain-validated DV certificate. Okay. So DV certificate is proving that you own that domain. That's it. There is nothing to it. You own that domain name. Okay. And it goes like organization validation and after that extended validation. So I will go to extended validation. So extended validation is telling that you are the legal entity and that domain name is tied to that legal entity. Okay. It's just an extended validation on top of domain and organization. Okay. And which you will see now soon. So these are like, we are talking about these because they are visual indicators online. Okay. On browsers, like you will see those visual indicators. So let's look at it. So this is DV, right? So this is telling that that lock on the left, it tells that the main name is like owned by Adam, Dr. Dupin. Okay. And you see now we are seeing a EV. Okay. This is extended validation. So it also tells the organization name and the legal entity on left of it. This is how it looks like. The first one is EV, the other one is EV. And this is changed for every browser. So I believe this is Safari. This is Firefox. And this is Chrome. I believe so. These are the visual indicators or those validations. And so Web of Trust, we talked about it. We briefly talked about it. Actually, we finished talking about it. But again, we should talk about it. So we are the difference between that centralization. We talked about certificate authority. But now we are talking about Web of Trust. So we are giving the end users to decide who to trust, how to trust and how to trust. Okay. And also they can build a graph by trusting someone that they trust. We talked about that. So if Alice trusts someone, and if I trust Alice, I will trust who Alice trusts. It goes like this and this and this can be like a large huge graph, like huge graph of trust. Okay. Yeah. So I will briefly touch on the hash functions. I will jump there now. But I will not go into detail. Okay. I will just tell you what hash function is. Actually, I have slides, but let's go. So we will talk about message integrity. So we talked about the weaknesses of public key cryptography. So there's another weakness that is message integrity. So how do we know if someone tampered with the message? We don't have a way normally. So they came up with hash functions. So hash functions are functions that takes arbitrary size input, any size of input, and they are changing with a fixed size string. Okay. Fixed size string. So it's like a very compact version of it. But there are two things to say about this. So these, so if you have different size of inputs, okay, they will have different hashes. The resulting hash should be different, right? If they are the same, then this won't work. The hash function won't work. So like, because we are talking about tampering, right? So if the attacker tempers one bit, the hash should be different in order to have that tampering like protection, right? Another thing is if, so it should not be reversible. It is not reversible. So unlike encryption and decryption, what did we do? Encryption and decryption. Yeah. Yes. So we could, we could got like, so from the plain text, we got the cyber text. And from the cyber text, we could get the plain text, right? But hash functions, this is not the case. It just creates a string. That's it. And this is used by how can this be used? So that's fixed size string. How can the other side can understand like, based on what I said? So how can Bob understand that it's not tampered with? Yes. Yes. Exactly. So like, but Alice sends what? To the other side. To Bob. The message and the hash of the message, right? So then Bob can take it. If the message is tampered with, we are assuming that a good hash function will have a different size, a different string at the end. So that means the message is tampered with. But if he finds the same exact hash, then that means the message was not tampered with. There are many applications to this. I won't go into detail. Maybe we will go into detail later on. But yeah, this is all for today. Thank you for listening. Thanks.