• 沒有找到結果。

AWS Key Management Service

N/A
N/A
Protected

Academic year: 2022

Share "AWS Key Management Service"

Copied!
251
0
0

加載中.... (立即查看全文)

全文

(1)

AWS Key Management Service

API Reference

API Version 2014-11-01

(2)

AWS Key Management Service: API Reference

Copyright © Amazon Web Services, Inc. and/or its affiliates. All rights reserved.

Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's, in any manner that is likely to cause confusion among customers, or in any manner that disparages or discredits Amazon. All other trademarks not owned by Amazon are the property of their respective owners, who may or may not be affiliated with, connected to, or sponsored by Amazon.

(3)

Table of Contents

Welcome ... 1

Actions ... 3

CancelKeyDeletion ... 5

Request Syntax ... 5

Request Parameters ... 5

Response Syntax ... 5

Response Elements ... 6

Errors ... 6

Examples ... 6

See Also ... 7

ConnectCustomKeyStore ... 8

Request Syntax ... 8

Request Parameters ... 8

Response Elements ... 9

Errors ... 9

See Also ... 10

CreateAlias ... 11

Request Syntax ... 11

Request Parameters ... 11

Response Elements ... 12

Errors ... 12

Examples ... 13

See Also ... 14

CreateCustomKeyStore ... 15

Request Syntax ... 15

Request Parameters ... 15

Response Syntax ... 16

Response Elements ... 16

Errors ... 17

See Also ... 18

CreateGrant ... 19

Request Syntax ... 19

Request Parameters ... 20

Response Syntax ... 22

Response Elements ... 22

Errors ... 23

Examples ... 23

See Also ... 24

CreateKey ... 26

Request Syntax ... 27

Request Parameters ... 28

Response Syntax ... 32

Response Elements ... 32

Errors ... 32

Examples ... 34

See Also ... 35

Decrypt ... 36

Request Syntax ... 37

Request Parameters ... 37

Response Syntax ... 38

Response Elements ... 39

Errors ... 39

Examples ... 40

See Also ... 41

(4)

DeleteAlias ... 42

Request Syntax ... 42

Request Parameters ... 42

Response Elements ... 43

Errors ... 43

Examples ... 43

See Also ... 44

DeleteCustomKeyStore ... 45

Request Syntax ... 45

Request Parameters ... 45

Response Elements ... 46

Errors ... 46

See Also ... 47

DeleteImportedKeyMaterial ... 48

Request Syntax ... 48

Request Parameters ... 48

Response Elements ... 49

Errors ... 49

Examples ... 49

See Also ... 50

DescribeCustomKeyStores ... 51

Request Syntax ... 51

Request Parameters ... 51

Response Syntax ... 52

Response Elements ... 53

Errors ... 53

See Also ... 54

DescribeKey ... 55

Request Syntax ... 55

Request Parameters ... 56

Response Syntax ... 56

Response Elements ... 57

Errors ... 57

Examples ... 58

See Also ... 59

DisableKey ... 60

Request Syntax ... 60

Request Parameters ... 60

Response Elements ... 60

Errors ... 61

Examples ... 61

See Also ... 62

DisableKeyRotation ... 63

Request Syntax ... 63

Request Parameters ... 63

Response Elements ... 64

Errors ... 64

Examples ... 64

See Also ... 65

DisconnectCustomKeyStore ... 66

Request Syntax ... 66

Request Parameters ... 66

Response Elements ... 67

Errors ... 67

See Also ... 67

EnableKey ... 69

Request Syntax ... 69

(5)

Request Parameters ... 69

Response Elements ... 69

Errors ... 69

Examples ... 70

See Also ... 71

EnableKeyRotation ... 72

Request Syntax ... 72

Request Parameters ... 72

Response Elements ... 73

Errors ... 73

Examples ... 73

See Also ... 74

Encrypt ... 75

Request Syntax ... 76

Request Parameters ... 76

Response Syntax ... 77

Response Elements ... 78

Errors ... 78

Examples ... 79

See Also ... 80

GenerateDataKey ... 81

Request Syntax ... 82

Request Parameters ... 82

Response Syntax ... 83

Response Elements ... 84

Errors ... 84

Examples ... 85

See Also ... 86

GenerateDataKeyPair ... 87

Request Syntax ... 87

Request Parameters ... 88

Response Syntax ... 89

Response Elements ... 89

Errors ... 90

See Also ... 91

GenerateDataKeyPairWithoutPlaintext ... 92

Request Syntax ... 92

Request Parameters ... 93

Response Syntax ... 94

Response Elements ... 94

Errors ... 95

See Also ... 96

GenerateDataKeyWithoutPlaintext ... 97

Request Syntax ... 97

Request Parameters ... 98

Response Syntax ... 99

Response Elements ... 99

Errors ... 100

Examples ... 101

See Also ... 101

GenerateRandom ... 103

Request Syntax ... 103

Request Parameters ... 103

Response Syntax ... 103

Response Elements ... 104

Errors ... 104

Examples ... 105

(6)

See Also ... 105

GetKeyPolicy ... 106

Request Syntax ... 106

Request Parameters ... 106

Response Syntax ... 107

Response Elements ... 107

Errors ... 107

Examples ... 108

See Also ... 108

GetKeyRotationStatus ... 110

Request Syntax ... 110

Request Parameters ... 110

Response Syntax ... 111

Response Elements ... 111

Errors ... 111

Examples ... 112

See Also ... 112

GetParametersForImport ... 114

Request Syntax ... 114

Request Parameters ... 114

Response Syntax ... 115

Response Elements ... 115

Errors ... 116

Examples ... 117

See Also ... 118

GetPublicKey ... 119

Request Syntax ... 119

Request Parameters ... 119

Response Syntax ... 120

Response Elements ... 120

Errors ... 122

See Also ... 123

ImportKeyMaterial ... 124

Request Syntax ... 124

Request Parameters ... 125

Response Elements ... 126

Errors ... 126

Examples ... 127

See Also ... 128

ListAliases ... 129

Request Syntax ... 129

Request Parameters ... 129

Response Syntax ... 130

Response Elements ... 130

Errors ... 131

Examples ... 131

See Also ... 133

ListGrants ... 134

Request Syntax ... 134

Request Parameters ... 134

Response Syntax ... 135

Response Elements ... 136

Errors ... 136

Examples ... 137

See Also ... 139

ListKeyPolicies ... 140

Request Syntax ... 140

(7)

Request Parameters ... 140

Response Syntax ... 141

Response Elements ... 141

Errors ... 142

Examples ... 142

See Also ... 143

ListKeys ... 144

Request Syntax ... 144

Request Parameters ... 144

Response Syntax ... 145

Response Elements ... 145

Errors ... 145

Examples ... 146

See Also ... 147

ListResourceTags ... 148

Request Syntax ... 148

Request Parameters ... 148

Response Syntax ... 149

Response Elements ... 149

Errors ... 150

Examples ... 150

See Also ... 151

ListRetirableGrants ... 152

Request Syntax ... 152

Request Parameters ... 152

Response Syntax ... 153

Response Elements ... 153

Errors ... 154

Examples ... 155

See Also ... 155

PutKeyPolicy ... 157

Request Syntax ... 157

Request Parameters ... 157

Response Elements ... 158

