A media company archives 200 MB video files, and a client-side process must encrypt each one with a customer managed AWS KMS key before it is stored.
Passing a whole file to the KMS Encrypt API fails because the file is too large. The company wants the fewest KMS API calls per file, and the key material of the KMS key must never leave KMS.
Which approach meets these requirements?
Choose one answer.
AA. Split each file into 4 KB pieces and call the KMS Encrypt API once for every piece, so that each call stays within its size limit.
BB. Create an asymmetric RSA KMS key and call Encrypt on the whole file, because RSA keys are meant for large inputs.
CC. Call GenerateDataKey, encrypt each file locally with the plaintext data key, and store the encrypted data key with the file.
DD. Call GenerateDataKeyWithoutPlaintext and use the encrypted data key that it returns to encrypt each file locally.
Show the answer and explanation
Answer: C
A. Wrong: Encrypt accepts at most 4,096 bytes of plaintext, so pieces of that size are accepted. But a 200 MB file would need about 50,000 calls, which is the opposite of keeping KMS calls to a minimum and invites throttling. Envelope encryption needs one call per file. Learn more: Encrypt API (opens in a new tab)
B. Wrong: RSA keys accept far less plaintext than symmetric keys: at most a few hundred bytes per call, depending on key size. The file would still be rejected, and a symmetric key with data keys is the right design. Learn more: Encrypt API (opens in a new tab)
C. Right: Correct. This is envelope encryption: KMS protects a small data key under the KMS key, and the large file is encrypted locally. The client keeps the encrypted data key with the file, discards the plaintext key and calls Decrypt on the data key when reading. Learn more: GenerateDataKey API (opens in a new tab)
D. Wrong: This operation returns only the encrypted copy of a data key, which is useless for local encryption until it is decrypted. An extra Decrypt call would then be needed for every file, so GenerateDataKey is the direct choice. Learn more: GenerateDataKey API (opens in a new tab)
Explanation
KMS Encrypt handles at most 4,096 bytes, so large files use envelope encryption. GenerateDataKey returns a plaintext data key for local encryption and an encrypted copy to store with the file, and the KMS key itself never leaves KMS. Chunking, RSA keys and the without-plaintext variant either multiply calls or still cannot encrypt the file.
One KMS call per file. To read the file later, send the stored encrypted data key to KMS Decrypt.
Want more on Encryption with AWS KMS? The 5 full-length practice sets have 16 more Encryption with AWS KMS questions, 390 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →