TLS Handshake

The handshake that authenticates the server and derives symmetric session keys.

At a Glance

TLS 1.3 Handshake (Sequence)

One round trip. The client sends its key_share with ClientHello so the server can derive keys and start encrypting in its very first response.

sequenceDiagram participant C as Client participant S as Server C->>S: ClientHello + key_share + SNI/ALPN + versions + cipher_suites S->>C: ServerHello + key_share + chosen cipher_suite Note over C,S: handshake keys derived S-->>C: [enc] EncryptedExtensions S-->>C: [enc] Certificate S-->>C: [enc] CertificateVerify (signature over transcript) S-->>C: [enc] Finished (MAC over transcript) C-->>S: [enc] Finished Note over C,S: application data (AEAD)

Dashed arrows are encrypted under the handshake keys.

ClientHello / ServerHello

The hellos carry almost everything interesting. Many legacy fields survive in TLS 1.3 only for backwards compatibility.

FieldIn ClientHelloIn ServerHello
legacy_versionAlways 0x0303 (TLS 1.2) for compatSame — real version in supported_versions
random32 random bytes32 random bytes (incl. downgrade sentinel)
cipher_suitesList of acceptable AEAD+hash pairsThe single selected suite
supported_versions extOffered TLS versionsChosen version (e.g. TLS 1.3)
key_share extOne or more (group, pubkey) pairsSingle matching (group, pubkey)
supported_groups extECDHE curves client will accept
signature_algorithms extWhat client can verify
server_name (SNI)Hostname client is asking for
ALPNProtocols client can speak (h2, http/1.1)The single chosen protocol
pre_shared_key extResumption ticket + bindersIndex of accepted PSK

Key Exchange (ECDHE)

Ephemeral ECDH on Curve25519 or a NIST P-curve. Both sides derive the same shared secret without it ever touching the wire.

sequenceDiagram participant C as Client participant S as Server Note over C: cx = random scalar
CX = cx · G Note over S: sx = random scalar
SX = sx · G C->>S: key_share CX S->>C: key_share SX Note over C: shared = cx · SX Note over S: shared = sx · CX Note over C,S: HKDF-Extract(shared) → handshake + application traffic secrets

Keys are ephemeral (both scalars are discarded after the connection closes), so forward secrecy is automatic: past sessions cannot be decrypted even if the server's signing key is later compromised.

Certificate Verification

The Certificate message carries the server's end-entity cert + any intermediates. The client must verify all of the following.

TLS 1.2 vs 1.3

TLS 1.2TLS 1.3
RTTs to first app byte21 (or 0 with PSK)
Key exchangeRSA, DHE, or ECDHEECDHE only (PSK too, for resumption)
Forward secrecyOptional (only with DHE/ECDHE)Mandatory
Cipher suiteBundles kx + auth + cipher + MAC (e.g. TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256)Only AEAD + hash (e.g. TLS_AES_128_GCM_SHA256); kx and auth negotiated separately
Handshake encryptionPlaintext after ServerHelloEncrypted from EncryptedExtensions onward
Removed / bannedStatic RSA, CBC MAC-then-encrypt, SHA-1, compression, renegotiation, custom groups
0-RTTNot supportedSupported via early_data + PSK
Version negotiationIn legacy_versionIn supported_versions extension (legacy field frozen)

Session Resumption & 0-RTT

After a successful handshake, the server can issue a NewSessionTicket (an opaque blob, usually an encrypted PSK). Future connections can skip the full handshake.

sequenceDiagram participant C as Client participant S as Server C->>S: ClientHello + pre_shared_key (ticket, binders) + early_data + key_share C-->>S: [enc, PSK] 0-RTT application data S->>C: ServerHello + pre_shared_key (accepted) S-->>C: [enc] EncryptedExtensions + early_data ok S-->>C: [enc] Finished C-->>S: [enc] EndOfEarlyData C-->>S: [enc] Finished Note over C,S: 1-RTT application data

0-RTT replay risk. The network (or a middlebox) can capture the 0-RTT record and resend it. TLS 1.3 provides no per-record replay protection for early data, so 0-RTT payloads must be idempotent. In practice: safe for GET, unsafe for POST/PUT. Servers typically only accept 0-RTT for known-safe endpoints or enforce an anti-replay window.

Cipher Suite Format

TLS 1.2 bundles four things into one name; TLS 1.3 strips it down to the two things that actually vary per-record.

TLS 1.2:
  TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
      └───┬───┘ └┬┘      └─────┬─────┘ └──┬──┘
   key exchange auth      AEAD cipher    PRF / HMAC hash

  = ephemeral ECDH for key exchange,
    RSA signatures for server auth,
    AES-128-GCM for symmetric encryption,
    SHA-256 as the HKDF hash.

TLS 1.3:
  TLS_AES_128_GCM_SHA256
      └─────┬─────┘ └──┬──┘
     AEAD cipher    HKDF hash

  Key exchange (ECDHE group) and server auth (signature alg)
  are now negotiated via separate extensions, not baked into
  the suite name.

References