Errors ... 158

Examples ... 159

See Also ... 161

ReEncrypt ... 162

Request Syntax ... 163

Request Parameters ... 163

Response Syntax ... 166

Response Elements ... 166

Errors ... 166

Examples ... 168

See Also ... 169

ReplicateKey ... 170

Request Syntax ... 171

Request Parameters ... 171

Response Syntax ... 173

Response Elements ... 174

Errors ... 175

See Also ... 176

RetireGrant ... 177

Request Syntax ... 177

Request Parameters ... 177

Response Elements ... 178

Errors ... 178

(8)

Examples ... 179

See Also ... 179

RevokeGrant ... 181

Request Syntax ... 181

Request Parameters ... 181

Response Elements ... 182

Errors ... 182

Examples ... 183

See Also ... 183

ScheduleKeyDeletion ... 184

Request Syntax ... 184

Request Parameters ... 184

Response Syntax ... 185

Response Elements ... 185

Errors ... 186

Examples ... 187

See Also ... 187

Sign ... 189

Request Syntax ... 189

Request Parameters ... 189

Response Syntax ... 191

Response Elements ... 191

Errors ... 192

See Also ... 193

TagResource ... 194

Request Syntax ... 194

Request Parameters ... 194

Response Elements ... 195

Errors ... 195

Examples ... 196

See Also ... 196

UntagResource ... 198

Request Syntax ... 198

Request Parameters ... 198

Response Elements ... 199

Errors ... 199

Examples ... 200

See Also ... 200

UpdateAlias ... 201

Request Syntax ... 201

Request Parameters ... 201

Response Elements ... 202

Errors ... 202

Examples ... 203

See Also ... 204

UpdateCustomKeyStore ... 205

Request Syntax ... 205

Request Parameters ... 206

Response Elements ... 207

Errors ... 207

See Also ... 208

UpdateKeyDescription ... 210

Request Syntax ... 210

Request Parameters ... 210

Response Elements ... 211

Errors ... 211

Examples ... 211

(9)

See Also ... 212

UpdatePrimaryRegion ... 213

Request Syntax ... 214

Request Parameters ... 214

Response Elements ... 214

Errors ... 214

See Also ... 215

Verify ... 216

Request Syntax ... 216

Request Parameters ... 216

Response Syntax ... 218

Response Elements ... 218

Errors ... 219

See Also ... 220

Data Types ... 221

AliasListEntry ... 222

Contents ... 222

See Also ... 222

CustomKeyStoresListEntry ... 224

Contents ... 224

See Also ... 226

GrantConstraints ... 227

Contents ... 227

See Also ... 227

GrantListEntry ... 228

Contents ... 228

See Also ... 229

KeyListEntry ... 230

Contents ... 230

See Also ... 230

KeyMetadata ... 231

Contents ... 231

See Also ... 235

MultiRegionConfiguration ... 236

Contents ... 236

See Also ... 236

MultiRegionKey ... 237

Contents ... 237

See Also ... 237

Tag ... 238

Contents ... 238

See Also ... 238

Common Parameters ... 239

Common Errors ... 241

(10)

Welcome

AWS Key Management Service (AWS KMS) is an encryption and key management web service. This guide describes the AWS KMS operations that you can call programmatically. For general information about AWS KMS, see the AWS Key Management Service Developer Guide.

NoteAWS KMS is replacing the term customer master key (CMK) with AWS KMS key and KMS key. The concept has not changed. To prevent breaking changes, AWS KMS is keeping some variations of this term.

AWS provides SDKs that consist of libraries and sample code for various programming languages and platforms (Java, Ruby, .Net, macOS, Android, etc.). The SDKs provide a convenient way to create programmatic access to AWS KMS and other AWS services. For example, the SDKs take care of tasks such as signing requests (see below), managing errors, and retrying requests automatically. For more information about the AWS SDKs, including how to download and install them, see Tools for Amazon Web Services.

We recommend that you use the AWS SDKs to make programmatic API calls to AWS KMS.

If you need to use FIPS 140-2 validated cryptographic modules when communicating with AWS, use the FIPS endpoint in your preferred AWS Region. For more information about the available FIPS endpoints, see Service endpoints in the AWS Key Management Service topic of the Amazon Web Services General Reference.

Clients must support TLS (Transport Layer Security) 1.0. We recommend TLS 1.2. Clients must also support cipher suites with Perfect Forward Secrecy (PFS) such as Ephemeral Diffie-Hellman (DHE) or Elliptic Curve Ephemeral Diffie-Hellman (ECDHE). Most modern systems such as Java 7 and later support these modes.

Signing Requests

Requests must be signed by using an access key ID and a secret access key. We strongly recommend that you do not use your AWS account (root) access key ID and secret key for everyday work with AWS KMS.

Instead, use the access key ID and secret access key for an IAM user. You can also use the AWS Security Token Service to generate temporary security credentials that you can use to sign requests.

All AWS KMS operations require Signature Version 4.

Logging API Requests

AWS KMS supports AWS CloudTrail, a service that logs AWS API calls and related events for your AWS account and delivers them to an Amazon S3 bucket that you specify. By using the information collected by CloudTrail, you can determine what requests were made to AWS KMS, who made the request, when it was made, and so on. To learn more about CloudTrail, including how to turn it on and find your log files, see the AWS CloudTrail User Guide.

Additional Resources

For more information about credentials and request signing, see the following:

• AWS Security Credentials - This topic provides general information about the types of credentials used to access AWS.

• Temporary Security Credentials - This section of the IAM User Guide describes how to create and use temporary security credentials.

• Signature Version 4 Signing Process - This set of topics walks you through the process of signing a request using an access key ID and a secret access key.

(11)

Commonly Used API Operations

Of the API operations discussed in this guide, the following will prove the most useful for most applications. You will likely perform operations other than these, such as creating keys and assigning policies, by using the console.

• Encrypt (p. 75)

• Decrypt (p. 36)

• GenerateDataKey (p. 81)

• GenerateDataKeyWithoutPlaintext (p. 97)

This document was last published on March 6, 2022.

(12)

Actions

The following actions are supported:

• CancelKeyDeletion (p. 5)

• ConnectCustomKeyStore (p. 8)

• CreateAlias (p. 11)

• CreateCustomKeyStore (p. 15)

• CreateGrant (p. 19)

• CreateKey (p. 26)

• Decrypt (p. 36)

• DeleteAlias (p. 42)

• DeleteCustomKeyStore (p. 45)

• DeleteImportedKeyMaterial (p. 48)

• DescribeCustomKeyStores (p. 51)

• DescribeKey (p. 55)

• DisableKey (p. 60)

• DisableKeyRotation (p. 63)

• DisconnectCustomKeyStore (p. 66)

• EnableKey (p. 69)

• EnableKeyRotation (p. 72)

• Encrypt (p. 75)

• GenerateDataKey (p. 81)

• GenerateDataKeyPair (p. 87)

• GenerateDataKeyPairWithoutPlaintext (p. 92)

• GenerateDataKeyWithoutPlaintext (p. 97)

• GenerateRandom (p. 103)

• GetKeyPolicy (p. 106)

• GetKeyRotationStatus (p. 110)

• GetParametersForImport (p. 114)

• GetPublicKey (p. 119)

