Last updated: 2021-02-04 10:24:08

    1. API Description

    Domain name for API request:

    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 parameter. The value used for this API: AsymmetricSm2Decrypt.
    Version Yes String Common parameter. The value used for this API: 2019-01-18.
    Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
    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 SM2 asymmetric key

    Input Example
    &<Common request parameters>

    Output Example

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

    5. Developer Resources


    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.