Computer Systems Edition Vol. I No. 20
The Developer's Post
Explaining Technology Through the Art of Storytelling
Weather: ECDHE key exchange negotiating symmetric AES-256 session over public fiber Exchange: TLS 1.3: 1-RTT handshake | TLS 1.2: 2-RTT legacy | Diffie-Hellman: S = g^(ab) mod p | Perfect Forward Secrecy Price: 10 Credits
By Shubham Kumar Section: Cryptography & Networks Branch Date: September 27, 2026

Computer Science: The Anatomy of TLS 1.3 vs TLS 1.2 Handshakes

Every millisecond of every day, billions of devices transmit credit card numbers, confidential passwords, and private messages across the open internet. The underlying physical medium—submarine fiber optic cables, cell towers, and public coffee shop Wi-Fi routers—is completely accessible to anyone with network sniffing hardware.

How can two strangers who have never met—your web browser in New Delhi and a web server in California—communicate with airtight secrecy across an untrusted wire without a third party eavesdropping?

The answer is Transport Layer Security (TLS), the cryptographic backbone powering HTTPS. In this edition, we explore how modern TLS 1.3 slashed latency in half compared to TLS 1.2, and how both protocols utilize the elegant mathematical machinery of Elliptic-Curve Diffie-Hellman Ephemeral (ECDHE) to defend your data against interception.

The Cryptographic Glossary

  • Symmetric Encryption (AES-GCM / ChaCha20): Uses the same secret key to encrypt and decrypt data. Blazing fast, but requires both parties to already possess the shared key.
  • Asymmetric Encryption (RSA / ECC): Uses a keypair (Public Key to encrypt, Private Key to decrypt). Solves key distribution, but is too computationally heavy for bulk data streaming.
  • Diffie-Hellman Key Exchange (ECDHE): A mathematical protocol allowing two parties to derive a shared secret over an insecure channel without transmitting the secret itself.
  • Perfect Forward Secrecy (PFS): A security guarantee ensuring that even if a server's long-term private key is compromised in the future, past encrypted sessions remain unbreakable.
  • Round-Trip Time (RTT): The duration required for a data packet to travel from client to server and back again. Reducing RTT is the holy grail of web performance.

1. The Diffie-Hellman Mathematical Miracle

Invented by Whitfield Diffie and Martin Hellman in 1976 (and modernized via Elliptic Curves), Diffie-Hellman solves the ancient Key Distribution Problem.

Imagine Alice (the browser) and Bob (the server) want to agree on a secret key without Eve (an eavesdropper) discovering it:

  1. Alice and Bob publicly agree on a generator base $g$ and a large prime modulus $p$. Eve sees both $g$ and $p$.
  2. Alice picks a random private secret number $a$. She computes her public key: \(A = g^a \pmod p\) Alice sends $A$ across the wire to Bob.
  3. Bob picks a random private secret number $b$. He computes his public key: \(B = g^b \pmod p\) Bob sends $B$ across the wire to Alice.
  4. Now, both parties compute the shared secret $S$:
    • Alice calculates: $S = B^a \pmod p = (g^b)^a = g^{ab} \pmod p$
    • Bob calculates: $S = A^b \pmod p = (g^a)^b = g^{ab} \pmod p$
\[\text{Alice and Bob now possess identical secret: } S = g^{ab} \pmod p\]

What about Eve? Eve intercepted $g, p, A = g^a$, and $B = g^b$. To compute $S$, she must deduce $a$ or $b$. But computing $a = \log_g(A) \pmod p$ is the Discrete Logarithm Problem—a computational challenge that would take the world’s most powerful supercomputers billions of years to crack when $p$ is sufficiently large!

 Alice (Browser)                     Insecure Wire                      Bob (Server)
 [Secret: a]                       [Public: g, p]                     [Secret: b]
      |                                   |                                |
      |-------- Send Public A (g^a) ----->|------------------------------->|
      |<------- Send Public B (g^b) ------|<-------------------------------|
      |                                   |                                |
  Compute:                            Eve sees:                        Compute:
  S = B^a = g^(ab)                   (g, p, A, B)                      S = A^b = g^(ab)
  [Shared Secret S]                 [Cannot find S!]                   [Shared Secret S]

2. The Evolution: TLS 1.2 vs TLS 1.3