• ImportKeyMaterial (p. 124)

• ListAliases (p. 129)

• ListGrants (p. 134)

• ListKeyPolicies (p. 140)

• ListKeys (p. 144)

• ListResourceTags (p. 148)

• ListRetirableGrants (p. 152)

• PutKeyPolicy (p. 157)

• ReEncrypt (p. 162)

• ReplicateKey (p. 170)

• RetireGrant (p. 177)

• RevokeGrant (p. 181)

• ScheduleKeyDeletion (p. 184)

(13)

• Sign (p. 189)

• TagResource (p. 194)

• UntagResource (p. 198)

• UpdateAlias (p. 201)

• UpdateCustomKeyStore (p. 205)

• UpdateKeyDescription (p. 210)

• UpdatePrimaryRegion (p. 213)

• Verify (p. 216)

(14)

CancelKeyDeletion

CancelKeyDeletion

Cancels the deletion of a KMS key. When this operation succeeds, the key state of the KMS key is Disabled. To enable the KMS key, use EnableKey (p. 69).

For more information about scheduling and canceling deletion of a KMS key, see Deleting KMS keys in the AWS Key Management Service Developer Guide.

The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of AWS KMS keys in the AWS Key Management Service Developer Guide.

Cross-account use: No. You cannot perform this operation on a KMS key in a different AWS account.

Required permissions: kms:CancelKeyDeletion (key policy) Related operations: ScheduleKeyDeletion (p. 184)

Request Syntax

{ "KeyId": "string"

}

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters (p. 239).

The request accepts the following data in JSON format.

NoteIn the following list, the required parameters are described first.

KeyId (p. 5)

Identifies the KMS key whose deletion is being canceled.

Specify the key ID or key ARN of the KMS key.

For example:

• Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab

• Key ARN: arn:aws:kms:us-

east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys (p. 144) or DescribeKey (p. 55).

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Required: Yes

Response Syntax

{

(15)

Response Elements

"KeyId": "string"

}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

KeyId (p. 5)

The Amazon Resource Name (key ARN) of the KMS key whose deletion is canceled.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 241).

DependencyTimeoutException

The system timed out while trying to fulfill the request. The request can be retried.

HTTP Status Code: 500 InvalidArnException

The request was rejected because a specified ARN, or an ARN in a key policy, is not valid.

HTTP Status Code: 400 KMSInternalException

The request was rejected because an internal exception occurred. The request can be retried.

HTTP Status Code: 500 KMSInvalidStateException

The request was rejected because the state of the specified resource is not valid for this request.

For more information about how key state affects the use of a KMS key, see Key state: Effect on your KMS key in the AWS Key Management Service Developer Guide .

HTTP Status Code: 400 NotFoundException

The request was rejected because the specified entity or resource could not be found.

HTTP Status Code: 400

Examples

Example Request

The following example is formatted for legibility.

(16)

See Also

POST / HTTP/1.1

Host: kms.us-east-2.amazonaws.com Content-Length: 48

X-Amz-Target: TrentService.CancelKeyDeletion X-Amz-Date: 20161025T182658Z

Content-Type: application/x-amz-json-1.1 Authorization: AWS4-HMAC-SHA256\

Credential=AKIAI44QH8DHBEXAMPLE/20161025/us-east-2/kms/aws4_request,\

SignedHeaders=content-type;host;x-amz-date;x-amz-target,\

Signature=1a600d3edf52b2c14bd6fb6fa44c6ca591bdcb02931fd9cac2e8aa66bd52e3bf {"KeyId":"1234abcd-12ab-34cd-56ef-1234567890ab"}

Example Response

This example illustrates one usage of CancelKeyDeletion.

HTTP/1.1 200 OK Server: Server

Date: Tue, 25 Oct 2016 18:27:01 GMT Content-Type: application/x-amz-json-1.1 Content-Length: 87

Connection: keep-alive

x-amzn-RequestId: 9f3b3cb8-9ae0-11e6-ac6b-03478315fc57

{"KeyId":"arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"}

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(17)

ConnectCustomKeyStore

ConnectCustomKeyStore

Connects or reconnects a custom key store to its associated AWS CloudHSM cluster.

The custom key store must be connected before you can create KMS keys in the key store or use the KMS keys it contains. You can disconnect and reconnect a custom key store at any time.

To connect a custom key store, its associated AWS CloudHSM cluster must have at least one active HSM.

To get the number of active HSMs in a cluster, use the DescribeClusters operation. To add HSMs to the cluster, use the CreateHsm operation. Also, the kmsuser crypto user (CU) must not be logged into the cluster. This prevents AWS KMS from using this account to log in.

The connection process can take an extended amount of time to complete; up to 20 minutes. This operation starts the connection process, but it does not wait for it to complete. When it succeeds, this operation quickly returns an HTTP 200 response and a JSON object with no properties. However, this response does not indicate that the custom key store is connected. To get the connection state of the custom key store, use the DescribeCustomKeyStores (p. 51) operation.

During the connection process, AWS KMS finds the AWS CloudHSM cluster that is associated with the custom key store, creates the connection infrastructure, connects to the cluster, logs into the AWS CloudHSM client as the kmsuser CU, and rotates its password.

The ConnectCustomKeyStore operation might fail for various reasons. To find the reason, use the DescribeCustomKeyStores (p. 51) operation and see the ConnectionErrorCode in the response. For help interpreting the ConnectionErrorCode, see CustomKeyStoresListEntry (p. 224).

To fix the failure, use the DisconnectCustomKeyStore (p. 66) operation to disconnect the custom key store, correct the error, use the UpdateCustomKeyStore (p. 205) operation if necessary, and then use ConnectCustomKeyStore again.

If you are having trouble connecting or disconnecting a custom key store, see Troubleshooting a Custom Key Store in the AWS Key Management Service Developer Guide.

Cross-account use: No. You cannot perform this operation on a custom key store in a different AWS account.

Required permissions: kms:ConnectCustomKeyStore (IAM policy) Related operations

• CreateCustomKeyStore (p. 15)

• DeleteCustomKeyStore (p. 45)

• DescribeCustomKeyStores (p. 51)

• DisconnectCustomKeyStore (p. 66)

• UpdateCustomKeyStore (p. 205)

Request Syntax

{

"CustomKeyStoreId": "string"

}

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters (p. 239).

(18)

Response Elements

The request accepts the following data in JSON format.

NoteIn the following list, the required parameters are described first.

CustomKeyStoreId (p. 8)

Enter the key store ID of the custom key store that you want to connect. To find the ID of a custom key store, use the DescribeCustomKeyStores (p. 51) operation.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Required: Yes

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 241).

CloudHsmClusterInvalidConfigurationException

The request was rejected because the associated AWS CloudHSM cluster did not meet the configuration requirements for a custom key store.

• The cluster must be configured with private subnets in at least two different Availability Zones in the Region.

• The security group for the cluster (cloudhsm-cluster-<cluster-id>-sg) must include inbound rules and outbound rules that allow TCP traffic on ports 2223-2225. The Source in the inbound rules and the Destination in the outbound rules must match the security group ID. These rules are set by default when you create the cluster. Do not delete or change them. To get information about a particular security group, use the DescribeSecurityGroups operation.

