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.

This is the response object from the Encapsulate operation.

Inheritance Hierarchy

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

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

Syntax

C#
public class EncapsulateResponse : AmazonWebServiceResponse

The EncapsulateResponse type exposes the following members

Constructors

NameDescription
Public Method EncapsulateResponse()

Properties

NameTypeDescription
Public Property ContentLength System.Int64 Inherited from Amazon.Runtime.AmazonWebServiceResponse.
Public Property EncapsulationAlgorithm Amazon.KeyManagementService.EncapsulationAlgorithmSpec

Gets and sets the property EncapsulationAlgorithm.

The key encapsulation algorithm used to generate the shared secret.

Public Property HttpStatusCode System.Net.HttpStatusCode Inherited from Amazon.Runtime.AmazonWebServiceResponse.
Public Property KeyId System.String

Gets and sets the property KeyId.

The identifier of the ML-KEM KMS key used to encapsulate the shared secret.

Public Property ResponseMetadata Amazon.Runtime.ResponseMetadata Inherited from Amazon.Runtime.AmazonWebServiceResponse.
Public Property SharedSecret System.IO.MemoryStream

Gets and sets the property SharedSecret.

The plaintext shared secret. It is a 32-byte cryptographically random value that both parties can use directly as key material or pass through a key derivation function to generate multiple keys and nonces. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded.

Public Property SharedSecretCiphertextBlob System.IO.MemoryStream

Gets and sets the property SharedSecretCiphertextBlob.

The encapsulated form of the shared secret. Pass this value to the Decapsulate operation to recover the shared secret. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded. The length of SharedSecretCiphertextBlob depends on the ML-KEM key spec. Before Base64 encoding, the encapsulated shared secret is 768 bytes for ML_KEM_512, 1088 bytes for ML_KEM_768, and 1568 bytes for ML_KEM_1024.

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