Encryption, TLS, and Secrets Management

Encryption Types

TypePurposeExamples
In transitProtect data on the networkTLS/HTTPS, mTLS between services
At restProtect stored dataAES-256 disk encryption, encrypted DB columns
End-to-endOnly sender/receiver can readSignal protocol, WhatsApp

TLS (Transport Layer Security)

// TLS handshake (simplified):
1. Client → Server: "Hello, I support TLS 1.3, these ciphers"
2. Server → Client: certificate (proves identity) + chosen cipher
3. Key exchange (Diffie-Hellman): both derive shared secret
4. All subsequent data encrypted with shared secret
// Adds ~1 RTT to connection setup (TLS 1.3)

mTLS (Mutual TLS)

Both client AND server present certificates. Used for service-to-service auth in microservices (Istio does this automatically).

Secrets Management

Key Takeaways