• The cluster must contain at least as many HSMs as the operation requires. To add HSMs, use the AWS CloudHSM CreateHsm operation.

For the CreateCustomKeyStore (p. 15), UpdateCustomKeyStore (p. 205), and

CreateKey (p. 26) operations, the AWS CloudHSM cluster must have at least two active HSMs, each in a different Availability Zone. For the ConnectCustomKeyStore (p. 8) operation, the AWS CloudHSM must contain at least one active HSM.

For information about the requirements for an AWS CloudHSM cluster that is associated with a custom key store, see Assemble the Prerequisites in the AWS Key Management Service Developer Guide. For information about creating a private subnet for an AWS CloudHSM cluster, see Create a Private Subnet in the AWS CloudHSM User Guide. For information about cluster security groups, see Configure a Default Security Group in the AWS CloudHSM User Guide .

HTTP Status Code: 400

CloudHsmClusterNotActiveException

The request was rejected because the AWS CloudHSM cluster that is associated with the custom key store is not active. Initialize and activate the cluster and try the command again. For detailed instructions, see Getting Started in the AWS CloudHSM User Guide.

HTTP Status Code: 400

(19)

See Also

CustomKeyStoreInvalidStateException

The request was rejected because of the ConnectionState of the custom key store. To get the ConnectionState of a custom key store, use the DescribeCustomKeyStores (p. 51) operation.

This exception is thrown under the following conditions:

• You requested the CreateKey (p. 26) or GenerateRandom (p. 103) operation in a custom key store that is not connected. These operations are valid only when the custom key store ConnectionState is CONNECTED.

• You requested the UpdateCustomKeyStore (p. 205) or DeleteCustomKeyStore (p. 45)

operation on a custom key store that is not disconnected. This operation is valid only when the custom key store ConnectionState is DISCONNECTED.

• You requested the ConnectCustomKeyStore (p. 8) operation on a custom key store with a ConnectionState of DISCONNECTING or FAILED. This operation is valid for all other ConnectionState values.

HTTP Status Code: 400

CustomKeyStoreNotFoundException

The request was rejected because AWS KMS cannot find a custom key store with the specified key store name or ID.

HTTP Status Code: 400 KMSInternalException

The request was rejected because an internal exception occurred. The request can be retried.

HTTP Status Code: 500

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(20)

CreateAlias

CreateAlias

Creates a friendly name for a KMS key.

NoteAdding, deleting, or updating an alias can allow or deny permission to the KMS key. For details, see ABAC in AWS KMS in the AWS Key Management Service Developer Guide.

You can use an alias to identify a KMS key in the AWS KMS console, in the DescribeKey (p. 55) operation and in cryptographic operations, such as Encrypt (p. 75) and GenerateDataKey (p. 81).

You can also change the KMS key that's associated with the alias (UpdateAlias (p. 201)) or delete the alias (DeleteAlias (p. 42)) at any time. These operations don't affect the underlying KMS key.

You can associate the alias with any customer managed key in the same AWS Region. Each alias is associated with only one KMS key at a time, but a KMS key can have multiple aliases. A valid KMS key is required. You can't create an alias without a KMS key.

The alias must be unique in the account and Region, but you can have aliases with the same name in different Regions. For detailed information about aliases, see Using aliases in the AWS Key Management Service Developer Guide.

This operation does not return a response. To get the alias that you created, use the ListAliases (p. 129) operation.

The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of AWS KMS keys in the AWS Key Management Service Developer Guide.

Cross-account use: No. You cannot perform this operation on an alias in a different AWS account.

Required permissions

• kms:CreateAlias on the alias (IAM policy).

• kms:CreateAlias on the KMS key (key policy).

For details, see Controlling access to aliases in the AWS Key Management Service Developer Guide.

Related operations:

• DeleteAlias (p. 42)

• ListAliases (p. 129)

• UpdateAlias (p. 201)

Request Syntax

{

"AliasName": "string", "TargetKeyId": "string"

}

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters (p. 239).

The request accepts the following data in JSON format.

(21)

Response Elements

NoteIn the following list, the required parameters are described first.

AliasName (p. 11)

Specifies the alias name. This value must begin with alias/ followed by a name, such as alias/

ExampleAlias.

The AliasName value must be string of 1-256 characters. It can contain only alphanumeric characters, forward slashes (/), underscores (_), and dashes (-). The alias name cannot begin with alias/aws/. The alias/aws/ prefix is reserved for AWS managed keys.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: alias/^[a-zA-Z0-9/_-]+$

Required: Yes TargetKeyId (p. 11)

Associates the alias with the specified customer managed key. The KMS key must be in the same AWS Region.

A valid key ID is required. If you supply a null or empty string value, this operation returns an error.

For help finding the key ID and ARN, see Finding the Key ID and ARN in the AWS Key Management Service Developer Guide .

Specify the key ID or key ARN of the KMS key.

For example:

• Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab

• Key ARN: arn:aws:kms:us-

east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys (p. 144) or DescribeKey (p. 55).

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Required: Yes

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 241).

AlreadyExistsException

The request was rejected because it attempted to create a resource that already exists.

HTTP Status Code: 400

(22)

Examples

DependencyTimeoutException

The system timed out while trying to fulfill the request. The request can be retried.

HTTP Status Code: 500 InvalidAliasNameException

The request was rejected because the specified alias name is not valid.

HTTP Status Code: 400 KMSInternalException

The request was rejected because an internal exception occurred. The request can be retried.

HTTP Status Code: 500 KMSInvalidStateException

The request was rejected because the state of the specified resource is not valid for this request.

For more information about how key state affects the use of a KMS key, see Key state: Effect on your KMS key in the AWS Key Management Service Developer Guide .

HTTP Status Code: 400 LimitExceededException

The request was rejected because a quota was exceeded. For more information, see Quotas in the AWS Key Management Service Developer Guide.

HTTP Status Code: 400 NotFoundException

The request was rejected because the specified entity or resource could not be found.

HTTP Status Code: 400

Examples

Example Request

The following example is formatted for legibility.

POST / HTTP/1.1

Host: kms.us-west-2.amazonaws.com Content-Length: 87

X-Amz-Target: TrentService.CreateAlias X-Amz-Date: 20160517T204220Z

Content-Type: application/x-amz-json-1.1 Authorization: AWS4-HMAC-SHA256\

Credential=AKIAI44QH8DHBEXAMPLE/20160517/us-west-2/kms/aws4_request,\

SignedHeaders=content-type;host;x-amz-date;x-amz-target,\

Signature=ca7bcf1e8d5364dc3f0d881c05bdadf36f498c6c6a8b576a060142d9b2199123 {

"TargetKeyId": "1234abcd-12ab-34cd-56ef-1234567890ab", "AliasName": "alias/ExampleAlias"

}

(23)

See Also

Example Response

This example illustrates one usage of CreateAlias.

HTTP/1.1 200 OK Server: Server

Date: Tue, 17 May 2016 20:42:25 GMT Content-Type: application/x-amz-json-1.1 Content-Length: 0

Connection: keep-alive

x-amzn-RequestId: dcb07ca7-1c6f-11e6-8540-77c363708b91

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(24)

CreateCustomKeyStore

CreateCustomKeyStore

Creates a custom key store that is associated with an AWS CloudHSM cluster that you own and manage.

