decapsulate¶
Operation¶
decapsulate
async
¶
decapsulate(input: DecapsulateInput, plugins: list[Plugin] | None = None) -> DecapsulateOutput
Recovers the shared secret that was encapsulated with the public key of an ML-KEM KMS key. 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 Decapsulate operation is not available in China Regions.
Decapsulate returns the shared secret as a 32-byte value. You can use
it directly as key material, or run it through a key derivation function
to derive multiple keys and nonces.
Warning
Decapsulate returns an InvalidCiphertextException when the length of
the SharedSecretCiphertextBlob is inconsistent with the ML-KEM key
spec. In all other cases, Decapsulate returns a 32-byte pseudo-random
value. This is true even when the SharedSecretCiphertextBlob was
created using a different ML-KEM key or altered from its original value.
This behavior is a security feature called implicit rejection that
helps protect against chosen-ciphertext attacks.
Because a response does not indicate that the ciphertext and key are valid, confirm the two parties derived the same shared secret before using it.
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:Decapsulate (key policy)
Related operations:
-
Encapsulate
-
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
|
DecapsulateInput
|
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 |
|---|---|
DecapsulateOutput
|
An instance of |
Input¶
DecapsulateInput
dataclass
¶
Bases: _SerdeShape
Dataclass for DecapsulateInput 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 recover the shared
secret. 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 the asymmetric ML-KEM KMS key whose public key was used to produce the encapsulated shared secret. KMS uses the private key in the specified key pair to decapsulate the shared secret.
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.
shared_secret_ciphertext_blob
class-attribute
instance-attribute
¶
shared_secret_ciphertext_blob: bytes | None = ...
The encapsulated (ciphertext) form of the shared secret to recover. This
is the SharedSecretCiphertextBlob value that the Encapsulate operation
returns. When you use the HTTP API or the Amazon Web Services CLI, the
value is Base64-encoded. Otherwise, it is not Base64-encoded.
Output¶
DecapsulateOutput
dataclass
¶
Bases: _SerdeShape
Dataclass for DecapsulateOutput structure.
Attributes¶
encapsulation_algorithm
class-attribute
instance-attribute
¶
encapsulation_algorithm: str | None = ...
The key encapsulation algorithm used to recover the shared secret.
key_id
class-attribute
instance-attribute
¶
key_id: str | None = ...
The identifier of the ML-KEM KMS key used to decapsulate 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 recovered from the encapsulated form. It is a 32-byte value that matches the shared secret held by the encapsulating party. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded.