AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

This is the response object from the CreateKey operation.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceResponse
    Amazon.KeyManagementService.Model.CreateKeyResponse

Namespace: Amazon.KeyManagementService.Model
Assembly: AWSSDK.KeyManagementService.dll
Version: 3.x.y.z

Syntax

C#
public class CreateKeyResponse : AmazonWebServiceResponse

The CreateKeyResponse type exposes the following members

Constructors

NameDescription
Public Method CreateKeyResponse()

Properties

NameTypeDescription
Public Property ContentLength System.Int64 Inherited from Amazon.Runtime.AmazonWebServiceResponse.
Public Property HttpStatusCode System.Net.HttpStatusCode Inherited from Amazon.Runtime.AmazonWebServiceResponse.
Public Property KeyMetadata Amazon.KeyManagementService.Model.KeyMetadata

Gets and sets the property KeyMetadata.

Metadata associated with the KMS key.

Public Property ResponseMetadata Amazon.Runtime.ResponseMetadata Inherited from Amazon.Runtime.AmazonWebServiceResponse.

Examples

The following example creates a symmetric KMS key for encryption and decryption. No parameters are required for this operation.

To create a KMS key


var client = new AmazonKeyManagementServiceClient();
var response = client.CreateKey(new CreateKeyRequest 
{
});

KeyMetadata keyMetadata = response.KeyMetadata; // Detailed information about the KMS key that this operation creates.

            

This example creates a KMS key that contains an asymmetric RSA key pair for encryption and decryption. The key spec and key usage can't be changed after the key is created.

To create an asymmetric RSA KMS key for encryption and decryption


var client = new AmazonKeyManagementServiceClient();
var response = client.CreateKey(new CreateKeyRequest 
{
    KeySpec = "RSA_4096", // Describes the type of key material in the KMS key.
    KeyUsage = "ENCRYPT_DECRYPT" // The cryptographic operations for which you can use the KMS key.
});

KeyMetadata keyMetadata = response.KeyMetadata; // Detailed information about the KMS key that this operation creates.

            

This example creates a KMS key that contains an asymmetric elliptic curve (ECC) key pair for signing and verification. The key usage is required even though "SIGN_VERIFY" is the only valid value for ECC KMS keys. The key spec and key usage can't be changed after the key is created.

To create an asymmetric elliptic curve KMS key for signing and verification


var client = new AmazonKeyManagementServiceClient();
var response = client.CreateKey(new CreateKeyRequest 
{
    KeySpec = "ECC_NIST_P521", // Describes the type of key material in the KMS key.
    KeyUsage = "SIGN_VERIFY" // The cryptographic operations for which you can use the KMS key.
});

KeyMetadata keyMetadata = response.KeyMetadata; // Detailed information about the KMS key that this operation creates.

            

This example creates a multi-Region primary symmetric encryption key. Because the default values for all parameters create a symmetric encryption key, only the MultiRegion parameter is required for this KMS key.

To create a multi-Region primary KMS key


var client = new AmazonKeyManagementServiceClient();
var response = client.CreateKey(new CreateKeyRequest 
{
    MultiRegion = true // Indicates whether the KMS key is a multi-Region (True) or regional (False) key.
});

KeyMetadata keyMetadata = response.KeyMetadata; // Detailed information about the KMS key that this operation creates.

            

This example creates a KMS key with no key material. When the operation is complete, you can import your own key material into the KMS key. To create this KMS key, set the Origin parameter to EXTERNAL.

To create a KMS key for imported key material


var client = new AmazonKeyManagementServiceClient();
var response = client.CreateKey(new CreateKeyRequest 
{
    Origin = "EXTERNAL" // The source of the key material for the KMS key.
});

KeyMetadata keyMetadata = response.KeyMetadata; // Detailed information about the KMS key that this operation creates.

            

This example creates a KMS key in the specified custom key store. The operation creates the KMS key and its metadata in AWS KMS and the key material in the AWS CloudHSM cluster associated with the custom key store. This example requires the Origin and CustomKeyStoreId parameters.

To create a KMS key in a custom key store


var client = new AmazonKeyManagementServiceClient();
var response = client.CreateKey(new CreateKeyRequest 
{
    CustomKeyStoreId = "cks-1234567890abcdef0", // Identifies the custom key store that hosts the KMS key.
    Origin = "AWS_CLOUDHSM" // Indicates the source of the key material for the KMS key.
});

KeyMetadata keyMetadata = response.KeyMetadata; // Detailed information about the KMS key that this operation creates.

            

Version Information

.NET Core App:
Supported in: 3.1

.NET Standard:
Supported in: 2.0

.NET Framework:
Supported in: 4.5, 4.0, 3.5