Prior to 2018, the internet ran on TLS 1.2 (defined in RFC 5246). TLS 1.2 was robust, but it suffered from two key drawbacks: high connection latency (2 full round trips before sending application data) and backwards-compatible support for obsolete, dangerous ciphers (such as static RSA key exchange and RC4).

In 2018, the IETF ratified TLS 1.3 (RFC 8446). It fundamentally revamped the handshake architecture:

Feature / Metric Legacy TLS 1.2 Modern TLS 1.3
Handshake Latency 2-RTT (2 full round trips) 1-RTT (50% faster, 0-RTT resumption)
Key Exchange RSA, DHE, ECDHE ECDHE only (Mandates Forward Secrecy)
Key Share Timing Negotiated in 2nd flight (ClientKeyExchange) Speculatively sent in 1st flight (ClientHello)
Handshake Encryption Plaintext until ChangeCipherSpec Encrypted immediately after ServerHello
Outlawed Ciphers Supported RC4, MD5, SHA-1, CBC mode, static RSA Removed all legacy ciphers; only AEAD allowed
Allowed AEAD Ciphers AES-CBC, AES-GCM AES-128-GCM, AES-256-GCM, ChaCha20-Poly1305
       TLS 1.2 Handshake (2-RTT)                         TLS 1.3 Handshake (1-RTT)
   Client                      Server               Client                      Server
     |                            |                   |                            |
     |--------- ClientHello ----->|                   |-- ClientHello + KeyShare ->|
     |                            |                   |   (e.g., Curve25519 g^a)   |
     |<-------- ServerHello ------|                   |<-- ServerHello + KeyShare -|
     |<-------- Certificate ------|                   |    (g^b) + EncryptedExts   |
     |<---- ServerKeyExchange ----|                   |    + Cert + Finished       |
     |<----- ServerHelloDone -----|                   |                            |
     |                            |                   |=== HTTP App Data (GET) ===>|
     |---- ClientKeyExchange ---->|                   |<== HTTP App Data (Resp) ===|
     |---- [ChangeCipherSpec] --->|
     |--------- Finished -------->|
     |                            |
     |<--- [ChangeCipherSpec] ----|
     |<-------- Finished ---------|
     |                            |
     |=== HTTP App Data (GET) ===>|
     |<== HTTP App Data (Resp) ===|

Notice the crucial difference: in TLS 1.3, the client speculatively assumes the server supports popular elliptic curves (like Curve25519 or secp256r1) and bundles its key share $g^a$ directly inside the ClientHello. The server answers with its key share $g^b$, immediately derives the symmetric key, and encrypts its certificate and Finished message in the very same response packet!


Interactive TLS 1.3 vs TLS 1.2 Protocol Simulator

Toggle between TLS 1.3 (1-RTT) and TLS 1.2 (2-RTT). Watch real-time packet byte streams, RTT progression, fiber-optic photons, and verify how eavesdropper Eve is thwarted.

Step: 0: Idle
Wire Packet Record Inspection: TLS_AES_256_GCM_SHA384
Click "Next Step" to begin handshake negotiation.
RECORD: Type=0x16 (Handshake) | Ver=0x0303 (TLS 1.2 compat) | Length=0x0000 | Payload=[None]
Latency: 0.0 RTT
Client Priv (a): 0x7F2A
Server Priv (b): 0x3E91
Derived Key (S): None
Eve Wiretap: Passive Sniffing

3. Why Perfect Forward Secrecy Matters

Imagine an intelligence agency or malicious actor recording petabytes of encrypted internet traffic passing through submarine fiber cables today.

Under the old static RSA key exchange (prevalent in early SSL and TLS versions), if the private RSA key of a bank or government server were stolen, compromised, or subpoenaed five years later, the attacker could retroactively decrypt every single past historical session ever recorded from that server!

With ECDHE (Ephemeral Diffie-Hellman):

  1. The private keys $a$ and $b$ are generated purely in RAM for that single connection.
  2. Once the symmetric session key is derived, $a$ and $b$ are erased from memory with zeroing instructions.
  3. Even if the server hardware is physically confiscated by an adversary in the future, past communications remain mathematically impervious to decryption.

This is why TLS 1.3 completely eradicated static RSA key exchange, mandating ephemeral Diffie-Hellman by law of the protocol.

Shubham Kumar
❖ ❖ ❖