Creates a customer master key (CMK).
A CMK can be symmetric or asymmetric. Symmetric CMKs are used to generate data keys that can be used to encrypt large amounts of data. You can also use symmetric CMKs to encrypt less than 6 KB of data. For more information, see GenerateDataKey. Asymmetric CMKs are used to encrypt data, decrypt data, generate digital signatures, and verify digital signatures. However, you cannot use asymmetric CMKs to generate data keys.
The following table describes different types of CMKs and the operations that are supported by the CMKs.
CMK category |
CMK type |
Description |
Encryption and decryption |
Signature generation and verification |
---|---|---|---|---|
Symmetric CMK |
Aliyun_AES_256 |
An advanced Encryption Standard (AES) key with a length of 256 bits. |
Supported |
Not supported |
Symmetric CMK |
Aliyun_AES_128 |
An AES key with a length of 128 bits. Only Dedicated KMS supports this CMK type. |
Supported |
Not supported |
Symmetric CMK |
Aliyun_AES_192 |
An AES key with a length of 192 bits. Only Dedicated KMS supports this CMK type. |
Supported |
Not supported |
Symmetric CMK |
Aliyun_SM4 |
SM4 key. |
Supported |
Not supported |
Asymmetric CMK |
RSA_2048 |
A Rivest-Shamir-Adleman (RSA) key with a length of 2,048 bits. |
Supported |
Supported |
Asymmetric CMK |
RSA_3072 |
A RSA key with a length of 3,072 bits. |
Supported |
Supported |
Asymmetric CMK |
EC_P256 |
National Institute of Standards and Technology (NIST) P-256 (secp256r1) . |
Not supported |
Supported |
Asymmetric CMK |
EC_P256K |
Standards for Efficient Cryptography Group (SECG) elliptic curve secp256k1. |
Not supported |
Supported |
Asymmetric CMK |
EC_SM2 |
256-bit elliptic curve over the prime field that is defined in GB/T 32918. |
Supported |
Supported |
- If the value of the KeySpec parameter that is used to create a symmetric CMK is prefixed
with
Aliyun_
, a standard cryptographic algorithm is used, but non-standard ciphertext is generated. An asymmetric CMK can be used to generate standard ciphertext or signatures. -
You can use an RSA CMK to perform one of the two types of operations: encrypt and decrypt data, and generate and verify signatures. You cannot use the RSA CMK to perform both two types of operations.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | CreateKey |
The operation that you want to perform. Set the value to CreateKey. |
Description | String | No | key description example |
The description of the CMK. The description can be 0 to 8,192 characters in length. |
KeySpec | String | No | Aliyun_AES_256 |
The type of the CMK. Valid values:
Note
|
KeyUsage | String | No | ENCRYPT/DECRYPT |
The usage of the CMK. Valid values:
|
Origin | String | No | Aliyun_KMS |
The source of key material. Valid values:
Note
|
ProtectionLevel | String | No | SOFTWARE |
The protection level of the CMK. Valid values:
Note
|
EnableAutomaticRotation | Boolean | No | false |
Specifies whether to enable automatic key rotation. Valid values:
Note If you set the Origin parameter to EXTERNAL or the KeySpec parameter to an asymmetric
CMK type, automatic key rotation is unavailable.
|
RotationInterval | String | No | 365d |
The interval for automatic key rotation. Specify the value in the integer[unit] format. The following units are supported: d (day), h (hour), m (minute), and s (second). For example, you can use either 7d or 604800s to specify a seven-day interval. The interval can range from 7 days to 730 days. Note If you set the EnableAutomaticRotation parameter to true, you must also specify this
parameter. If you set the EnableAutomaticRotation parameter to false, you can leave
this parameter unspecified.
|
For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
KeyMetadata | Struct |
The metadata of the CMK. |
|
Arn | String | acs:kms:cn-qingdao:154035569884****:key/d6bee1cb-2e14-4277-ba6b-73786b21**** |
The Alibaba Cloud Resource Name (ARN) of the CMK. |
AutomaticRotation | String | Disabled |
Indicates whether automatic key rotation is enabled. Valid values:
Note Automatic key rotation is available only for symmetric CMKs.
|
CreationDate | String | 2016-03-25T10:42:40Z |
The time when the CMK was created. The time is displayed in UTC. |
Creator | String | 154035569884**** |
The creator of the CMK. |
DeleteDate | String | 2020-07-06T18:22:03Z |
The time when the CMK is scheduled for deletion. For more information, see ScheduleKeyDeletion. Note This value is returned only when the value of the KeyState parameter is PendingDeletion.
|
Description | String | key description example |
The description of the CMK. |
KeyId | String | d6bee1cb-2e14-4277-ba6b-73786b21**** |
The ID of the CMK. The ID is globally unique. |
KeySpec | String | Aliyun_AES_256 |
The type of the CMK. |
KeyState | String | Enabled |
The status of the CMK. For more information, see Impact of CMK status on API operations. |
KeyUsage | String | ENCRYPT/DECRYPT |
The usage of the CMK. |
LastRotationDate | String | 2019-06-06T18:22:03Z |
The time when the last rotation was performed. The time is displayed in UTC. For a new CMK, the value of this parameter is the time when the initial version of the CMK was generated. |
MaterialExpireTime | String | 2020-07-06T18:22:03Z |
The time when the key material for the CMK expires. The time is displayed in UTC. If the parameter is empty, the key material of the CMK does not expire. |
NextRotationDate | String | 2020-07-06T18:22:03Z |
The time when the next rotation will be performed. Note This value is returned only when the value of the AutomaticRotation parameter is Enabled
or Suspended.
|
Origin | String | Aliyun_KMS |
The source of the key material for the CMK. |
PrimaryKeyVersion | String | 7ce1d081-06cb-42e6-aab6-5c5de030**** |
The ID of the primary key version of the symmetric CMK. Note
|
ProtectionLevel | String | SOFTWARE |
The protection level of the CMK. |
RotationInterval | String | 31536000s |
The period of automatic key rotation. Unit: seconds. The value is in the format of an integer followed by the letter s. For example, if the rotation period is seven days, this parameter is set to 604800s. This value is returned only when the value of the AutomaticRotation parameter is Enabled or Suspended. |
RequestId | String | 36c7e41a-3f2c-45f7-9bdd-d1dc1e7e7e06 |
The ID of the request. |
Examples
Sample requests
https://[Endpoint]/?Action=CreateKey
&<Common request parameters>
Sample success responses
XML
format
<KMS>
<KeyMetadata>
<CreationDate>2021-04-12T06:00:54Z</CreationDate>
<Description></Description>
<KeyId>d6bee1cb-2e14-4277-ba6b-73786b21****</KeyId>
<KeySpec>Aliyun_AES_256</KeySpec>
<KeyState>Enabled</KeyState>
<KeyUsage>ENCRYPT/DECRYPT</KeyUsage>
<PrimaryKeyVersion>7ce1d081-06cb-42e6-aab6-5c5de030****</PrimaryKeyVersion>
<DeleteDate></DeleteDate>
<Creator>154035569884****</Creator>
<Arn>acs:kms:cn-qingdao:154035569884****:key/d6bee1cb-2e14-4277-ba6b-73786b21****</Arn>
<Origin>Aliyun_KMS</Origin>
<MaterialExpireTime></MaterialExpireTime>
<ProtectionLevel>SOFTWARE</ProtectionLevel>
<LastRotationDate>2021-04-12T06:00:54Z</LastRotationDate>
<AutomaticRotation>Disabled</AutomaticRotation>
</KeyMetadata>
<RequestId>36c7e41a-3f2c-45f7-9bdd-d1dc1e7e7e06</RequestId>
</KMS>
JSON
format
{
"KeyMetadata": {
"CreationDate": "2021-04-12T06:00:54Z",
"Description": "",
"KeyId": "d6bee1cb-2e14-4277-ba6b-73786b21****",
"KeySpec": "Aliyun_AES_256",
"KeyState": "Enabled",
"KeyUsage": "ENCRYPT/DECRYPT",
"PrimaryKeyVersion": "7ce1d081-06cb-42e6-aab6-5c5de030****",
"DeleteDate": "",
"Creator": "154035569884****",
"Arn": "acs:kms:cn-qingdao:154035569884****:key/d6bee1cb-2e14-4277-ba6b-73786b21****",
"Origin": "Aliyun_KMS",
"MaterialExpireTime": "",
"ProtectionLevel": "SOFTWARE",
"LastRotationDate": "2021-04-12T06:00:54Z",
"AutomaticRotation": "Disabled"
},
"RequestId": "36c7e41a-3f2c-45f7-9bdd-d1dc1e7e7e06"
}
Error codes
For a list of error codes, visit the API Error Center.