Networking & ProtocolsTLS/SSL & EncryptionEasy⏱️ ~3 min

TLS/SSL Fundamentals: Three Core Guarantees and Protocol Phases

Definition
TLS (Transport Layer Security) is the cryptographic protocol that secures communication over untrusted networks by providing three guarantees: confidentiality (encryption prevents eavesdropping), integrity (tampering is detected), and authenticity (parties verify each other identity). SSL (Secure Sockets Layer) is the historical predecessor; all modern implementations use TLS 1.2 or TLS 1.3.

Two Phase Protocol Structure

TLS operates in two distinct phases. The handshake phase establishes a secure connection: the client and server negotiate which cryptographic algorithms to use, the server proves its identity using a certificate, and both sides derive shared secret keys. Once the handshake completes, the record protocol phase begins, where all application data is encrypted using the negotiated symmetric cipher. The handshake uses computationally expensive asymmetric cryptography (operations involving key pairs), while the record protocol uses fast symmetric cryptography (operations using shared keys) for bulk data.

RTT (Round Trip Time, the time for a packet to travel to the server and back) directly determines handshake latency. TLS 1.2 requires 2 round trips after the TCP connection establishes, meaning 3 RTTs total before any application data flows. On a 200ms intercontinental path, this adds 600ms of latency before the first byte of content. TLS 1.3 reduces this to 1 RTT for TLS (2 RTTs total), saving 200ms on that same path.

Asymmetric and Symmetric Cryptography

The handshake combines two cryptographic operations. Key exchange algorithms like ECDHE (Elliptic Curve Diffie-Hellman Ephemeral) allow two parties to derive a shared secret over an insecure channel without ever transmitting the secret itself. The ephemeral part means new keys are generated for each connection, providing forward secrecy: if an attacker later compromises long term keys, they cannot decrypt past sessions. Common curves include X25519 (a modern curve optimized for performance and security) and P-256 (an older NIST standard with broader compatibility).

Once the handshake derives session keys, the record protocol encrypts data using symmetric ciphers. AES-GCM (Advanced Encryption Standard in Galois Counter Mode) provides both encryption and authentication in a single operation, achieving 2 to 5 Gbps per core on CPUs with hardware acceleration. ChaCha20-Poly1305 is an alternative designed for software implementation, often 2 to 3x faster than AES-GCM on devices lacking dedicated AES hardware (most mobile processors).

Certificate Based Authentication

Servers prove identity using certificates signed by Certificate Authorities (CAs), trusted third parties whose root certificates ship with browsers and operating systems. When a server presents its certificate, the client verifies the signature chain back to a trusted root. Modern certificates use 90 day lifetimes (versus the 398 day browser maximum) to limit exposure if private keys are compromised. Short lifetimes require automated renewal, typically using ACME (Automated Certificate Management Environment), a protocol that proves domain ownership and issues certificates without manual intervention.

💡 Key Takeaways
TLS provides confidentiality (encryption), integrity (tamper detection), and authenticity (identity verification) for communication over untrusted networks
TLS 1.2 requires 3 RTTs total (1 TCP + 2 TLS) before application data; TLS 1.3 reduces to 2 RTTs, saving 200ms on intercontinental paths with 200ms RTT
ECDHE (Elliptic Curve Diffie-Hellman Ephemeral) generates new keys per connection, providing forward secrecy so past sessions remain secure if keys later leak
AES-GCM achieves 2 to 5 Gbps per core with hardware acceleration; ChaCha20-Poly1305 is 2 to 3x faster on mobile devices without AES hardware
Certificates signed by trusted Certificate Authorities prove server identity; 90 day lifetimes limit compromise exposure versus 398 day maximum
Handshake uses expensive asymmetric cryptography (key pairs); record protocol uses fast symmetric cryptography (shared keys) for bulk data encryption
📌 Interview Tips
1Explain TLS as two phases: handshake (expensive, establishes trust and keys) and record protocol (fast, encrypts application data)
2Discuss forward secrecy: ephemeral keys mean compromising today server key cannot decrypt yesterday recorded traffic
3Mention the latency trade off: TLS 1.3 saves one round trip, which matters significantly on high latency mobile networks
← Back to TLS/SSL & Encryption Overview