A developer is implementing local client-side envelope encryption for sensitive reports in a microservice before uploading them to Amazon S3. To optimize costs and network overhead, the developer aims to generate a unique data key for each report using a customer managed key in AWS KMS. However, during integration testing, the developer observes that each file encryption requires two sequential AWS KMS API calls, which is causing latency and doubling API billing. The current implementation performs `kmsClient.generateDataKeyWithoutPlaintext(...)` followed by `kmsClient.decrypt(...)`. Which modification to the code should the developer make to reduce the integration to a single AWS KMS API call per report?
- AReplace the `generateDataKeyWithoutPlaintext` call with `encrypt` using the customer managed key to directly encrypt the report payload, and use the `decrypt` call to decrypt it upon retrieval.
- BStore a pre-generated plaintext data key in AWS Systems Manager Parameter Store as a SecureString parameter, retrieve it with a single call, and use the KMS `decrypt` API only to verify its integrity.
- Replace the `generateDataKeyWithoutPlaintext` call with `generateDataKey` to obtain both the plaintext data key and the ciphertext data key in a single response, and remove the subsequent `decrypt` call.Cevap
- DChange the second call to `reEncrypt` to convert the ciphertext data key into a format readable by the local encryption utility, bypassing the need for a plaintext key.
Cevap
Replace the `generateDataKeyWithoutPlaintext` call with `generateDataKey` to obtain both the plaintext data key and the ciphertext data key in a single response, and remove the subsequent `decrypt` call.
The correct solution is to change the API call to `generateDataKey`. Under envelope encryption, the client requires the plaintext data key to encrypt the payload locally, and the ciphertext data key to store alongside the encrypted payload. The `generateDataKey` operation returns both in a single response, removing the need for a separate, subsequent call to the `decrypt` API to extract the plaintext key.
Adım Adım Çözüm
Anahtar Kavram
AWS KMS Envelope Encryption Workflow Optimization