All Products
Search
Document Center

Key Management Service:ExportDataKey

更新時間:Sep 13, 2024

Encrypts a data key by using a specific public key and exports the data key.

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.

Description

You can call the GenerateDataKeyWithoutPlaintext operation to obtain the data key that is encrypted by using a key. If you want to distribute the data key to other regions or cryptographic modules, you can call the ExportDataKey operation to obtain the ciphertext of the data key that is encrypted by using the specified public key.

Then, you can import the ciphertext of the data key that is encrypted by using the public key to a cryptographic module where paired private keys are stored. This way, the data key is securely distributed from KMS to the cryptographic module. After the data key is imported to the cryptographic module, you can use it to encrypt or decrypt data.

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 ExportDataKey

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

CiphertextBlob String Yes ODZhOWVmZDktM2QxNi00ODk0LWJkNGYtMWZjNDNmM2YyYWJmS7FmDBBQ0BkKsQrtRnidtPwirmDcS0ZuJCU41xxAAWk4Z8qsADfbV0b+i6kQmlvj79dJdGOvtX69Uycs901q********

The ciphertext of the data key that is encrypted by using a key.

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

The JSON string that consists of key-value pairs. The parameter specifies the encryption context. For more information, see EncryptionContext.

PublicKeyBlob String Yes MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAndKfC2ReLL2+y8a0+ZBBeAft/uBYo86GZiYJuflqgUzKxpyuvlo3uQkBv6b+nx+0tz8g8v7GhpPWMSW5L9mNHYsvYFsa7jTxsYdt17yj6GlUHPuMIs8hr5qbwl38IHU1iIa7nYWwE2fb3ePOvLDACRJVgGpU0yxioW80d2QD+9aU4jF5dlAahcfgsNzo2CXzCUc1+xbmNuq7Rp+H9VJB9dyYOwqnW3RhOLBo21FzpORapf0UiRlrHRpk1V6ez+aE1dofaYh/9bh0m6ioxj7j5hpZbWccuEZTMBKd+cbuBkRhJzc6Tti6qwZbDiu4fUwbZS0Tqpuo1UadiyxMW********

The Base64-encoded public key.

WrappingKeySpec String Yes RSA_2048

The key type of the public key that is specified by PublicKeyBlob. For more information about key types, see Introduction to asymmetric keys.

Valid values:

  • RSA_2048
  • EC_SM2
WrappingAlgorithm String Yes RSAES_OAEP_SHA_256

The encryption algorithm based on which you use the public key specified by PublicKeyBlob to encrypt the data key. For more information about encryption algorithms, see AsymmetricDecrypt.

Valid values:

  • RSAES_OAEP_SHA_256
  • RSAES_OAEP_SHA_1
  • SM2PKE
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 configure 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 data key ciphertext.

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

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

The ID must be globally unique.

RequestId String 4bd560a1-729e-45f1-a3d9-b2a33d61046b

The request ID.

ExportedDataKey String BQKP+1zK6+ZEMxTP5qaVzcsgXtWplYBKm0NXdSnB5FzliFxE1bSiu4dnEIlca2JpeH7yz1/S6fed630H+hIH6DoM25fTLNcKj+mFB0Xnh9m2+HN59Mn4qyTfcUeadnfCXSWcGBouhXFwcdd2rJ3n337bzTf4jm659gZu3L0i6PLuxM9p7mqdwO0cKJPfGVfhnfMz+f4alMg79WB/NNyE2lyX7/qxvV49ObNrrJbKSFiz8Djocaf0IESNLMbfYI5bXjWkJlX92DQbKhibtQW8ZOJ//ZC6t0AWcUoKL6QDm/dg5koQalcleRinpB+QadFm894sLbVZ9+N4GVs*******

The ciphertext of the data key that is encrypted by using the public key.

Examples

Sample requests

