Huron.
And welcome back.
In today's video, we will be discussing about the asymmetric key encryption.
Now, the asymmetric key cryptography makes use of public and private keys to encrypt and decrypt the
data.
So let's understand this in a simple way.
So what happens in asymmetric key encryption is that there are two keys which are involved, and these
two keys are in some way related with each other.
So what happens here is that whatever data that you encrypt with one key can only and only be decrypted
with the second key here.
And in a similar way, whatever data that you encrypt with, the second key can only be decrypted with
the first key.
So that's the basic concept of asymmetric key.
So here it is referred the two keys are referred as public key and private key.
So one key is public and second key is private.
Now, as the name suggests, the public key can be shared with everyone, so you can share it across
the Internet.
There is no issue there.
And the other key is kept as secret and you do not share it with anyone.
And it is called as the private key.
So as we discussed, either of the keys can be used to encrypt a message and the opposite key from the
one which is used to encrypt the message is used for decryption.
So let's understand this.
Let's say that you have a user.
Her name is Alice.
So Alice generates two key.
One is the public key and second is the private key.
So now once the keys are generated, she can go ahead and distribute the public key among the Internet.
And she can say that anyone who wants to send me a message, encrypt that message with my public key
and send that across.
So once that message is encrypted with the public key, we know that it can only be decrypted with the
private key which the Alice user has.
So what Bob does, Bob has a message called as Hello Alice.
He encrypts that message with the Alice's public key and you have the resultant encrypted message.
So now this resultant encrypted message is something that he can send across the Internet or across
a unsafe network.
So now what Alice will do?
Alice will get this encrypted message.
She will decrypt that message with the Alice's private key and read it.
So here she can read.
Hello, Alice.
So this is the role of public and private key.
So this can also be better explained with one more diagram where you have the sender.
Sender makes use of the public key to encrypt this plaintext document.
So this plaintext document and the public key encrypts the document and with the corresponding private
key, it's not like you cannot use any other private key.
You only have to use the private key, which is associated with this specific public key through which
it is encrypted.
So through the private key, you can go ahead and decrypt the message and receiver will have the proper
message here.
All right.
Now, in fact, let me quickly show you, because asymmetric key is used in a lot of applications.
So generally at Cape Labs, what I do is whatever sensitive data that I send across the Internet, which
includes email, all of that data is in the encrypted state.
So you can see that I have sent an email credentials to one of the person who recently joined Cape Labs.
So all of the messages, if you look into the message, this is completely encrypted mail.
So even if a attacker is able to read this mail, he will not be able to decrypt it because this message
is encrypted completely.
So how things work, let's say that I have to send a message to Alice.
So what I do, I tell Alice to send me her public key.
Once she sends me her public key, I encrypt the message with her public key.
And this is how the encrypted message looks like.
It is quite big.
And then I send it across towards her email.
Now she can make use of the private key and decrypt the credentials accordingly.
Now in between, if there is a attacker who is reading a mail or even let's say that there is a Google
employee who is reading the mail, he will not be able to find out because this is encrypted.
So even if there is someone who has access towards the email and he is able to read everything, still
he will only see this encrypted block.
He will not see the email credentials.
So let's.
Understand.
A second use case of asymmetric encryption.
So this is a typical use case when a user wants to log in to a Linux server.
So what happens here that you have a user, you have a server?
Now, the server basically contains the user's public key.
All right.
So for here you see, zeal has its own public key.
So all the public key of the user who might want to log in to the server is stored in the server.
So let's understand this step.
So user zeal wants to log in to the server.
Now, since the server uses public key authentication, so instead of taking the password from the user
server will verify if the user claiming to be zeal actually holds the private key.
So here the first request via SSH is I am zeal.
I want to log in.
So server receives that message.
Server says prove by solving this.
All right, so this is encrypted over here if you see.
So this becomes the step two.
So what happens in step two, The server creates a simple challenge.
Let's say two plus three is equal to question mark.
And this simple challenge, it will encrypt it with the public key of the user and send it back to the
user.
All right.
Now, this is in a encrypted format and it is encrypted by the public key associated with the zeal user.
So only the person who holds the Associated private key will be able to decrypt the message.
So if it is public key, then it is assumed that zeal will hold its private key.
Now, within the step three, since user zeal holds the associated private key, he will be able to
decrypt the message and the answer is computed, which would be five.
So here the challenge is two plus three is equal to question mark.
And this challenge was encrypted with the zeal public key and send it across.
Now zeal.
Since he holds the private key, he quickly decrypts the message and he computes the answer as five.
He encrypts that message, which is the answer as five with the private key and sends it back to the
server.
All right.
So in stage three, the answer is encrypted with the private key and it is sent back to the server.
Now, in the step four, the server basically decrypts the message with the public key and check if
the answer is correct.
Now, do remember that if the user or in our case, if zeal has encrypted the message with the private
key, it can only be decrypted with the corresponding public key and it cannot be decrypted with any
other public key.
All right.
So server receives the answer.
It decrypts the answer with the zeal.
Public key.
So since the message is decrypted, the server can know that it was encrypted with the corresponding
private key which user zeal hold.
And this is one of the ways in which it knows that an individual who wanted to log in has the correct
associated private key, and it also looks into the challenge and then sends the authentication successful
message.
So this is one of the approaches for asymmetric key encryption.
So let me quickly show you this.
So here, whenever I am logging in through SSH, you will see with the hyphen I am specifying the private
key here.
All right.
So when I press enter here, this is just an additional password to the private key.
It automatically logged me in.
Now, if you basically look into the authorized keys here, it basically contains the public key.
So if you look into the diagram, the server hold the public key here.
All right.
So this public key was used to compute the appropriate challenge.
Depending upon the protocol that you are using, you can quickly generate a public private key pair.
So if you just do a ssh key gen.
All right.
So now it automatically generated a public key and the private key.
So if you see your public key has been saved here and your identification, which is your private key,
has been saved.
So if you go to the SSH directory, you will see that one is public key.
So this is public key and second is private key.
So if you just want to see how public key looks like this is how the public key looks like, and if
you want to see how private key looks like, this is how the private key looks like.
So this is a big key, which is difficult to remember.
So this is.
One of the ways of asymmetric key encryption, and this is the recommended approach.
So generally whenever you go in organizations and enterprises and if you want to log in to the server,
they'll generally ask you, okay, generate a public private key pair and send us the public key and
the system administrator will go ahead and put your public key within the server and through the private
key you will be able to log in.
And this is similar where I had sent an email with encrypted with the public key of the user and this
mail is being received by the user, so he'll be able to decrypt it with the corresponding private key.
Now, because of the advantages that it offers, asymmetric key encryption is used by a variety of protocols.
So some of these protocols are BGP, you have, you have Bitcoin, you even have TLS.
So the SSL websites that you might see with Green Bar TLS also extensively makes use of the asymmetric
encryption.
You also have Smime, which uses this.
So these are some of the protocols which extensively uses asymmetric key encryption.
Again, this is just a small list.
There are a lot of others as well.
So that's the high level overview.
I hope you understood asymmetric key encryption at a glance, and I hope this video has been informative
for you and I look forward to see you in the next video.