This operation is part of the Custom Key Store feature feature in AWS KMS, which combines the

convenience and extensive integration of AWS KMS with the isolation and control of a single-tenant key store.

Before you create the custom key store, you must assemble the required elements, including an AWS CloudHSM cluster that fulfills the requirements for a custom key store. For details about the required elements, see Assemble the Prerequisites in the AWS Key Management Service Developer Guide.

When the operation completes successfully, it returns the ID of the new custom key store. Before you can use your new custom key store, you need to use the ConnectCustomKeyStore (p. 8) operation to connect the new key store to its AWS CloudHSM cluster. Even if you are not going to use your custom key store immediately, you might want to connect it to verify that all settings are correct and then disconnect it until you are ready to use it.

For help with failures, see Troubleshooting a Custom Key Store in the AWS Key Management Service Developer Guide.

Cross-account use: No. You cannot perform this operation on a custom key store in a different AWS account.

Required permissions: kms:CreateCustomKeyStore (IAM policy).

Related operations:

• ConnectCustomKeyStore (p. 8)

• DeleteCustomKeyStore (p. 45)

• DescribeCustomKeyStores (p. 51)

• DisconnectCustomKeyStore (p. 66)

• UpdateCustomKeyStore (p. 205)

Request Syntax

{ "CloudHsmClusterId": "string", "CustomKeyStoreName": "string", "KeyStorePassword": "string", "TrustAnchorCertificate": "string"

}

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters (p. 239).

The request accepts the following data in JSON format.

NoteIn the following list, the required parameters are described first.

(25)

Response Syntax

CloudHsmClusterId (p. 15)

Identifies the AWS CloudHSM cluster for the custom key store. Enter the cluster ID of any active AWS CloudHSM cluster that is not already associated with a custom key store. To find the cluster ID, use the DescribeClusters operation.

Type: String

Length Constraints: Minimum length of 19. Maximum length of 24.

Required: Yes

CustomKeyStoreName (p. 15)

Specifies a friendly name for the custom key store. The name must be unique in your AWS account.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Required: Yes

KeyStorePassword (p. 15)

Enter the password of the kmsuser crypto user (CU) account in the specified AWS CloudHSM cluster.

AWS KMS logs into the cluster as this user to manage key material on your behalf.

The password must be a string of 7 to 32 characters. Its value is case sensitive.

This parameter tells AWS KMS the kmsuser account password; it does not change the password in the AWS CloudHSM cluster.

Type: String

Length Constraints: Minimum length of 7. Maximum length of 32.

Required: Yes

TrustAnchorCertificate (p. 15)

Enter the content of the trust anchor certificate for the cluster. This is the content of the customerCA.crt file that you created when you initialized the cluster.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 5000.

Required: Yes

Response Syntax

{

"CustomKeyStoreId": "string"

}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

(26)

Errors

The following data is returned in JSON format by the service.

CustomKeyStoreId (p. 16)

A unique identifier for the new custom key store.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 241).

CloudHsmClusterInUseException

The request was rejected because the specified AWS CloudHSM cluster is already associated with a custom key store or it shares a backup history with a cluster that is associated with a custom key store. Each custom key store must be associated with a different AWS CloudHSM cluster.

Clusters that share a backup history have the same cluster certificate. To view the cluster certificate of a cluster, use the DescribeClusters operation.

HTTP Status Code: 400

CloudHsmClusterInvalidConfigurationException

The request was rejected because the associated AWS CloudHSM cluster did not meet the configuration requirements for a custom key store.

• The cluster must be configured with private subnets in at least two different Availability Zones in the Region.

• The security group for the cluster (cloudhsm-cluster-<cluster-id>-sg) must include inbound rules and outbound rules that allow TCP traffic on ports 2223-2225. The Source in the inbound rules and the Destination in the outbound rules must match the security group ID. These rules are set by default when you create the cluster. Do not delete or change them. To get information about a particular security group, use the DescribeSecurityGroups operation.

• The cluster must contain at least as many HSMs as the operation requires. To add HSMs, use the AWS CloudHSM CreateHsm operation.

For the CreateCustomKeyStore (p. 15), UpdateCustomKeyStore (p. 205), and

CreateKey (p. 26) operations, the AWS CloudHSM cluster must have at least two active HSMs, each in a different Availability Zone. For the ConnectCustomKeyStore (p. 8) operation, the AWS CloudHSM must contain at least one active HSM.

For information about the requirements for an AWS CloudHSM cluster that is associated with a custom key store, see Assemble the Prerequisites in the AWS Key Management Service Developer Guide. For information about creating a private subnet for an AWS CloudHSM cluster, see Create a Private Subnet in the AWS CloudHSM User Guide. For information about cluster security groups, see Configure a Default Security Group in the AWS CloudHSM User Guide .

HTTP Status Code: 400

CloudHsmClusterNotActiveException

The request was rejected because the AWS CloudHSM cluster that is associated with the custom key store is not active. Initialize and activate the cluster and try the command again. For detailed instructions, see Getting Started in the AWS CloudHSM User Guide.

HTTP Status Code: 400

(27)

See Also

CloudHsmClusterNotFoundException

The request was rejected because AWS KMS cannot find the AWS CloudHSM cluster with the specified cluster ID. Retry the request with a different cluster ID.

HTTP Status Code: 400

CustomKeyStoreNameInUseException

The request was rejected because the specified custom key store name is already assigned to another custom key store in the account. Try again with a custom key store name that is unique in the account.

HTTP Status Code: 400 IncorrectTrustAnchorException

The request was rejected because the trust anchor certificate in the request is not the trust anchor certificate for the specified AWS CloudHSM cluster.

When you initialize the cluster, you create the trust anchor certificate and save it in the customerCA.crt file.

HTTP Status Code: 400 KMSInternalException

The request was rejected because an internal exception occurred. The request can be retried.

HTTP Status Code: 500

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(28)

CreateGrant

CreateGrant

Adds a grant to a KMS key.

A grant is a policy instrument that allows AWS principals to use KMS keys in cryptographic operations.

It also can allow them to view a KMS key (DescribeKey (p. 55)) and create and manage grants. When authorizing access to a KMS key, grants are considered along with key policies and IAM policies. Grants are often used for temporary permissions because you can create one, use its permissions, and delete it without changing your key policies or IAM policies.

For detailed information about grants, including grant terminology, see Grants in AWS KMS in the AWS Key Management Service Developer Guide . For examples of working with grants in several programming languages, see Programming grants.

The CreateGrant operation returns a GrantToken and a GrantId.

• When you create, retire, or revoke a grant, there might be a brief delay, usually less than five minutes, until the grant is available throughout AWS KMS. This state is known as eventual consistency. Once the grant has achieved eventual consistency, the grantee principal can use the permissions in the grant without identifying the grant.

However, to use the permissions in the grant immediately, use the GrantToken that CreateGrant returns. For details, see Using a grant token in the AWS Key Management Service Developer Guide .

• The CreateGrant operation also returns a GrantId. You can use the GrantId and a key identifier to identify the grant in the RetireGrant (p. 177) and RevokeGrant (p. 181) operations. To find the grant ID, use the ListGrants (p. 134) or ListRetirableGrants (p. 152) operations.

The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of AWS KMS keys in the AWS Key Management Service Developer Guide.

