A developer is implementing a security feature for a web application to encrypt sensitive transaction records using an AWS KMS customer managed key (CMK). During the `Encrypt` API call, the developer passes the transaction ID as part of the encryption context: `{"TransactionID": "TX-98765"}`. During a scheduled audit, an offline compliance service attempts to decrypt the transaction records using the AWS SDK. The service's IAM role has full permissions to call `kms:Decrypt` on the CMK, but the decryption requests fail with an `InvalidCiphertextException`. How should the developer resolve this issue?
- Ensure that the compliance service includes the exact encryption context `{"TransactionID": "TX-98765"}` in its `Decrypt` API request.Cevap
- BUpdate the KMS key policy of the customer managed key to permit the compliance service to bypass the encryption context verification.
- CStore the encryption context value in AWS Systems Manager Parameter Store as a secure string and reference it in the service's IAM policy.
- DCall the `ReEncrypt` API to move the ciphertext to a different customer managed key that does not require an encryption context.
Cevap
Ensure that the compliance service includes the exact encryption context `{"TransactionID": "TX-98765"}` in its `Decrypt` API request.
The encryption context in AWS KMS acts as additional authenticated data (AAD) and is cryptographically bound to the ciphertext. To decrypt the data, the exact same encryption context (key-value pair) must be provided in the Decrypt API request. Without it, KMS cannot verify the integrity of the ciphertext and returns an InvalidCiphertextException.
Adım Adım Çözüm
Anahtar Kavram
AWS KMS Encryption Context behaves as Additional Authenticated Data (AAD) that must match exactly during decryption operations.