nerdexam
Amazon

DVA-C02 · Question #274

A developer is writing an application that will retrieve sensitive data from a third-party system. The application will format the data into a PDF file. The PDF file could be more than 1 MB. The…

The correct answer is A. Write the encrypted key from the GenerateDataKey API to disk for later use. Use the plaintext key. The AWS KMS envelope encryption pattern requires storing the encrypted data key alongside the ciphertext and using the plaintext data key only transiently in memory to encrypt data, never persisting it to disk.

Submitted by yaw92· Mar 5, 2026Security

Question

A developer is writing an application that will retrieve sensitive data from a third-party system. The application will format the data into a PDF file. The PDF file could be more than 1 MB. The application will encrypt the data to disk by using AWS Key Management Service (AWS KMS). The application will decrypt the file when a user requests to download it. The retrieval and formatting portions of the application are complete. The developer needs to use the GenerateDataKey API to encrypt the PDF file so that the PDF file can be decrypted later. The developer needs to use an AWS KMS symmetric customer managed key for encryption. Which solutions will meet these requirements?

Options

  • AWrite the encrypted key from the GenerateDataKey API to disk for later use. Use the plaintext key
  • BWrite the plain text key from the GenerateDataKey API to disk for later use. Use the encrypted
  • CWrite the encrypted key from the GenerateDataKey API to disk for later use. Use the plaintext key
  • DWrite the plain text key from the GenerateDataKey API to disk for later use. Use the encrypted

How the community answered

(36 responses)
  • A
    42% (15)
  • B
    8% (3)
  • C
    33% (12)
  • D
    17% (6)

Why each option

The AWS KMS envelope encryption pattern requires storing the encrypted data key alongside the ciphertext and using the plaintext data key only transiently in memory to encrypt data, never persisting it to disk.

AWrite the encrypted key from the GenerateDataKey API to disk for later use. Use the plaintext keyCorrect

The `GenerateDataKey` API returns both a plaintext key and an encrypted key (ciphertext blob). The correct pattern is to use the plaintext key immediately in memory to encrypt the PDF, then discard the plaintext key, and write only the encrypted key to disk with the ciphertext. To decrypt later, the encrypted key is passed to `Decrypt`, which returns the plaintext key to decrypt the file.

BWrite the plain text key from the GenerateDataKey API to disk for later use. Use the encrypted

Writing the plaintext key to disk is a critical security violation; if the disk is compromised, the key is exposed and the encryption provides no protection. The plaintext key must only exist in memory and be discarded after use.

CWrite the encrypted key from the GenerateDataKey API to disk for later use. Use the plaintext key

This option describes the same correct action as A but with an incorrect step (writing the encrypted key and using the plaintext key) -- however, the distinction between A and C likely involves whether the plaintext key is discarded after use; C may imply keeping the plaintext key, making it insecure.

DWrite the plain text key from the GenerateDataKey API to disk for later use. Use the encrypted

This option involves writing the plaintext key to disk, which is insecure for the same reason as option B; persisting the plaintext data key defeats the purpose of envelope encryption.

Concept tested: AWS KMS envelope encryption with GenerateDataKey

Source: https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#enveloping

Community Discussion

No community discussion yet for this question.

Full DVA-C02 Practice