TLS Cryptography and Handshake Overview

Understanding the Foundations of Secure Communication

Networking
Security
A deep dive into the cryptographic principles and handshake mechanisms that underpin TLS, the protocol that secures our online interactions.
Author

Shane Oh

Published

December 17, 2025

Introduction

Transport Layer Security (TLS) is the backbone of secure communication on the internet. It ensures that data transmitted between clients and servers remains confidential and authenticated.

  • Types of Ciphers
    • Symmetric Key Cryptography
    • Asymmetric Key Cryptography
    • Hash Functions
  • TLS Overview
    • TLS 1.2
    • TLS 1.3

Types of Ciphers

Symmetric Key Cryptography

Cipher Usage
AES Modern standard, widely used in TLS (AES-GCM, AES-CBC)
ChaCha20 Fast in software, used in TLS as ChaCha20-Poly1305
DES Insecure, banned in modern TLS
3DES Legacy, slow and small block size; being phased out in TLS
RC4 Severe weaknesses, banned in TLS
Blowfish Legacy, 64-bit block size limits suitability for TLS
Twofish AES finalist, used in some systems

Asymmetric Key Cryptography

Cipher Usage
RSA Widely used for key exchange and digital signatures in TLS (RSA key exchange, RSA signatures)
DSA Digital Signature Algorithm (signature-only; not used for encryption or key exchange). Legacy in TLS and not used in TLS 1.3.
ECDSA Used for digital signatures in TLS (ECDSA signatures)
Diffie-Hellman (DH) Used for secure key exchange in TLS (DHE)
Elliptic Curve Diffie-Hellman (ECDH) Used for secure key exchange in TLS (ECDHE)
Ed25519 Modern signature scheme, not widely used in TLS yet

Hash Functions

Hash Function Usage
SHA-256 Widely used in TLS for message authentication and digital signatures
SHA-384 Used in TLS for stronger security (e.g., in ECDSA signatures)
SHA-1 Insecure, banned in modern TLS
MD5 Insecure, banned in modern TLS

TLS Overview

HTTPS is the secure version of HTTP, and it relies on TLS to encrypt the communication between the client and the server. The TLS handshake is the process that establishes a secure connection by negotiating cryptographic parameters and exchanging keys.

HTTPS connection consists of two phases:

  1. TCP three-way handshake: SYN, SYN-ACK, ACK to establish a TCP connection.
  2. TLS handshake: The client and server negotiate cipher suites, verify the server’s certificate, and derive a shared session key.

After this process, the client and server can securely transmit data using the established TLS connection.

TLS 1.2

TLS 1.2 requires 2 round trips (2-RTT) for the handshake. The server sends its certificate and the client encrypts a pre-master secret with the server’s public key (RSA key exchange), or they use ECDHE for forward secrecy.

sequenceDiagram
    participant Client
    participant Server

    Note over Client,Server: TCP three-way Handshake
    Client->>Server: SYN
    Server->>Client: SYN-ACK
    Client->>Server: ACK

    Note over Client,Server: TLS 1.2 Handshake (2-RTT)
    Client->>Server: ClientHello (TLS version, cipher suites, client random)
    Server->>Client: ServerHello (chosen cipher suite, server random)
    Server->>Client: Certificate (server cert chain, signed by CA)
    Server->>Client: ServerHelloDone

    Note over Client: Verify certificate chain
    Note over Client: Generate pre-master secret
    Note over Client,Server: Key Exchange
    Client->>Server: ClientKeyExchange (pre-master secret, encrypted with server pubkey)
    Client->>Server: ChangeCipherSpec
    Client->>Server: Finished (HMAC of handshake)

    Note over Server: Derive session key
    Server->>Client: ChangeCipherSpec
    Server->>Client: Finished (HMAC of handshake)

    Note over Client,Server: Encrypted Communication
    Client->>Server: Application Data
    Server->>Client: Application Data

TLS 1.3

TLS 1.3 reduces the handshake to 1 round trip (1-RTT) by embedding the key share in the ClientHello. It removes weak algorithms (RSA key exchange, MD5, SHA-1, CBC mode) and mandates forward secrecy via ECDHE.

sequenceDiagram
    participant Client
    participant Server

    Note over Client,Server: TCP three-way Handshake
    Client->>Server: SYN
    Server->>Client: SYN-ACK
    Client->>Server: ACK

    Note over Client,Server: TLS 1.3 Handshake (1-RTT)
    Client->>Server: ClientHello (TLS 1.3, cipher suites, ECDHE key share, client random)

    Note over Server: Select cipher suite
    Note over Server: Generate ECDHE key share
    Note over Server: Derive handshake keys
    Server->>Client: ServerHello (chosen cipher suite, ECDHE key share)
    Server->>Client: EncryptedExtensions
    Server->>Client: Certificate (server cert chain, signed by CA)
    Server->>Client: CertificateVerify (signature over handshake)
    Server->>Client: Finished (HMAC)

    Note over Client: Verify certificate & signature
    Note over Client: Derive session keys
    Client->>Server: Finished (HMAC)

    Note over Client,Server: Encrypted Communication
    Client->>Server: Application Data
    Server->>Client: Application Data

Certificate Authorities (CAs)

Certificate Authorities (CAs) ensures that the owner of a domain is who they claim to be.

flowchart TD
    CA[Certificate Authority]
    S[Server / Domain Owner]
    C[Client]

    S -->|"① CSR (Certificate Signing Request; Server pubkey + Domain)"| CA
    CA -->|"② Signed Certificate"| S
    S -->|"③ Signed Certificate"| C
    C -->|"④ Verify with Root CA certificate (local)"| C

  1. Server creates a public/private key pair and generates a Certificate Signing Request (CSR) containing the public key and domain information.
  2. The Certificate Authority (CA) verifies domain ownership (e.g., DNS challenge, HTTP challenge, or email validation) and signs the server’s public key and certificate metadata with the CA’s private key, creating an X.509 certificate.
  3. The server receives the signed certificate and presents it to clients during the TLS handshake.
  4. The client verifies the certificate locally by checking the signature using the CA’s public key contained in a trusted root certificate that is pre-installed in the client’s trust store.
NoteEncryption and Signatures

In asymmetric cryptography, encryption can be performed with both public and private keys, but the usage differs based on the context:

  • Encryption: public key is used to encrypt data -> private key is used to decrypt data
  • Signatures: private key is used to sign data -> public key is used to verify the signature
NoteHow does SSH work?

SSH uses asymmetric cryptography to authenticate clients using signatures.

  1. The client generates a public/private key pair and shares the public key with the server.
  2. The server stores the client’s public key in ~/.ssh/authorized_keys.
  3. When the client initiates an SSH connection, the server sends a challenge (a random string) to the client.
  4. The client signs the challenge using its private key (Digital Signature).
  5. The server verifies the signature using the client’s public key, confirming that the client possesses the corresponding private key.
  6. Once authenticated, the client and server establish a secure channel using symmetric encryption (e.g., AES) with a shared session key derived from the key exchange.