encapsulate¶
Operation¶
encapsulate
async
¶
encapsulate(input: EncapsulateInput, plugins: list[Plugin] | None = None) -> EncapsulateOutput
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:
-
Decapsulate
-
DeriveSharedSecret
-
CreateKey
-
GetPublicKey
-
DescribeKey
Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
EncapsulateInput
|
An instance of |
required |
plugins
|
list[Plugin] | None
|
A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations. |
None
|
Returns:
| Type | Description |
|---|---|
EncapsulateOutput
|
An instance of |
Input¶
EncapsulateInput
dataclass
¶
Bases: _SerdeShape
Dataclass for EncapsulateInput structure.
Attributes¶
dry_run
class-attribute
instance-attribute
¶
dry_run: bool | None = ...
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.
encapsulation_algorithm
class-attribute
instance-attribute
¶
encapsulation_algorithm: str | None = ...
Specifies the key encapsulation algorithm used to generate the shared
secret and its encapsulated form. The only valid value is ML_KEM.
grant_tokens
class-attribute
instance-attribute
¶
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.
key_id
class-attribute
instance-attribute
¶
key_id: str | None = ...
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.
Output¶
EncapsulateOutput
dataclass
¶
Bases: _SerdeShape
Dataclass for EncapsulateOutput structure.
Attributes¶
encapsulation_algorithm
class-attribute
instance-attribute
¶
encapsulation_algorithm: str | None = ...
The key encapsulation algorithm used to generate the shared secret.
key_id
class-attribute
instance-attribute
¶
key_id: str | None = ...
The identifier of the ML-KEM KMS key used to encapsulate the shared secret.
response_metadata
class-attribute
instance-attribute
¶
Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.
shared_secret
class-attribute
instance-attribute
¶
shared_secret: bytes | None = ...
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.
shared_secret_ciphertext_blob
class-attribute
instance-attribute
¶
shared_secret_ciphertext_blob: bytes | None = ...
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.