Decrypt
Calls the Decrypt operation to decrypt ciphertext into plaintext.
Operation description
After you call the Encrypt or GenerateDataKey operation to generate ciphertext, you can use Decrypt to decrypt the ciphertext.
For more information about key specifications and encryption modes, see Key management types and key specifications.
Usage notes
All request parameters are encoded with Protocol Buffers. The resulting request body cannot exceed 3 MB. If the data volume exceeds 3 MB, the server rejects the request and returns HTTP status code 413.
For a single encrypt or decrypt call, keep the data within the following limits:
Key type | Recommended maximum data volume |
Symmetric key | 6 KB |
Asymmetric key | 1 KB |
If your data exceeds these limits, use envelope encryption instead. For more information, see Envelope encryption.
The larger the data volume in a single call, the higher the risk of network transmission failure, the longer the transmission takes, and the longer the KMS instance needs to complete data encryption or decryption.
Request parameters
Name | Type | Required | Example | Description |
KeyId | string | Yes | key-hzz62f1cb66fa42qo**** | The globally unique identifier of the key. You can also specify a key alias for this parameter. |
Algorithm | string | No | AES_GCM | The decryption algorithm. Important The value must be the same as the algorithm used for encryption. |
Iv | bytes | No | Binary data | The initialization vector. This parameter is required only if the decryption algorithm (Algorithm parameter) is AES_GCM, AES_CBC, or SM4_GCM.
Important The value must be the same as the initialization vector used for encryption. |
CiphertextBlob | bytes | Yes | Binary data | The ciphertext to decrypt. Note If the ECIES algorithm is used, the ciphertext format follows the SEC 1: Elliptic Curve Cryptography, Version 2.0 standard. |
Aad | bytes | No | Binary data | The additional authenticated data. The length cannot exceed 8,192 bytes. This parameter is required only if the decryption algorithm (Algorithm) is AES_GCM or SM4_GCM and the additional authenticated data (Aad) is specified during encryption. Important The value must be the same as the additional authenticated data used for encryption. |
PaddingMode | string | No | PKCS7_PADDING | The padding mode. This parameter is required only if the encryption algorithm is AES_CBC or AES_ECB. Important The value must be the same as the padding mode used for encryption. Valid values:
|
Response data
Name | Type | Example | Description |
Plaintext | bytes | Binary data | The decrypted plaintext. |
KeyId | string | key-hzz62f1cb66fa42qo**** | The globally unique identifier of the key. If a key alias is used as the KeyId parameter in the request, the globally unique identifier of the key that corresponds to the alias is returned in the response. |
Algorithm | string | AES_GCM | The decryption algorithm. |
PaddingMode | string | PKCS7_PADDING | The padding mode. |
RequestId | string | 475f1620-b9d3-4d35-b5c6-3fbdd941423d | The ID of the request. Alibaba Cloud generates a unique ID for each request. You can use the request ID to troubleshoot issues. |
Error codes
HTTP status code | Error code | Error message | Description |
500 | InternalFailure | Internal Failure. | Possible causes:
If the preceding causes are ruled out, contact technical support. |
For more information about error codes, see Common error codes.