http(s)://[Endpoint]/?Action=ExportDataKey
&CiphertextBlob=ODZhOWVmZDktM2QxNi00ODk0LWJkNGYtMWZjNDNmM2YyYWJmS7FmDBBQ0BkKsQrtRnidtPwirmDcS0ZuJCU41xxAAWk4Z8qsADfbV0b+i6kQmlvj79dJdGOvtX69Uycs901q********
&PublicKeyBlob=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAndKfC2ReLL2+y8a0+ZBBeAft/uBYo86GZiYJuflqgUzKxpyuvlo3uQkBv6b+nx+0tz8g8v7GhpPWMSW5L9mNHYsvYFsa7jTxsYdt17yj6GlUHPuMIs8hr5qbwl38IHU1iIa7nYWwE2fb3ePOvLDACRJVgGpU0yxioW80d2QD+9aU4jF5dlAahcfgsNzo2CXzCUc1+xbmNuq7Rp+H9VJB9dyYOwqnW3RhOLBo21FzpORapf0UiRlrHRpk1V6ez+aE1dofaYh/9bh0m6ioxj7j5hpZbWccuEZTMBKd+cbuBkRhJzc6Tti6qwZbDiu4fUwbZS0Tqpuo1UadiyxMW********
&WrappingKeySpec=RSA_2048
&WrappingAlgorithm=RSAES_OAEP_SHA_256
&DryRun=false
&<Common request parameters>

Sample success responses

XML format

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

<ExportDataKeyResponse>
    <KeyVersionId>2ab1a983-7072-4bbc-a582-584b5bd8****</KeyVersionId>
    <KeyId>202b9877-5a25-46e3-a763-e20791b5****</KeyId>
    <RequestId>4bd560a1-729e-45f1-a3d9-b2a33d61046b</RequestId>
    <ExportedDataKey>BQKP+1zK6+ZEMxTP5qaVzcsgXtWplYBKm0NXdSnB5FzliFxE1bSiu4dnEIlca2JpeH7yz1/S6fed630H+hIH6DoM25fTLNcKj+mFB0Xnh9m2+HN59Mn4qyTfcUeadnfCXSWcGBouhXFwcdd2rJ3n337bzTf4jm659gZu3L0i6PLuxM9p7mqdwO0cKJPfGVfhnfMz+f4alMg79WB/NNyE2lyX7/qxvV49ObNrrJbKSFiz8Djocaf0IESNLMbfYI5bXjWkJlX92DQbKhibtQW8ZOJ//ZC6t0AWcUoKL6QDm/dg5koQalcleRinpB+QadFm894sLbVZ9+N4GVs*******</ExportedDataKey>
</ExportDataKeyResponse>

JSON format

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

{
  "KeyVersionId" : "2ab1a983-7072-4bbc-a582-584b5bd8****",
  "KeyId" : "202b9877-5a25-46e3-a763-e20791b5****",
  "RequestId" : "4bd560a1-729e-45f1-a3d9-b2a33d61046b",
  "ExportedDataKey" : "BQKP+1zK6+ZEMxTP5qaVzcsgXtWplYBKm0NXdSnB5FzliFxE1bSiu4dnEIlca2JpeH7yz1/S6fed630H+hIH6DoM25fTLNcKj+mFB0Xnh9m2+HN59Mn4qyTfcUeadnfCXSWcGBouhXFwcdd2rJ3n337bzTf4jm659gZu3L0i6PLuxM9p7mqdwO0cKJPfGVfhnfMz+f4alMg79WB/NNyE2lyX7/qxvV49ObNrrJbKSFiz8Djocaf0IESNLMbfYI5bXjWkJlX92DQbKhibtQW8ZOJ//ZC6t0AWcUoKL6QDm/dg5koQalcleRinpB+QadFm894sLbVZ9+N4GVs*******"
}

Error codes

HttpCode

Error code

Error message

Description

400 InvalidParameter The specified parameter is not valid. The specified parameter is invalid.
500 InternalFailure Internal Failure. An internal error occurred. Try again later. If the error persists, submit a ticket.

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