You need to enable JavaScript to run this app.
导航
AsymmetricEncrypt - 非对称密钥小流量数据加密
最近更新时间:2024.08.29 17:28:34首次发布时间:2024.08.29 17:28:34

非对称密钥小流量数据加密

调试

请求参数

下表仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数

参数
类型
是否必填
示例值
描述
Action
String

AsymmetricEncrypt

要执行的操作,取值:AsymmetricEncrypt。

Version
String

2021-02-18

API的版本,取值:2021-02-18。

KeyringName
String

keyring-test

密钥环名称,长度为 2 - 31 个字符。合法字符:[a-zA-Z0-9-_]

KeyName
String

key-test

主密钥名称,长度为 2 - 31 个字符。合法字符:[a-zA-Z0-9-_]

KeyID
String

39a0e7c6-b7dd-4c83-b400-3449bb95403a

主密钥ID,二选一:
KeyringName 和 KeyName
KeyID

Plaintext
String

encryptPlaintext=

加密的明文的Base64编码,取值:[1, 4096]

Algorithm
String

RSAES_OAEP_SHA_256

加密算法,如下枚举之一:
RSAES_OAEP_SHA_256
SM2PKE
加密算法和密钥类型,对应关系

返回参数

下表仅列出本接口特有的返回参数。更多信息请参见返回结构

参数
类型
示例值
描述
KeyID
String

39a0e7c6-b7dd-4c83-b400-3449bb95403a

主密钥唯一标识符,UUID形式

CiphertextBlob
String

43y7grE9TjamX4P7ZOHFbwAAqoNHFtMZ6RNyblKlEhIhrfP6zy034cwJN6MSqFGiDm8oiGqu2Rahs1aKPIcMjaOuodVCE1zYpDFg1QvgOHtVQxkQWhfpE8i8NibiJ1pL8ILgAE+TogQZuIglAoo=

明文加密后的密文,Base64编码

请求示例

POST /?Action=AsymmetricEncrypt&Version=2021-02-18&KeyringName=demo&KeyName=demo&Algorithm=RSAES_OAEP_SHA_256 HTTP/1.1
Host: kms.volcengineapi.com
Content-Type: application/json; charset=UTF-8
X-Date: 20240708T142655Z
X-Content-Sha256: 287e874e******d653b44d21e
Authorization: HMAC-SHA256 Credential=Adfks******wekfwe/20240708/cn-beijing/kms/request, SignedHeaders=host;x-content-sha256;x-date, Signature=47a7d934ff7b37c03938******cd7b8278a40a1057690c401e92246a0e41085f

{
  "Plaintext": "encryptPlaintext=",
}

返回示例

{
  "ResponseMetadata": {
    "RequestId": "202407082227511702362061286618D1",
    "Action": "AsymmetricEncrypt",
    "Version": "2021-02-18",
    "Service": "kms",
    "Region": "cn-beijing"
  },
  "Result": {
    "KeyID": "39a0e7c6-b7dd-4c83-b400-3449bb95403a",
    "CiphertextBlob": "43y7grE9TjamX4P7ZOHFbwAAqoNHFtMZ6RNyblKlEhIhrfP6zy034cwJN6MSqFGiDm8oiGqu2Rahs1aKPIcMjaOuodVCE1zYpDFg1QvgOHtVQxkQWhfpE8i8NibiJ1pL8ILgAE+TogQZuIglAoo="
  }
}

错误码

下表为您列举了该接口与业务逻辑相关的错误码。公共错误码请参见公共错误码文档。

状态码
错误码
错误信息
说明
400
MissingParameter
The request is missing %s parameter.
400
InvalidParameter
The request parameter %s is invalid.
400
InvalidKeyStatus
Current key status: %s does not allow to perform this action
400
InvalidKeyUsage
Current key usage only allows: %s. Please use different keys for encryption/decryption and signing/verification.
403
AccessDenied
User is not authorized to do this action
403
Reject.Throttling.CMK
The request of CMK: %s upper limit is exceeded.
403
KeyMaterialExpire
Key expire in, %s
404
Not Found
Not found %s [%s].
500
UndefinedError
Undefined Internal Error. Pls Contact With Admin.