tencent cloud

Feedback

AsymmetricSm2Decrypt

Last updated: 2023-08-07 17:45:17

1. API Description

Domain name for API request: kms.tencentcloudapi.com.

This API is used to decrypt data with the specified private key that is encrypted with SM2 asymmetric cryptographic algorithm. The ciphertext must be encrypted with the corresponding public key. The asymmetric key must be in Enabled state for decryption. The length of the ciphertext passed in cannot exceed 256 bytes.

A maximum of 200 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: AsymmetricSm2Decrypt.
Version Yes String Common Params. The value used for this API: 2019-01-18.
Region No String Common Params. This parameter is not required for this API.
KeyId Yes String Unique CMK ID
Ciphertext Yes String Base64-encoded ciphertext encrypted with PublicKey, whose length cannot exceed 256 bytes.

3. Output Parameters

Parameter Name Type Description
KeyId String Unique CMK ID
Plaintext String Base64-encoded plaintext after decryption
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Decrypting data with an SM2 asymmetric key

Input Example

https://kms.tencentcloudapi.com/?Action=AsymmetricSm2Decrypt
&KeyId=554ef4b3-3071-11ea-a86a-5254006d0810
&Ciphertext=Fb0UICocErQgNEkYKJagtoKNed7DLeo5UkZzPJMyI94CfWh6yKHGgb/0PBHrCve2Avo4gJI5pJMWP3Aq5ggX0aunLv87UX+sgO1/3HXW+q4ARaiwZ9Q73RQuPg6qJ2Eg33uZ2Xjey3l+5yHiOdZYmCVePtKAsuhxzKw/sALTbGTYYnbJXnGKr3Yu7Hs0hCC1bOz0sNqd1IXdUyMtQtbDOV8NWg2ecdZPIOdbnrCKIQ4rpMUghjSFv3rSHo5VbpuOGPXqEZT4goou42psIXb03li3TXxFZMTAdxVMzpqEuTfRxiMPEqyPEHe6xG92vJX0FZfWU8Y5SxlfXp+mvBbAmw==
&<Common request parameters>

Output Example

{
    "Response": {
        "RequestId": "7c076c83-1402-41d8-8ce6-73a350a9eaf6",
        "KeyId": "554ef4b3-3071-11ea-a86a-5254006d0810",
        "Plaintext": "dGVzdA=="
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
FailedOperation.DecryptError Decryption failed.
InternalError Internal error.
InvalidParameter Invalid parameter.
InvalidParameterValue.InvalidKeyId Invalid KeyId.
InvalidParameterValue.InvalidKeyUsage Incorrect KeyUsage parameter.
ResourceUnavailable.CmkNotFound The CMK does not exist.
ResourceUnavailable.CmkStateNotSupport This operation cannot be performed under the current CMK status.
UnauthorizedOperation Unauthorized operation.
UnsupportedOperation.UnsupportedKeyUsageInCurrentRegion The encryption method is not supported in the current region.