Cross-account use: Yes. To perform this operation on a KMS key in a different AWS account, specify the key ARN in the value of the KeyId parameter.

Required permissions: kms:CreateGrant (key policy) Related operations:

• ListGrants (p. 134)

• ListRetirableGrants (p. 152)

• RetireGrant (p. 177)

• RevokeGrant (p. 181)

Request Syntax

{

"Constraints": {

"EncryptionContextEquals": { "string" : "string"

},

"EncryptionContextSubset": { "string" : "string"

} },

"GranteePrincipal": "string", "GrantTokens": [ "string" ], "KeyId": "string",

(29)

Request Parameters

"Name": "string",

"Operations": [ "string" ], "RetiringPrincipal": "string"

}

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters (p. 239).

The request accepts the following data in JSON format.

NoteIn the following list, the required parameters are described first.

GranteePrincipal (p. 19)

The identity that gets the permissions specified in the grant.

To specify the principal, use the Amazon Resource Name (ARN) of an AWS principal. Valid AWS principals include AWS accounts (root), IAM users, IAM roles, federated users, and assumed role users. For examples of the ARN syntax to use for specifying a principal, see AWS Identity and Access Management (IAM) in the Example ARNs section of the AWS General Reference.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^[\w+=,.@:/-]+$

Required: Yes KeyId (p. 19)

Identifies the KMS key for the grant. The grant gives principals permission to use this KMS key.

Specify the key ID or key ARN of the KMS key. To specify a KMS key in a different AWS account, you must use the key ARN.

For example:

• Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab

• Key ARN: arn:aws:kms:us-

east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys (p. 144) or DescribeKey (p. 55).

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Required: Yes Operations (p. 19)

A list of operations that the grant permits.

The operation must be supported on the KMS key. For example, you cannot create a grant for a symmetric KMS key that allows the Sign (p. 189) operation, or a grant for an asymmetric KMS key that allows the GenerateDataKey (p. 81) operation. If you try, AWS KMS returns a

ValidationError exception. For details, see Grant operations in the AWS Key Management Service Developer Guide.

(30)

Request Parameters

Type: Array of strings

Valid Values: Decrypt | Encrypt | GenerateDataKey |

GenerateDataKeyWithoutPlaintext | ReEncryptFrom | ReEncryptTo | Sign

| Verify | GetPublicKey | CreateGrant | RetireGrant | DescribeKey | GenerateDataKeyPair | GenerateDataKeyPairWithoutPlaintext

Required: Yes Constraints (p. 19)

Specifies a grant constraint.

AWS KMS supports the EncryptionContextEquals and EncryptionContextSubset grant constraints. Each constraint value can include up to 8 encryption context pairs. The encryption context value in each constraint cannot exceed 384 characters.

These grant constraints allow the permissions in the grant only when the encryption context in the request matches (EncryptionContextEquals) or includes (EncryptionContextSubset) the encryption context specified in this structure. For information about grant constraints, see Using grant constraints in the AWS Key Management Service Developer Guide. For more information about encryption context, see Encryption Context in the AWS Key Management Service Developer Guide . The encryption context grant constraints are supported only on operations that include an

encryption context. You cannot use an encryption context grant constraint for cryptographic operations with asymmetric KMS keys or for management operations, such as DescribeKey (p. 55) or RetireGrant (p. 177).

Type: GrantConstraints (p. 227) object Required: No

GrantTokens (p. 19) A list of grant tokens.

Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the AWS Key Management Service Developer Guide.

Type: Array of strings

Array Members: Minimum number of 0 items. Maximum number of 10 items.

Length Constraints: Minimum length of 1. Maximum length of 8192.

Required: No Name (p. 19)

A friendly name for the grant. Use this value to prevent the unintended creation of duplicate grants when retrying this request.

When this value is absent, all CreateGrant requests result in a new grant with a unique GrantId even if all the supplied parameters are identical. This can result in unintended duplicates when you retry the CreateGrant request.

When this value is present, you can retry a CreateGrant request with identical parameters; if the grant already exists, the original GrantId is returned without creating a new grant. Note that the returned grant token is unique with every CreateGrant request, even when a duplicate GrantId is returned. All grant tokens for the same grant ID can be used interchangeably.

Type: String

(31)

Response Syntax

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^[a-zA-Z0-9:/_-]+$

Required: No RetiringPrincipal (p. 19)

The principal that has permission to use the RetireGrant (p. 177) operation to retire the grant.

To specify the principal, use the Amazon Resource Name (ARN) of an AWS principal. Valid AWS principals include AWS accounts (root), IAM users, federated users, and assumed role users.

For examples of the ARN syntax to use for specifying a principal, see AWS Identity and Access Management (IAM) in the Example ARNs section of the AWS General Reference.

The grant determines the retiring principal. Other principals might have permission to retire the grant or revoke the grant. For details, see RevokeGrant (p. 181) and Retiring and revoking grants in the AWS Key Management Service Developer Guide.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^[\w+=,.@:/-]+$

Required: No

Response Syntax

{ "GrantId": "string", "GrantToken": "string"

}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

GrantId (p. 22)

The unique identifier for the grant.

You can use the GrantId in a ListGrants (p. 134), RetireGrant (p. 177), or RevokeGrant (p. 181) operation.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

GrantToken (p. 22) The grant token.

Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the AWS Key Management Service Developer Guide.

(32)

Errors

Type: String

Length Constraints: Minimum length of 1. Maximum length of 8192.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 241).

DependencyTimeoutException

The system timed out while trying to fulfill the request. The request can be retried.

HTTP Status Code: 500 DisabledException

The request was rejected because the specified KMS key is not enabled.

HTTP Status Code: 400 InvalidArnException

The request was rejected because a specified ARN, or an ARN in a key policy, is not valid.

HTTP Status Code: 400 InvalidGrantTokenException

The request was rejected because the specified grant token is not valid.

HTTP Status Code: 400 KMSInternalException

The request was rejected because an internal exception occurred. The request can be retried.

HTTP Status Code: 500 KMSInvalidStateException

The request was rejected because the state of the specified resource is not valid for this request.

For more information about how key state affects the use of a KMS key, see Key state: Effect on your KMS key in the AWS Key Management Service Developer Guide .

HTTP Status Code: 400 LimitExceededException

The request was rejected because a quota was exceeded. For more information, see Quotas in the AWS Key Management Service Developer Guide.

HTTP Status Code: 400 NotFoundException

The request was rejected because the specified entity or resource could not be found.

HTTP Status Code: 400

Examples

The following examples are formatted for legibility.

(33)

See Also

Example Request

This example illustrates one usage of CreateGrant.

POST / HTTP/1.1

Host: kms.us-east-2.amazonaws.com Content-Length: 176

X-Amz-Target: TrentService.CreateGrant X-Amz-Date: 20161031T202851Z

Content-Type: application/x-amz-json-1.1 Authorization: AWS4-HMAC-SHA256\

Credential=AKIAI44QH8DHBEXAMPLE/20161031/us-east-2/kms/aws4_request,\

SignedHeaders=content-type;host;x-amz-date;x-amz-target,\

