TLS and digital certificates rely on cryptography. This article explains encryption, signatures, and key exchange and how they work together to protect network communication.
1. Fundamentals
1. Encryption and decryption
Encryption: transforms readable plaintext into ciphertext.
Decryption: recovers plaintext from ciphertext using the appropriate key.
Key: a cryptographic parameter used by the encryption, decryption, or signature algorithm.
2. Symmetric and asymmetric cryptography
Two broad approaches are used:
Symmetric encryption:
- Uses a shared secret key for encryption and decryption
- Efficient for large volumes of data
- Requires secure key establishment
Asymmetric cryptography:
- Uses a related public/private key pair
- More computationally expensive, but supports authentication and secure key establishment
- Also called public-key cryptography
2. Symmetric encryption
1. How it works
The same shared key is used to encrypt and decrypt:
Plaintext + key → [Encryption] → Ciphertext
Ciphertext + key → [Decryption] → Plaintext
Example:
- The sender encrypts message M with key K to produce ciphertext C
- The receiver uses K to recover M from C
2. Common algorithms
AES(Advanced Encryption Standard):
- A widely deployed symmetric block cipher
- Supports 128-, 192-, and 256-bit keys
- Standardized and efficient
ChaCha20:
- A stream cipher designed by Daniel J. Bernstein
- Efficient in software, including on many mobile devices
- Used with Poly1305 as a TLS 1.3 authenticated-encryption option
3DES(Triple DES):
- Older encryption algorithms
- Not appropriate for modern TLS configurations
3. Advantages and limitations
Advantages:
- ✅ Fast encryption and decryption
- ✅ Relatively low processing cost
- ✅ Suitable for bulk data
Limitations:
- ❌ Requires secure key distribution or establishment
- ❌ Key compromise exposes data protected by that key
- ❌ Shared keys must be established securely
4. Use in TLS
TLS uses symmetric authenticated encryption for application traffic:
- The handshake establishes shared traffic secrets
- Traffic keys are derived from those secrets
- Subsequent records are protected using the traffic keys
3. Public-key cryptography
1. How it works
Asymmetric cryptography uses a public/private key pair.
Key generation:
- Generate related keys using the selected algorithm
- Share the public key
- Keep the private key confidential
Public-key encryption, where supported:
Plaintext + recipient public key → [Encryption] → Ciphertext
Decryption:
Ciphertext + recipient private key → [Decryption] → Plaintext
Properties:
- Public-key encryption requires the matching private key to decrypt
- Signatures are created with a private key and verified with its public key; this is not simply “private-key encryption”
- Recovering the private key from the public key should be computationally infeasible
2. Common public-key algorithms
RSA(Rivest-Shamir-Adleman):
- A widely used public-key algorithm
- Its security is related to the difficulty of factoring large integers
- Common historical sizes include 1024, 2048, and 4096 bits
- Use at least 2048-bit RSA for the configurations described here
ECDSA(Elliptic Curve Digital Signature Algorithm):
- Based on elliptic-curve cryptography
- Shorter keys than RSA at comparable classical security levels
- Can reduce processing and bandwidth requirements
- A suitable 256-bit EC curve provides roughly the classical security level of 3072-bit RSA
ECDH(Elliptic Curve Diffie-Hellman):
- Used for key agreement
- Based on elliptic-curve cryptography
- Used with Poly1305 as a TLS 1.3 authenticated-encryption option
3. Advantages and limitations
Advantages:
- ✅ Supports secure key establishment
- ✅ Public keys can be distributed openly, but their authenticity must be verified
- ✅ Supports digital signatures with suitable algorithms
Limitations:
- ❌ More expensive than symmetric encryption
- ❌ Greater processing requirements
- ❌ Not generally used for bulk traffic encryption
4. Use in TLS
TLS uses public-key cryptography for:
Key establishment:
- Legacy RSA key transport encrypted a premaster secret with the server's public key
- The server decrypted it with its private key; modern TLS uses different key-agreement mechanisms
Identity validation:
- Sign data using the private key
- Clients verify signatures with the public key to authenticate the server
Certificates:
- The certificate contains the server's public key
- The CA signs the certificate with its private key
4. Digital signatures
1. Definition
A digital signature authenticates signed data and detects modification using a private/public key pair.
2. How signatures work
Signing:
Data + signing private key → [Signature algorithm] → Signature
Verification:
Data + signature + public key → [Verification algorithm] → Valid or invalid
Properties:
- The private key is required to generate valid signatures
- Anyone with the authentic public key can verify them
- Altering the signed data invalidates the signature
- Secure signature schemes resist forgery
3. Applications
Certificate signatures:
- The CA signs the certificate with its private key
- The client verifies the signature with the issuer's public key
- This detects changes to certificate contents
TLS handshake:
- The server signs handshake data using its private key
- The client verifies with the public key
- This demonstrates possession of the authenticated key
Code signing:
- A developer signs software with a private key
- Users verify the signature with the corresponding trusted public key
- This authenticates the publisher and detects modification
5. Key agreement
1. Diffie–Hellman
Diffie–Hellman (DH) lets two parties establish a shared secret over a public channel. Authentication is still required to prevent an active intermediary.
How it works:
- Agree on public group parameters
- Generate private values
- Exchange corresponding public values
- Combine the peer's public value with the local private value to derive the shared secret
Properties:
- An observer should not be able to derive the secret from the public exchange
- Security depends on the relevant discrete-logarithm assumptions
2. Elliptic-curve Diffie–Hellman (ECDH)
ECDH uses elliptic-curve groups and offers:
- Shorter keys at comparable security levels
- Efficient computation
- Lower resource requirements in many implementations
3. TLS key establishment
The following sequence illustrates legacy RSA key transport, not TLS 1.3 or ECDHE:
- Generate a premaster secret: the client creates a random secret
- Encrypt it: use the server's RSA public key
- Send it: transmit the encrypted premaster secret
- Decrypt it: the server uses its RSA private key
- Derive keys: both sides derive traffic keys from the secret and handshake values
- Protect traffic: use symmetric encryption for application data
6. Hybrid cryptography
1. Why combine approaches?
TLS combines public-key operations with symmetric traffic protection:
Public-key operations:
- Authenticate peers and establish shared secrets
- Address key-establishment requirements
- Are too expensive for routine bulk encryption
Symmetric encryption:
- Protects application traffic
- Efficient for large volumes of data
- Requires securely established keys
2. Workflow
Handshake:
- Exchange the required public-key and key-share information
- Establish shared traffic secrets
- Authenticate the peer with signatures and certificates
Data transfer:
- Derive and use traffic keys
- Protect records with symmetric authenticated encryption
- Transfer application data efficiently
3. Benefits
- ✅ Combines authentication with efficient encryption
- ✅ Supports secure key establishment
- ✅ Supports high-throughput data transfer
- ✅ Authenticates endpoints
7. Forward secrecy
1. Definition
Forward secrecy protects past session traffic from later compromise of the long-term certificate private key, assuming ephemeral secrets have been erased.
2. How it works
Legacy RSA key transport without forward secrecy:
- Encrypts the premaster secret with the server's RSA public key
- Later theft of the private key can expose recorded sessions
Forward-secret key agreement:
- Uses ephemeral key material
- Generates fresh key material for each handshake
- Compromise of the long-term signing key does not reveal those past shared secrets
3. Forward-secret methods
ECDHE(Elliptic Curve Diffie-Hellman Ephemeral):
- Generate ephemeral keys for each handshake
- Provide forward secrecy
- Used in certificate-authenticated TLS 1.3 handshakes
DHE(Diffie-Hellman Ephemeral):
- The ephemeral form of finite-field DH
- Provide forward secrecy
- Often more computationally expensive than ECDHE
4. Why it matters
- Protects recorded historical traffic
- Limits the consequences of later certificate-key compromise
- Is an important property of modern TLS configurations
8. Key sizes and security
1. Choosing sizes
Symmetric keys:
- AES-128: 128-bit key
- AES-256: 256-bit key, providing a larger security margin
RSA keys:
- 1024-bit: unsuitable for modern public TLS
- 2048-bit: the minimum used in this guide
- 4096-bit: a larger margin with additional processing cost
EC keys:
- 256-bit curves: roughly comparable to 3072-bit RSA at the classical security level
- 384-bit curves: roughly comparable to 7680-bit RSA at the classical security level
2. Operational considerations
- Larger keys within an algorithm family generally increase security margin and processing cost
- Balance security requirements and performance
- Review key sizes and algorithms periodically
- Follow cryptographic developments and update policy when needed
Conclusion
Symmetric encryption, public-key cryptography, digital signatures, and key agreement form the cryptographic foundation of TLS and digital certificates.
- Symmetric encryption: efficient traffic protection
- Public-key cryptography: authentication and key establishment
- Signatures: authenticity and integrity of signed data
- Hybrid design: combines complementary strengths
- Forward secrecy: limits exposure of past sessions
Understanding these roles helps you configure and maintain secure network communication.