Skip to main content

Decrypt

Decrypts ciphertext that was encrypted by a KMS key using any of the encryption operations.

Description​

The `Decrypt` operation decrypts ciphertext that was encrypted by a KMS key using any of the following operations: `Encrypt`, `GenerateDataKey`, or `GenerateDataKeyWithoutPlaintext`. You can use this operation to decrypt data outside of QKMS that was encrypted with a KMS key in QKMS.

note
  • The KMS key that you use for this operation must be in a compatible key state. For details, see Key states required for operations.
  • The ciphertext must have been encrypted under the specified KMS key.
  • If the ciphertext was encrypted under a symmetric KMS key, you must use the same KMS key to decrypt it.
  • If you use an asymmetric KMS key to encrypt a message, you must use the correct asymmetric KMS key to decrypt the message.

Request Syntax​

Headers​

NameDescriptionRequiredType
Content-TypeMust be "application/x-amz-json-1.1"Yesstring
X-Amz-TargetMust be "TrentService.Decrypt"Yesstring

Request Body​

NameDescriptionRequiredType
CiphertextBlobThe ciphertext to decrypt.YesBlob
KeyIdSpecifies the KMS key that QKMS uses to decrypt the ciphertext. This value can be the key ID or key ARN of the KMS key.NoString
EncryptionContextSpecifies the encryption context to use when decrypting the data. The same encryption context that was used to encrypt the data must be provided.NoObject
GrantTokensA list of grant tokens that represent grants that were used to encrypt the ciphertext.NoArray
POST / HTTP/1.1
Content-Type: application/x-amz-json-1.1
X-Amz-Target: TrentService.Decrypt
{ "CiphertextBlob": "AQICAHiWj6qDgGqSQXkNHcsbq8Q3+q6lThTZqXXRRXYtGhEQXwEH5qV5eN9LQI6CtDwBUvNVAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMeq6+5Ey7LGAKorXtAgEQgDsgli8KqqW4qp0g9ZWnHdRGYc3ZJzpV3xH9qVGFRwzVVKJNK/Ey/fGS2tl4TOQXLcTYJMEOxR8gPjA=", "KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab", "EncryptionContext": { "Department": "Finance" } }
Values in italics indicate user input and should be replaced with actual values.

Response Elements​

NameDescriptionRequiredType
KeyIdThe Amazon Resource Name (ARN) of the KMS key that was used to decrypt the ciphertext.NoString
PlaintextThe decrypted (plaintext) data.NoString
EncryptionAlgorithmThe encryption algorithm that was used to decrypt the ciphertext.NoString

Examples​

Example 1: Decrypt ciphertext using a symmetric KMS key​

POST / HTTP/1.1
Content-Type: application/x-amz-json-1.1
X-Amz-Target: TrentService.Decrypt
{ "CiphertextBlob": "AQICAHiWj6qDgGqSQXkNHcsbq8Q3+q6lThTZqXXRRXYtGhEQXwEH5qV5eN9LQI6CtDwBUvNVAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMeq6+5Ey7LGAKorXtAgEQgDsgli8KqqW4qp0g9ZWnHdRGYc3ZJzpV3xH9qVGFRwzVVKJNK/Ey/fGS2tl4TOQXLcTYJMEOxR8gPjA=", "KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab", "EncryptionContext": { "Department": "Finance" } }
Values in italics indicate user input and should be replaced with actual values.
HTTP/1.1 200 OK
Content-Type: application/x-amz-json-1.1
{ "KeyId": "arn:verenc:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab", "Plaintext": "SGVsbG8gV29ybGQ=", "EncryptionAlgorithm": "SYMMETRIC_DEFAULT" }
Values in italics indicate variable response values.

Special Errors​

Error CodeDescription
DependencyTimeoutExceptionThe system timed out while trying to fulfill the request.
DisabledExceptionThe request was rejected because the specified KMS key is disabled.
InvalidCiphertextExceptionThe request was rejected because the specified ciphertext has been corrupted or is not valid.
InvalidGrantTokenExceptionThe request was rejected because the specified grant token is not valid.
InvalidKeyUsageExceptionThe request was rejected because the specified KeyId value cannot be used for this operation.
KeyUnavailableExceptionThe request was rejected because the specified KMS key was not available.
KMSInternalExceptionThe request was rejected because an internal error occurred.
KMSInvalidStateExceptionThe request was rejected because the key state is not valid for this operation.
NotFoundExceptionThe request was rejected because the specified key was not found.

Permissions​

To use the `Decrypt` operation, you must have the following permissions:

  • `kms:Decrypt` on the KMS key

Try It Out​

Test Decrypt

Decrypt ciphertext that was encrypted by a KMS key.

Coming Soon

This feature is currently under development and will be available soon.