Signature=84a2b3b8eb50b9bf34ba844cd5e59649fb315a16b447357ae49bf8b87774c8f7 { "Operations": [

"Encrypt", "Decrypt"

], "GranteePrincipal": "arn:aws:iam::111122223333:role/ExampleRole",

"KeyId": "arn:aws:kms:us-east-2:444455556666:key/1234abcd-12ab-34cd-56ef-1234567890ab"

}

Example Response

This example illustrates one usage of CreateGrant.

HTTP/1.1 200 OK Server: Server

Date: Mon, 31 Oct 2016 20:28:51 GMT Content-Type: application/x-amz-json-1.1 Content-Length: 585

Connection: keep-alive

x-amzn-RequestId: a2d8d452-9fa8-11e6-b30c-dbb8ea4d97c5

{ "GrantId": "0c237476b39f8bc44e45212e08498fbe3151305030726c0590dd8d3e9f3d6a60", "GrantToken":

"AQpAM2RhZTk1MGMyNTk2ZmZmMzEyYWVhOWViN2I1MWM4Mzc0MWFiYjc0ZDE1ODkyNGFlNTIzODZhMzgyZjBlNGY3NiKIAgEBAgB4Pa6VDCWW__MSrqnre1HIN0Grt00ViSSuUjhqOC8OT3YAAADfMIHcBgkqhkiG9w0BBwaggc4wgcsCAQAwgcUGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMmqLyBTAegIn9XlK5AgEQgIGXZQjkBcl1dykDdqZBUQ6L1OfUivQy7JVYO2- ZJP7m6f1g8GzV47HX5phdtONAP7K_HQIflcgpkoCqd_fUnE114mSmiagWkbQ5sqAVV3ov-

VeqgrvMe5ZFEWLMSluvBAqdjHEdMIkHMlhlj4ENZbzBfo9Wxk8b8SnwP4kc4gGivedzFXo- dwN8fxjjq_ZZ9JFOj2ijIbj5FyogDCN0drOfi8RORSEuCEmPvjFRMFAwcmwFkN2NPp89amA"

}

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

(34)

See Also

• AWS SDK for Ruby V3

(35)

CreateKey

CreateKey

Creates a unique customer managed KMS key in your AWS account and Region.

NoteAWS KMS is replacing the term customer master key (CMK) with AWS KMS key and KMS key. The concept has not changed. To prevent breaking changes, AWS KMS is keeping some variations of this term.

You can use the CreateKey operation to create symmetric or asymmetric KMS keys.

Symmetric KMS keys contain a 256-bit symmetric key that never leaves AWS KMS unencrypted. To use the KMS key, you must call AWS KMS. You can use a symmetric KMS key to encrypt and decrypt small amounts of data, but they are typically used to generate data keys and data keys pairs. For details, see GenerateDataKey (p. 81) and GenerateDataKeyPair (p. 87).

Asymmetric KMS keys can contain an RSA key pair or an Elliptic Curve (ECC) key pair. The private key in an asymmetric KMS key never leaves AWS KMS unencrypted. However, you can use the GetPublicKey (p. 119) operation to download the public key so it can be used outside of AWS KMS.

KMS keys with RSA key pairs can be used to encrypt or decrypt data or sign and verify messages (but not both). KMS keys with ECC key pairs can be used only to sign and verify messages.

For information about symmetric and asymmetric KMS keys, see Asymmetric KMS keys in the AWS Key Management Service Developer Guide.

To create different types of KMS keys, use the following guidance:

Asymmetric KMS keys

To create an asymmetric KMS key, use the KeySpec parameter to specify the type of key material in the KMS key. Then, use the KeyUsage parameter to determine whether the KMS key will be used to encrypt and decrypt or sign and verify. You can't change these properties after the KMS key is created.

Symmetric KMS keys

When creating a symmetric KMS key, you don't need to specify the KeySpec or KeyUsage parameters. The default value for KeySpec, SYMMETRIC_DEFAULT, and the default value for KeyUsage, ENCRYPT_DECRYPT, are the only valid values for symmetric KMS keys.

Multi-Region primary keys, Imported key material

To create a multi-Region primary key in the local AWS Region, use the MultiRegion parameter with a value of True. To create a multi-Region replica key, that is, a KMS key with the same key ID and key material as a primary key, but in a different AWS Region, use the ReplicateKey (p. 170) operation. To change a replica key to a primary key, and its primary key to a replica key, use the UpdatePrimaryRegion (p. 213) operation.

This operation supports multi-Region keys, an AWS KMS feature that lets you create multiple interoperable KMS keys in different AWS Regions. Because these KMS keys have the same key ID, key material, and other metadata, you can use them interchangeably to encrypt data in one AWS Region and decrypt it in a different AWS Region without re-encrypting the data or making a cross-Region call. For more information about multi-Region keys, see Multi-Region keys in AWS KMS in the AWS Key Management Service Developer Guide.

You can create symmetric and asymmetric multi-Region keys and multi-Region keys with imported key material. You cannot create multi-Region keys in a custom key store.

(36)

Request Syntax

To import your own key material, begin by creating a symmetric KMS key with no key material.

To do this, use the Origin parameter of CreateKey with a value of EXTERNAL. Next, use GetParametersForImport (p. 114) operation to get a public key and import token, and use the public key to encrypt your key material. Then, use ImportKeyMaterial (p. 124) with your import token to import the key material. For step-by-step instructions, see Importing Key Material in the AWS Key Management Service Developer Guide . You cannot import the key material into an asymmetric KMS key.

To create a multi-Region primary key with imported key material, use the Origin parameter of CreateKey with a value of EXTERNAL and the MultiRegion parameter with a value of True.

To create replicas of the multi-Region primary key, use the ReplicateKey (p. 170) operation. For more information about multi-Region keys, see Multi-Region keys in AWS KMS in the AWS Key Management Service Developer Guide.

Custom key store

To create a symmetric KMS key in a custom key store, use the CustomKeyStoreId parameter to specify the custom key store. You must also use the Origin parameter with a value of

AWS_CLOUDHSM. The AWS CloudHSM cluster that is associated with the custom key store must have at least two active HSMs in different Availability Zones in the AWS Region.

You cannot create an asymmetric KMS key in a custom key store. For information about custom key stores in AWS KMS see Custom key stores in AWS KMS in the AWS Key Management Service Developer Guide .

Cross-account use: No. You cannot use this operation to create a KMS key in a different AWS account.

Required permissions: kms:CreateKey (IAM policy). To use the Tags parameter, kms:TagResource (IAM policy). For examples and information about related permissions, see Allow a user to create KMS keys in the AWS Key Management Service Developer Guide.

Related operations:

• DescribeKey (p. 55)

• ListKeys (p. 144)

• ScheduleKeyDeletion (p. 184)

Request Syntax

{ "BypassPolicyLockoutSafetyCheck": boolean, "CustomerMasterKeySpec": "string",

"CustomKeyStoreId": "string", "Description": "string", "KeySpec": "string", "KeyUsage": "string", "MultiRegion": boolean, "Origin": "string", "Policy": "string", "Tags": [

{

"TagKey": "string", "TagValue": "string"

} ]}

(37)

Request Parameters

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters (p. 239).

The request accepts the following data in JSON format.

NoteIn the following list, the required parameters are described first.

BypassPolicyLockoutSafetyCheck (p. 27)

A flag to indicate whether to bypass the key policy lockout safety check.

