generate_random¶
Operation¶
generate_random
async
¶
generate_random(input: GenerateRandomInput, plugins: list[Plugin] | None = None) -> GenerateRandomOutput
Returns a random byte string that is cryptographically secure.
You must use the NumberOfBytes parameter to specify the length of the
random byte string. There is no default value for string length.
By default, the random byte string is generated in KMS. To generate the
byte string in the CloudHSM cluster associated with an CloudHSM key
store, use the CustomKeyStoreId parameter.
GenerateRandom also supports Amazon Web Services Nitro
Enclaves,
which provide an isolated compute environment in Amazon EC2. To call
GenerateRandom for a Nitro enclave or NitroTPM, use the Amazon Web
Services Nitro Enclaves
SDK
or any Amazon Web Services SDK. Use the Recipient parameter to provide
the attestation document for the attested environment. Instead of
plaintext bytes, the response includes the plaintext bytes encrypted
under the public key from the attestation document
(CiphertextForRecipient). For information about the interaction
between KMS and Amazon Web Services Nitro Enclaves or Amazon Web
Services NitroTPM, see Cryptographic attestation support in
KMS
in the Key Management Service Developer Guide.
For more information about entropy and random number generation, see Entropy and random number generation in the Key Management Service Developer Guide.
Cross-account use: Not applicable. GenerateRandom does not use any
account-specific resources, such as KMS keys.
Required permissions: kms:GenerateRandom (IAM policy)
Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
GenerateRandomInput
|
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 |
|---|---|
GenerateRandomOutput
|
An instance of |
Input¶
GenerateRandomInput
dataclass
¶
Bases: _SerdeShape
Dataclass for GenerateRandomInput structure.
Attributes¶
custom_key_store_id
class-attribute
instance-attribute
¶
custom_key_store_id: str | None = ...
Generates the random byte string in the CloudHSM cluster that is associated with the specified CloudHSM key store. To find the ID of a custom key store, use the DescribeCustomKeyStores operation.
External key store IDs are not valid for this parameter. If you specify
the ID of an external key store, GenerateRandom throws an
UnsupportedOperationException.
number_of_bytes
class-attribute
instance-attribute
¶
number_of_bytes: int | None = ...
The length of the random byte string. This parameter is required.
recipient
class-attribute
instance-attribute
¶
recipient: RecipientInfo | None = ...
A signed attestation
document
from an Amazon Web Services Nitro enclave or NitroTPM, and the
encryption algorithm to use with the public key in the attestation
document. The only valid encryption algorithm is RSAES_OAEP_SHA_256.
This parameter supports the Amazon Web Services Nitro Enclaves SDK or any Amazon Web Services SDK for Amazon Web Services Nitro Enclaves. It supports any Amazon Web Services SDK for Amazon Web Services NitroTPM.
When you use this parameter, instead of returning plaintext bytes, KMS
encrypts the plaintext bytes under the public key in the attestation
document, and returns the resulting ciphertext in the
CiphertextForRecipient field in the response. This ciphertext can be
decrypted only with the private key in the attested environment. The
Plaintext field in the response is null or empty.
For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide.
Output¶
GenerateRandomOutput
dataclass
¶
Bases: _SerdeShape
Dataclass for GenerateRandomOutput structure.
Attributes¶
ciphertext_for_recipient
class-attribute
instance-attribute
¶
ciphertext_for_recipient: bytes | None = ...
The plaintext random bytes encrypted with the public key from the attestation document. This ciphertext can be decrypted only by using a private key from the attested environment.
This field is included in the response only when the Recipient
parameter in the request includes a valid attestation document from an
Amazon Web Services Nitro enclave or NitroTPM. For information about the
interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon
Web Services NitroTPM, see Cryptographic attestation support in
KMS
in the Key Management Service Developer Guide.
plaintext
class-attribute
instance-attribute
¶
plaintext: bytes | None = ...
The random byte string. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded.
If the response includes the CiphertextForRecipient field, the
Plaintext field is null or empty.
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.