Loading content...
In 2013, Edward Snowden revealed that the NSA was collecting data from major tech companies through a program called PRISM. One key takeaway for organizations worldwide: data that isn't encrypted can be read by anyone who gains access to it—whether through legal process, insider threat, or breach.
Encryption is the last line of defense. Even when all other security controls fail—when IAM is bypassed, when network perimeters are breached, when attackers gain access to storage systems—properly encrypted data remains protected. An encrypted database dump is just random bytes without the decryption keys.
Cloud providers offer sophisticated encryption services that make strong encryption accessible without requiring deep cryptographic expertise. Understanding these services—how they work, when to use them, and how to manage keys—is essential for building secure cloud architectures.
This page covers encryption at rest, encryption in transit, key management, and the architectural decisions that determine whether your encryption actually protects you.
By the end of this page, you will understand the difference between encryption at rest and in transit, cloud key management services (KMS) and their security models, envelope encryption and key hierarchies, customer-managed keys versus provider-managed keys, and encryption implementation patterns for different cloud services.
Before diving into cloud-specific services, we must establish fundamental concepts that underpin all encryption implementations.
Symmetric vs. Asymmetric Encryption:
Symmetric encryption uses the same key for encryption and decryption. It's fast and efficient for encrypting large amounts of data. AES-256 is the standard.
Asymmetric encryption uses a key pair: public key for encryption, private key for decryption. It's slower but solves the key distribution problem—you can share the public key openly. RSA and ECC are common algorithms.
In practice, both are used together: asymmetric encryption protects symmetric keys, and symmetric keys encrypt the actual data. This is called hybrid encryption or envelope encryption.
| Characteristic | Symmetric (AES) | Asymmetric (RSA/ECC) |
|---|---|---|
| Key usage | Same key encrypts and decrypts | Different keys for each operation |
| Speed | Fast (hardware-accelerated) | Slow (computationally intensive) |
| Key distribution | Challenge: both parties need key | Easy: public key is shareable |
| Typical use | Data encryption at rest/transit | Key exchange, digital signatures |
| Key sizes | 128, 192, or 256 bits | 2048, 3072, 4096 bits (RSA) |
Encryption at Rest vs. In Transit:
These terms describe the data's state when encryption is applied:
Encryption at Rest — Protecting stored data. When data is written to disk (EBS, S3, databases), it's encrypted before writing. When read, it's decrypted. This protects against:
Encryption in Transit — Protecting data as it moves. When data travels over a network (between services, between users and servers), it's encrypted during transmission. This protects against:
Both are essential. A common mistake is implementing one but not the other. Data encrypted at rest but sent unencrypted over the network can be captured in transit. Data encrypted in transit but stored unencrypted can be stolen from storage.
Encryption protects data from unauthorized access to storage or networks. It doesn't prevent authorized users from accessing data—anyone with decryption permissions can read encrypted data. Encryption supplements IAM, it doesn't replace it.
Key management is harder than encryption. Encryption algorithms are well-understood and implemented in standard libraries. The challenge is managing keys: generating them securely, storing them safely, controlling access to them, rotating them regularly, and ensuring they're available when needed.
Cloud providers offer Key Management Services (KMS) that handle this complexity:
AWS KMS — Managed service for creating and controlling encryption keys. Integrates with nearly all AWS services. Keys are stored in FIPS 140-2 validated hardware security modules (HSMs).
Azure Key Vault — Centralized cloud service for storing and managing secrets, keys, and certificates. Offers HSM-backed keys.
Google Cloud KMS — Key management service with HSM, software, and external key backing. Integrates with Google Cloud services.
Key Types and Hierarchy:
KMS implements a key hierarchy to balance security and usability:
┌─────────────────────────────────────────────────────────────────────────┐
│ KEY HIERARCHY │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────┐ │
│ │ Root Keys / Master Keys │ Level 0 │
│ │ (Never leave HSM in plaintext) │ (HSM-protected) │
│ └─────────────────────────┬───────────────┘ │
│ │ │
│ │ Encrypts │
│ ▼ │
│ ┌─────────────────────────────────────────┐ │
│ │ Customer Master Keys (CMKs) │ Level 1 │
│ │ (Your KMS keys, managed by AWS) │ (Customer-controlled) │
│ └─────────────────────────┬───────────────┘ │
│ │ │
│ │ Encrypts │
│ ▼ │
│ ┌─────────────────────────────────────────┐ │
│ │ Data Encryption Keys (DEKs) │ Level 2 │
│ │ (Generated per object/volume) │ (Envelope encryption) │
│ └─────────────────────────┬───────────────┘ │
│ │ │
│ │ Encrypts │
│ ▼ │
│ ┌─────────────────────────────────────────┐ │
│ │ Your Data │ Level 3 │
│ │ (Encrypted with DEK) │ (Protected) │
│ └─────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
Key Policy Example (AWS KMS):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Enable IAM policies",
"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::123456789012:root"},
"Action": "kms:*",
"Resource": "*"
},
{
"Sid": "Allow encryption by app role",
"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::123456789012:role/AppRole"},
"Action": ["kms:Encrypt", "kms:Decrypt", "kms:GenerateDataKey"],
"Resource": "*",
"Condition": {
"StringEquals": {"kms:ViaService": "s3.us-east-1.amazonaws.com"}
}
}
]
}
This policy allows encryption/decryption only when the request comes through S3—preventing direct key usage outside of the intended context.
Standard KMS keys are protected by HSMs but operations may involve software. For highest assurance, use dedicated HSM-backed keys (CloudHSM, Azure Dedicated HSM) or custom key stores where the HSMs are exclusively yours.
Envelope encryption is the fundamental pattern used by cloud services to encrypt data efficiently while maintaining strong key protection. Understanding this pattern is essential for cloud security architects.
Why Not Encrypt Everything with KMS Directly?
You could send all your data to KMS for encryption, but this has problems:
The Envelope Encryption Solution:
For decryption:
Visual Representation:
ENCRYPTION FLOW
┌─────────────────────────────────────────────────────────────────────────┐
│ │
│ 1. Generate DEK 2. Encrypt Data 3. Encrypt DEK │
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │
│ │ Random │ ──▷ │ Your Data │ │ KMS │ │
│ │ DEK │──────▷ │ + DEK │ │ ┌─────────┐ │ │
│ │ (256-bit) │ │ = Encrypted │ │ │ CMK │ │ │
│ └───────────────┘ │ Data │ │ └────┬────┘ │ │
│ │ └───────────────┘ │ │ │ │
│ │ │ ▼ │ │
│ └───────────── DEK ────────────────────▷│ Encrypted │ │
│ │ DEK │ │
│ └───────┬───────┘ │
│ │ │
│ 4. Store Together │ │
│ ┌────────────────────────────────────────────────────────────────┐ │
│ │ Storage (S3, EBS, etc.) │ │
│ │ ┌─────────────────┐ ┌─────────────────────────────────────┐ │ │
│ │ │ Encrypted DEK │ │ Encrypted Data │ │ │
│ │ │ (Wrapped key) │ │ │ │ │
│ │ └─────────────────┘ └─────────────────────────────────────┘ │ │
│ └────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
Why This Pattern Works:
| Benefit | Explanation |
|---|---|
| Performance | Only the DEK (256 bits) goes to KMS; data encrypted locally at AES speed |
| Cost | One KMS call per object/volume, not per byte |
| Scalability | Generate unique DEK per object; compromise of one doesn't affect others |
| Key rotation | Rotate CMK without re-encrypting data; old DEKs still decryptable |
When you enable encryption on S3, EBS, or RDS, the service implements envelope encryption automatically. You select the CMK; the service handles DEK generation, encryption, storage, and retrieval transparently.
Encryption at rest protects data stored in cloud services. Each service has its own encryption implementation, though the underlying concepts are consistent.
AWS Storage Encryption Options:
| Service | Encryption Method | Key Options | Default |
|---|---|---|---|
| S3 | SSE-S3, SSE-KMS, SSE-C, Client-side | AWS-managed, CMK, Customer-provided | SSE-S3 (default since 2023) |
| EBS | XTS-AES-256 | AWS-managed, CMK | Optional (can mandate) |
| RDS | AES-256 | AWS-managed, CMK | Optional at creation |
| DynamoDB | AES-256 | AWS-managed, CMK | Enabled by default |
| EFS | AES-256 | AWS-managed, CMK | Optional at creation |
| Redshift | AES-256 | AWS-managed, CMK, CloudHSM | Optional |
S3 Server-Side Encryption Options Explained:
SSE-S3 (S3-Managed Keys):
SSE-KMS (KMS-Managed Keys):
SSE-C (Customer-Provided Keys):
Client-Side Encryption:
Remember: encryption at rest protects against unauthorized access to storage. Anyone with S3:GetObject permission AND KMS:Decrypt permission can read encrypted objects. Encryption adds a layer, but IAM remains essential.
Encryption in transit protects data as it moves across networks. The standard mechanism is Transport Layer Security (TLS), the successor to SSL.
TLS Overview:
TLS provides three security properties:
TLS Handshake (simplified):
┌──────────────┐ ┌──────────────┐
│ Client │ │ Server │
└──────────────┘ └──────────────┘
│ │
│──────── 1. ClientHello ────────────────▷│
│ (Supported versions, ciphers) │
│ │
│◁─────── 2. ServerHello + Certificate ───│
│ (Selected version, cipher, cert)│
│ │
│──────── 3. Key Exchange ───────────────▷│
│ (Verify cert, share key material)│
│ │
│◁─────── 4. Finished ────────────────────│
│ (Confirm encryption working) │
│ │
│◁═══════ 5. Encrypted Data ═════════════▷│
│ │
Internal Service-to-Service Encryption:
For traffic within your cloud environment (between microservices, to databases, etc.):
| Approach | Implementation | Complexity | Use Case |
|---|---|---|---|
| TLS everywhere | Each service has certificates; all connections over HTTPS | Medium | Traditional web applications |
| mTLS (Mutual TLS) | Both client and server present certificates | High | Zero-trust, service mesh |
| Service mesh (Istio, Linkerd) | Sidecar proxies handle mTLS automatically | Medium (operational) | Kubernetes environments |
| VPN/PrivateLink | Encrypted at network layer | Low (application) | Hybrid cloud, cross-account |
mTLS Deep Dive:
mTLS (mutual TLS) adds client authentication to standard TLS:
Standard TLS: mTLS:
┌────────┐ Verifies ┌────────┐ ┌────────┐ Verifies ┌────────┐
│ Client │ ─────────────▷ │ Server │ │ Client │ ◁──────────▷ │ Server │
└────────┘ Server └────────┘ └────────┘ Both Certs └────────┘
Cert Only Verified
mTLS is essential for zero-trust architectures where network location doesn't confer trust. Service meshes like Istio automate mTLS between all services, making the implementation transparent to application code.
Database connections are often unencrypted by default. Ensure RDS, Aurora, and ElastiCache connections use TLS. Check that connection strings include SSL/TLS requirements and that certificate validation is enforced.
For organizations with advanced security requirements, standard KMS may not be sufficient. Cloud providers offer additional key management options for higher assurance levels.
CloudHSM / Dedicated HSM:
For organizations requiring exclusive control over HSMs:
Bring Your Own Key (BYOK):
Some organizations must control key generation, often for compliance or to maintain consistency across multi-cloud:
BYOK Flow:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ On-Premises │ │ Wrapping │ │ AWS KMS │
│ Key Generation │────▷│ with AWS │────▷│ Import Key │
│ (Your HSM) │ │ Public Key │ │ Material │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │
│ Key material never │
│ leaves your control │
│ in plaintext │
│ │
└───────────────────────────────────────────────┘
BYOK Considerations:
External Key Stores (XKS):
The newest option allows KMS to use keys stored entirely outside AWS:
| Feature | Standard KMS | Custom Key Store | External Key Store |
|---|---|---|---|
| Key location | AWS HSMs | Your CloudHSM | Your external HSM/KMS |
| Key material | AWS generates/stores | You control in CloudHSM | Entirely outside AWS |
| Integration | Native AWS services | Native AWS services | Native AWS services |
| Use case | Most workloads | Regulatory HSM requirements | Sovereignty, multi-cloud key management |
Each level of additional control adds operational complexity. Standard KMS is secure enough for most workloads. Choose advanced options only when regulatory, contractual, or threat model requirements truly demand them.
Encryption is powerful but can be implemented incorrectly. These anti-patterns undermine the protection encryption should provide.
kms:* to applications or roles. Any entity with decrypt permission for your CMK can decrypt your data.The 'Encrypted' False Sense of Security:
A common mistake is assuming encrypted data is protected regardless of IAM:
Scenario: S3 bucket with SSE-KMS encryption
❌ Misconfigured:
- Bucket policy allows public access
- CMK policy grants kms:Decrypt to "*"
- Result: Anyone can download and decrypt
✓ Properly configured:
- Bucket policy restricts to specific principals
- CMK policy restricts kms:Decrypt to same principals
- Result: Only authorized entities can access
Encryption amplifies your IAM decisions, but it doesn't replace them. If the same principals who can read encrypted data can also decrypt, encryption mainly protects against physical theft and some insider scenarios—not against IAM misconfigurations.
The worst encryption mistake is 'security theater'—enabling encryption checkboxes for compliance without proper key management. Encryption with overly permissive key policies provides a false sense of security while adding no real protection against most attack scenarios.
Encryption is the last line of defense—when all other controls fail, encrypted data remains protected. But encryption is only as strong as key management and access controls.
What's Next:
With encryption protecting data, our final topic addresses compliance in the cloud—how organizations meet regulatory requirements, achieve and maintain certifications, and demonstrate security to auditors and customers. Compliance ties together all the security controls we've discussed into a cohesive, verifiable framework.
You now understand cloud encryption architecture—from fundamental concepts through KMS, envelope encryption, and advanced key management. This knowledge enables you to design encryption strategies that truly protect data rather than just checking compliance boxes.