All Products
Search
Document Center

Key Management Service:Decrypt

更新時間:Sep 09, 2024

Decrypts ciphertext.

Usage notes

  • Keys outside Key Management Service (KMS) instances: To perform cryptographic operations, use Alibaba Cloud SDK to call operations.
  • Keys in KMS instances: To perform cryptographic operations, use one of the following methods:

Limits

You can call this operation up to 750 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter

Type

Required

Example

Description

Action String Yes Decrypt

The operation that you want to perform. Set the value to Decrypt.

CiphertextBlob String Yes DZhOWVmZDktM2QxNi00ODk0LWJkNGYtMWZjNDNmM2YyYWJmaaSl+TztSIMe43nbTH/Z1Wr4XfLftKhAciUmDQXuMRl4WTvKhxjMThjK****

The ciphertext that you want to decrypt.

You can generate the ciphertext by calling the following operations:

EncryptionContext Map No {"Example":"Example"}

The JSON string that consists of key-value pairs.

Note If you specify the EncryptionContext parameter when you call the GenerateDataKey, Encrypt, or GenerateDataKeyWithoutPlaintext operation, you must specify the same value for this parameter when you call the Decrypt operation. For more information, see EncryptionContext.
DryRun String No false

Specifies whether to perform a dry run. Valid values:

  • true
  • false (default)

A dry run is used for testing in API calls. You can perform a dry run to check whether you have the permissions to access the resources that you want to manage and whether the request parameters are correctly configured. If you set DryRun to true in the request, KMS always returns an error code that indicates the cause of the error. KMS may return the following error codes:

  • DryRunOperationError: The request passes the dry run. If you do not specify the DryRun parameter and retain the other parameter configurations to call the same operation, the operation will be performed.
  • ValidationError: A parameter value in the request is invalid.
  • AccessDeniedError: You do not have the permissions to access the resources that you want to manage.

Response parameters

Parameter

Type

Example

Description

KeyVersionId String 2ab1a983-7072-4bbc-a582-584b5bd8****

The version ID of the key that is used to decrypt the ciphertext.

KeyId String 202b9877-5a25-46e3-a763-e20791b5****

The ID of the key that is used to decrypt the ciphertext.

The ID must be globally unique.

RequestId String 207596a2-36d3-4840-b1bd-f87044699bd7

The request ID.

Plaintext String tRYXuCwgja12xxO1N/gZERDDCLw9doZEQiPDk/Bv****

The plaintext that is generated after decryption.

Examples

Sample requests

http(s)://[Endpoint]/?Action=Decrypt
&CiphertextBlob=DZhOWVmZDktM2QxNi00ODk0LWJkNGYtMWZjNDNmM2YyYWJmaaSl+TztSIMe43nbTH/Z1Wr4XfLftKhAciUmDQXuMRl4WTvKhxjMThjK****
&DryRun=false
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DecryptResponse>
    <KeyVersionId>2ab1a983-7072-4bbc-a582-584b5bd8****</KeyVersionId>
    <KeyId>202b9877-5a25-46e3-a763-e20791b5****</KeyId>
    <RequestId>207596a2-36d3-4840-b1bd-f87044699bd7</RequestId>
    <Plaintext>tRYXuCwgja12xxO1N/gZERDDCLw9doZEQiPDk/Bv****</Plaintext>
</DecryptResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "KeyVersionId" : "2ab1a983-7072-4bbc-a582-584b5bd8****",
  "KeyId" : "202b9877-5a25-46e3-a763-e20791b5****",
  "RequestId" : "207596a2-36d3-4840-b1bd-f87044699bd7",
  "Plaintext" : "tRYXuCwgja12xxO1N/gZERDDCLw9doZEQiPDk/Bv****"
}

Error codes

HttpCode

Error code

Error message

Description

400 UnsupportedOperation This action is not supported. The operation is not supported.
404 Forbidden.AliasNotFound The specified Alias is not found. The specified alias is not found.
404 Forbidden.KeyNotFound The specified Key is not found. The specified key does not exist.
409 Rejected.Disabled The request was rejected because the key state is Disabled. The request is denied because the key is disabled.
409 Rejected.PendingDeletion The request was rejected because the key state is PendingDeletion. The request is denied because the key is in the Pending Deletion state.
409 Rejected.Unavailable The request was rejected because the key state is Unavailable. The request is denied because the key is unavailable.

For a list of error codes, see Service error codes.