Important

Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately.

For more information, refer to the scenario in the Default Key Policy section in the AWS Key Management Service Developer Guide .

Use this parameter only when you include a policy in the request and you intend to prevent the principal that is making the request from making a subsequent PutKeyPolicy (p. 157) request on the KMS key.

The default value is false.

Type: Boolean Required: No

CustomerMasterKeySpec (p. 27) This parameter has been deprecated.

Instead, use the KeySpec parameter.

The KeySpec and CustomerMasterKeySpec parameters work the same way. Only the names differ. We recommend that you use KeySpec parameter in your code. However, to avoid breaking changes, AWS KMS will support both parameters.

Type: String

Valid Values: RSA_2048 | RSA_3072 | RSA_4096 | ECC_NIST_P256 | ECC_NIST_P384 | ECC_NIST_P521 | ECC_SECG_P256K1 | SYMMETRIC_DEFAULT

Required: No

CustomKeyStoreId (p. 27)

Creates the KMS key in the specified custom key store and the key material in its associated AWS CloudHSM cluster. To create a KMS key in a custom key store, you must also specify the Origin parameter with a value of AWS_CLOUDHSM. The AWS CloudHSM cluster that is associated with the custom key store must have at least two active HSMs, each in a different Availability Zone in the Region.

This parameter is valid only for symmetric KMS keys and regional KMS keys. You cannot create an asymmetric KMS key or a multi-Region key in a custom key store.

To find the ID of a custom key store, use the DescribeCustomKeyStores (p. 51) operation.

The response includes the custom key store ID and the ID of the AWS CloudHSM cluster.

(38)

Request Parameters

This operation is part of the Custom Key Store feature feature in AWS KMS, which combines the convenience and extensive integration of AWS KMS with the isolation and control of a single-tenant key store.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Required: No Description (p. 27)

A description of the KMS key.

Use a description that helps you decide whether the KMS key is appropriate for a task. The default value is an empty string (no description).

To set or change the description after the key is created, use UpdateKeyDescription (p. 210).

Type: String

Length Constraints: Minimum length of 0. Maximum length of 8192.

Required: No KeySpec (p. 27)

Specifies the type of KMS key to create. The default value, SYMMETRIC_DEFAULT, creates a KMS key with a 256-bit symmetric key for encryption and decryption. For help choosing a key spec for your KMS key, see How to Choose Your KMS key Configuration in the AWS Key Management Service Developer Guide .

The KeySpec determines whether the KMS key contains a symmetric key or an asymmetric key pair.

It also determines the encryption algorithms or signing algorithms that the KMS key supports. You can't change the KeySpec after the KMS key is created. To further restrict the algorithms that can be used with the KMS key, use a condition key in its key policy or IAM policy. For more information, see kms:EncryptionAlgorithm or kms:Signing Algorithm in the AWS Key Management Service Developer Guide .

Important

AWS services that are integrated with AWS KMS use symmetric KMS keys to protect your data. These services do not support asymmetric KMS keys. For help determining whether a KMS key is symmetric or asymmetric, see Identifying Symmetric and Asymmetric KMS keys in the AWS Key Management Service Developer Guide.

AWS KMS supports the following key specs for KMS keys:

• Symmetric key (default)

• SYMMETRIC_DEFAULT (AES-256-GCM)

• Asymmetric RSA key pairs

• RSA_2048

• RSA_3072

• RSA_4096

• Asymmetric NIST-recommended elliptic curve key pairs

• ECC_NIST_P256 (secp256r1)

• ECC_NIST_P384 (secp384r1)

• ECC_NIST_P521 (secp521r1)

• Other asymmetric elliptic curve key pairs

• ECC_SECG_P256K1 (secp256k1), commonly used for cryptocurrencies.

(39)

Request Parameters

Type: String

Valid Values: RSA_2048 | RSA_3072 | RSA_4096 | ECC_NIST_P256 | ECC_NIST_P384 | ECC_NIST_P521 | ECC_SECG_P256K1 | SYMMETRIC_DEFAULT

Required: No KeyUsage (p. 27)

Determines the cryptographic operations for which you can use the KMS key. The default value is ENCRYPT_DECRYPT. This parameter is required only for asymmetric KMS keys. You can't change the KeyUsage value after the KMS key is created.

Select only one valid value.

• For symmetric KMS keys, omit the parameter or specify ENCRYPT_DECRYPT.

• For asymmetric KMS keys with RSA key material, specify ENCRYPT_DECRYPT or SIGN_VERIFY.

• For asymmetric KMS keys with ECC key material, specify SIGN_VERIFY.

Type: String

Valid Values: SIGN_VERIFY | ENCRYPT_DECRYPT Required: No

MultiRegion (p. 27)

Creates a multi-Region primary key that you can replicate into other AWS Regions. You cannot change this value after you create the KMS key.

For a multi-Region key, set this parameter to True. For a single-Region KMS key, omit this parameter or set it to False. The default value is False.

This operation supports multi-Region keys, an AWS KMS feature that lets you create multiple interoperable KMS keys in different AWS Regions. Because these KMS keys have the same key ID, key material, and other metadata, you can use them interchangeably to encrypt data in one AWS Region and decrypt it in a different AWS Region without re-encrypting the data or making a cross-Region call. For more information about multi-Region keys, see Multi-Region keys in AWS KMS in the AWS Key Management Service Developer Guide.

This value creates a primary key, not a replica. To create a replica key, use the ReplicateKey (p. 170) operation.

You can create a symmetric or asymmetric multi-Region key, and you can create a multi-Region key with imported key material. However, you cannot create a multi-Region key in a custom key store.

Type: Boolean Required: No Origin (p. 27)

The source of the key material for the KMS key. You cannot change the origin after you create the KMS key. The default is AWS_KMS, which means that AWS KMS creates the key material.

To create a KMS key with no key material (for imported key material), set the value to EXTERNAL. For more information about importing key material into AWS KMS, see Importing Key Material in the AWS Key Management Service Developer Guide. This value is valid only for symmetric KMS keys.

To create a KMS key in an AWS KMS custom key store and create its key material in the associated AWS CloudHSM cluster, set this value to AWS_CLOUDHSM. You must also use the CustomKeyStoreId parameter to identify the custom key store. This value is valid only for symmetric KMS keys.

參考文獻

相關文件

Classifying sensitive data (personal data, mailbox, exam papers etc.) Managing file storage, backup and cloud services, IT Assets (keys) Security in IT Procurement and

 understand and use the English terms for describing the animal types, external features, body parts, feeding habits, movement and habitats of a panda, a crocodile and a crab

Activate prior knowledge about the genre Language access strategies. While-reading activities Reading in

• Describe the role and importance of the following key business functions: human resources management, financial management, operations management, marketing management, information

Splitting a full node y ( have 2t-1 keys ) around its median key. into 2 nodes having (t-1)

The Peunayong Downtown area is in need of rejuvenation because this area considered as the Central Business District (CBD) of Banda Aceh city which in turn supports

For obtaining the real information what the benefits of a KMS provides, this study evaluated the benefits of the Proposal Preparation Assistant (PPA) system in a KMS from a case

This shows that service quality, perceived value, DM advertising, customer satisfaction and loyalty have become important issues on business management.. Therefore, the