TLS/ SSL HandShake
✅ TLS/SSL
SSL
Secure Socket Layer
- provide network transport security
- prevent eveasdropping, forgery of transport data of server-client
- encrypt data over client-server
TLS
Transport Layer Security
Handshake
Before client and server communicates in HTTTS, checks SSL for security
✅ TLS/SSL Handshake
- SSL is created of three phases.
SSL handshake-Session-Terminate Session - HTTPS operates on SSL
1️⃣ SSL handshake(1~8)
- First, server and client decides which
algorithmto use - When
algorithmis decided, createsymmetric keyand share
1. Client Hello
Client sends client hello message to server
client hello message holds such as client random data, version, encryption algorithm
if server and client has had SSL handshake, send session key to reuse the session
random data: random daraversionencryption algorithm: what kind of encryption algorithm the client can use
2. Server Hello
Server recieves client hello, replies with server hello
Server decides which encryption algorithm to use from the list of algorithms that the client sent
server hello message includes server random data, session ID, CA public key certificate
server random dataCA public key certificateholds public key
3. Client verify, create pre master secret(symmetric key)
Client checks if CA public key certificate is valid
Then create pre master secret, also called random key byte
- To check if
CA public key certificatedigital signatureis valid, usepublic keyfromCA - the certificate has Digital signature by
CA - If verified, the client will trust the server
- If
CA public key certificateis valid, client createsrandom key bytealso calledpre master secret - Client creates
symmetric key, calledpre master secret, combiningclient random dataandserver random data - This
pre master secretwill be used assymmetric keyfor encryption in client-server communication - This
random key byteis used for symmetric key
4. Encrpyt pre master secret with server's public key
- Then, send to server
- ⭐️ Assymetric key used
5. If in step 2, server required client certificate, send client cerfiticate
6. Server checks random key byte, decrypts random key byte(pre master secret) with server private key.
- Server checks client certificate
- ⭐️ Assymetric key used
7. Create master secret and session key
- Client sends
finishedmessage saying handshake is complete. - Now, server and client will create
master secretfrompre master secret - And use
master secretto createsession key - Hash the transmission messages then encrypts with
symmetric keyand sends to server.
8-1. Server also hashes transmission messages and checks if they match.
- If matches, server also sends
finishedmessage(encrypted withsymmetric key).
8-2.Client decrypts message and checks the server is safe, now two parties will share data with symmetric key.
2️⃣ Session(9)
- Server and Client exchange messages
- messages are encrypted with
session keywhich is a symmetric key - decryption is also possible with
session key
3️⃣ Terminate Session
- When transmission of data is over, server and client tells each other that the communication is over
- Then dispose
session key
💡 When is symmetric key used?
In level 3, using
pre-master-secretwhich is a symmetric key
During session, when server and client is exchanging messages withsession key
💡 When is asymmetric key used?
In level 4, to send
pre-master-secretto the server, encrypt the secret withserver's public key
In level 6, server will decryptpre-master-secretusing itsprivate key
💡 When is digital signature used?
In level 3, when client verifies the certification from server
the server certificate has digital signature by CA
💡 Why not only use public key?
- 👎🏻 public key uses a lot of computer power
- If lots of traffic occur on public key using server, the server will have high cost
💡 Why not only use symmetric key?
- In order to use
private key, the server and client needs to share theprivate key- Cannot share
private keywithout encryption ➡️ need to encrypt withpublic key
✅ Why use SSL/TLS over HTTP?
- HTTP exchanges message with plain text
- 👎🏻 easy to steal data
- HTTPS is a secure version of HTTP, which is HTTP on SSL/TLS
- every HTTP message that is sent on HTTPS is encrypted, decrypted by SSL/TLS