Skip to main content
Cryptography Basics
CHAPTER 13

Cryptography in Cloud Computing

Updated: May 15, 2026
25 min read

# CHAPTER 13

Cryptography in Cloud Computing

1. Introduction

When your data resides on your own physical hard drive, you control the physical security. But when you migrate your databases to AWS, Azure, or Google Cloud, your sensitive data sits on a hard drive in a data center owned by someone else, shared with hundreds of other companies. How do you guarantee privacy in a shared environment? The answer is ubiquitous encryption. In this chapter, we will explore the concepts of Encryption at Rest, Encryption in Transit, and the absolute necessity of Cloud Key Management Services (KMS).

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Define the Shared Responsibility Model regarding encryption.
  • Differentiate between Data at Rest and Data in Transit.
  • Understand the function of a Key Management Service (KMS).
  • Explain the concept of Envelope Encryption.
  • Identify the security benefits of Customer Managed Keys (CMK).

3. Beginner-Friendly Explanation

Imagine renting a storage unit.
  • The Cloud Provider: Owns the building. They provide security cameras and a padlock for your specific unit door. (Server-Side Encryption).
  • The Trust Issue: The storage facility manager has a master key to all the padlocks. If they wanted to, they could open your unit and look at your stuff.
  • Envelope Encryption (The Solution): Inside the storage unit, you put your items into a massive steel safe. You lock the safe with an electronic code. You put the electronic code on a piece of paper, put the paper in a small lockbox, and take the key to the lockbox home with you.
Even if the storage manager opens the unit door, they cannot open the safe without the code, and they cannot get the code because you hold the master key.

4. Data States and Encryption

Data exists in three states, and cryptography must protect all of them:
  1. 1. Data in Transit: Data moving over the network. *Protection:* TLS/HTTPS (Chapter 9).
  1. 2. Data at Rest: Data saved to a hard drive or database. *Protection:* AES-256 Symmetric Encryption.
  1. 3. Data in Use: Data loaded into RAM for active processing. *(The hardest to protect, requiring advanced concepts like Confidential Computing).*

5. Key Management Service (KMS)

The hardest part of cloud cryptography is not encrypting the data; it's hiding the keys. If you put your encryption key on the same cloud server as your database, a hacker steals both. A KMS (like AWS KMS or Azure Key Vault) is a highly secure, isolated hardware appliance within the cloud.
  • It generates, stores, and rotates cryptographic keys.
  • Crucially: The master keys *never* leave the KMS hardware. If an application wants to decrypt data, it must send the data *to* the KMS. The KMS decrypts it internally and sends the plaintext back. A hacker cannot steal a key that cannot be exported.

6. Envelope Encryption

Encrypting a 500GB database inside the KMS would overload the network. Cloud providers solve this using Envelope Encryption.
  1. 1. Data Key: The KMS generates a unique, temporary Symmetric Key (the Data Key).
  1. 2. Encrypt the Data: Your application uses this Data Key to quickly encrypt the 500GB database locally.
  1. 3. Encrypt the Key: Your application sends the Data Key to the KMS. The KMS encrypts the Data Key using a highly-guarded Master Key.
  1. 4. Storage: You store the *Encrypted Data* and the *Encrypted Data Key* side-by-side in the database.
If a hacker steals the database, they get the Encrypted Data Key, but they cannot decrypt it because the Master Key never left the KMS!

7. Mini Project: Configure Encrypted Cloud Storage Concepts

How do we apply this in an AWS environment?

The Secure S3 Bucket Workflow:

  1. 1. Create the Bucket: An administrator creates an Amazon S3 bucket for storing HR documents.
  1. 2. Enable Default Encryption: The admin checks the box for "Server-Side Encryption."
  1. 3. Choose the Key Strategy:
  • *Option A (SSE-S3):* Amazon manages the keys completely. (Easy, but you must fully trust Amazon).
  • *Option B (SSE-KMS):* You use a Customer Managed Key (CMK) in AWS KMS. You create strict policies stating: "Only the HR_Role can ask the KMS to decrypt files in this bucket."
  1. 4. The Result: Even if a rogue AWS employee accesses the physical hard drive in the data center, the data is AES-encrypted, and the rogue employee does not have permission to use your KMS Master Key.

8. Real-World Scenarios

In 2019, an attacker gained unauthorized access to a massive trove of data belonging to Capital One, stored in AWS S3 buckets. The data was encrypted at rest. However, the attacker managed to compromise a cloud firewall (WAF) and assume its IAM Role. Because the company had architected the environment such that this specific IAM Role had permissions to both read the S3 bucket *and* access the KMS decryption keys, the attacker was able to systematically download and decrypt the data. The encryption algorithms worked perfectly; the failure was overly permissive Access Control to the KMS keys.

9. Best Practices

  • Bring Your Own Key (BYOK): For organizations with extreme regulatory requirements (like finance or government), fully trusting the cloud provider is unacceptable. They use BYOK. The organization generates the Master Key on their own physical hardware inside their own office, and securely imports a copy into the Cloud KMS. If they ever want to instantly revoke the cloud provider's access, they simply delete the key from the KMS, rendering all cloud data permanently cryptographically shredded.
When storing data in foreign cloud regions (e.g., a US company storing data in a European data center), organizations must be aware of Data Sovereignty laws. Robust encryption and strict KMS policies are often legally mandated to ensure foreign governments cannot unilaterally access the data stored on physical servers within their borders.

11. Exercises

  1. 1. Describe the concept of Envelope Encryption. Why is it computationally necessary when dealing with massive datasets in the cloud?
  1. 2. Explain the security advantage of using a Key Management Service (KMS) rather than storing an encryption key as an environment variable on a web server.

12. FAQs

Q: Does encrypting my cloud database make my application slower? A: Marginally, yes. However, modern cloud processors have dedicated hardware instruction sets for AES encryption (AES-NI). The performance hit is typically less than a few milliseconds—a negligible cost for the massive security benefits it provides.

13. Interview Questions

  • Q: Explain the Shared Responsibility Model in the context of cloud data encryption. Where does the cloud provider's responsibility end and the customer's begin?
  • Q: A client wants to ensure that even if a cloud provider is subpoenaed by a government entity, the provider cannot decrypt the client's data. Architect a cloud encryption strategy using Customer Managed Keys (CMK) and Envelope Encryption to satisfy this requirement.

14. Summary

In Chapter 13, we addressed the trust deficit inherent to cloud computing. We learned that securing data on someone else's hardware requires ubiquitous encryption across all states: in transit and at rest. We explored Key Management Services (KMS) as the secure hardware vaults of the cloud, ensuring master keys are never exposed. Finally, we dissected Envelope Encryption, a brilliant architectural pattern that combines the speed of local symmetric encryption with the rigorous access control of centralized key management.

15. Next Chapter Recommendation

Cryptography secures money in banks and data in the cloud. But what if we used cryptography to create a completely decentralized system of trust, with no banks or central authorities at all? Proceed to Chapter 14: Blockchain and Cryptography Basics.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·