AWS SDK Version 4 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.

Container for the parameters to the Encapsulate operation. Generates a shared secret and its encapsulated (ciphertext) form using the public key of an ML-KEM KMS key pair. Module-Lattice-Based Key-Encapsulation Mechanism (ML-KEM), specified in FIPS 203 on the NIST website, is a post-quantum algorithm for establishing a shared secret between two parties.

For an example of how two parties establish a shared secret over an insecure channel using ML-KEM, see ML-KEM keys in KMS in the Key Management Service Developer Guide.

The Encapsulate operation is not available in China Regions.

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

Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter.

Required permissions: kms:Encapsulate (key policy)

Related operations:

Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceRequest
    Amazon.KeyManagementService.AmazonKeyManagementServiceRequest
      Amazon.KeyManagementService.Model.EncapsulateRequest

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

Syntax

C#
public class EncapsulateRequest : AmazonKeyManagementServiceRequest
         IAmazonWebServiceRequest

The EncapsulateRequest type exposes the following members

Constructors

NameDescription
Public Method EncapsulateRequest()

Properties

NameTypeDescription
Public Property DryRun System.Nullable<System.Boolean>

Gets and sets the property DryRun.

Checks if your request will succeed. DryRun is an optional parameter.

To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide.

Public Property EncapsulationAlgorithm Amazon.KeyManagementService.EncapsulationAlgorithmSpec

Gets and sets the property EncapsulationAlgorithm.

Specifies the key encapsulation algorithm used to generate the shared secret and its encapsulated form. The only valid value is ML_KEM.

Public Property GrantTokens System.Collections.Generic.List<System.String>

Gets and sets the property GrantTokens.

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 Key Management Service Developer Guide.

Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true.

Public Property KeyId System.String

Gets and sets the property KeyId.

Identifies an asymmetric ML-KEM KMS key. KMS uses the public key in the specified key pair to encapsulate the shared secret. ML-KEM KMS keys have a KeySpec value of ML_KEM_512, ML_KEM_768, or ML_KEM_1024 and a KeyUsage value of ENCAPSULATE_DECAPSULATE. To find the KeySpec and KeyUsage of a KMS key, use the DescribeKey operation.

To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with "alias/". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias 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

  • Alias name: alias/ExampleAlias

  • Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias

To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.

Examples

Generates a shared secret and its encapsulated ciphertext (SharedSecretCiphertextBlob) using the public key in an asymmetric ML-KEM KMS key. Send the ciphertext to your peer, who calls Decapsulate to recover the same shared secret.

To generate a shared secret and its encapsulated ciphertext


var client = new AmazonKeyManagementServiceClient();
var response = client.Encapsulate(new EncapsulateRequest
{
    EncapsulationAlgorithm = "ML_KEM",
    KeyId = "1234abcd-12ab-34cd-56ef-1234567890ab"
});

EncapsulationAlgorithmSpec encapsulationAlgorithm = response.EncapsulationAlgorithm;
string keyId = response.KeyId;
MemoryStream sharedSecret = response.SharedSecret;
MemoryStream sharedSecretCiphertextBlob = response.SharedSecretCiphertextBlob;

            

Version Information

.NET:
Supported in: 8.0 and newer

.NET Standard:
Supported in: 2.0

.NET Framework:
Supported in: 4.7.2 and newer