A developer is implementing client-side envelope encryption in a custom application to encrypt large payload files (greater than ) before uploading them to Amazon S3. The application needs to perform the encryption locally using a customer managed key stored in AWS KMS.
Which sequence of AWS SDK operations should the developer use to perform this client-side encryption?
- Call GenerateDataKey to retrieve both a plaintext and a ciphertext version of a data key. Use the plaintext key to encrypt the payload locally, discard the plaintext key from memory, and store the ciphertext key with the encrypted payload.Answer
- BCall Encrypt with the payload data to perform direct encryption in AWS KMS, then store the returned ciphertext payload in Amazon S3.
- CCall GenerateDataKeyWithoutPlaintext to retrieve the ciphertext data key. Use the ciphertext key to encrypt the payload locally, then store both the encrypted payload and the ciphertext key.
- DCall GetParameter with decryption enabled to retrieve the customer managed key from AWS Systems Manager Parameter Store, then use it to encrypt the payload locally.
Answer
Call GenerateDataKey to retrieve both a plaintext and a ciphertext version of a data key. Use the plaintext key to encrypt the payload locally, discard the plaintext key from memory, and store the ciphertext key with the encrypted payload.
The correct approach is to call the GenerateDataKey API to obtain both a plaintext data key (for local cryptographic operations) and a ciphertext data key (for safe storage). The plaintext key is used to encrypt the payload locally and must be removed from memory immediately afterward to ensure security.
Step-by-Step Solution
Key Concept
AWS KMS Envelope Encryption Workflow
Estimated Time:1m 30s