Skip to content

KMSClient.generate_data_key

rboto-kms==0.4.0 · Service index · Types

Model summary (excerpt): Returns a unique symmetric data key for use outside of KMS. This operation returns a plaintext copy of the data key and a copy that is encrypted under a symmetric encryption KMS key that you specify. The bytes in the plaintext key are random; they are not related to the caller or the KMS key. You can use the plaintext key to encrypt your data outside of KMS and store the encrypted data key...

Install and imports

python -m pip install "rboto[kms]==0.4.0"
from rboto import KMSClient
from collections.abc import Sequence
from rboto_kms.types import (
    DataKeySpec,
    GenerateDataKeyOutput,
    RecipientInfo,
)

Signature

async def generate_data_key(
    *,
    key_id: str,
    encryption_context: dict[str, str] | None = None,
    number_of_bytes: int | None = None,
    key_spec: DataKeySpec | None = None,
    grant_tokens: Sequence[str] | None = None,
    recipient: RecipientInfo | None = None,
    dry_run: bool | None = None,
) -> GenerateDataKeyOutput: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
key_id Yes Specifies the symmetric encryption KMS key that encrypts the data key. You cannot specify an asymmetric KMS key or a KMS key in a custom key store. To get the type and origin of your 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...
encryption_context No Specifies the encryption context that will be used when encrypting the data key. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. An encryption context is a collection of non-secret key-value pairs that represent additional authenticated data. When you use an encryption context to encrypt data, you...
number_of_bytes No Specifies the length of the data key in bytes. For example, use the value 64 to generate a 512-bit data key (64 bytes is 512 bits). For 128-bit (16-byte) and 256-bit (32-byte) data keys, use the KeySpec parameter. You must specify either the KeySpec or the NumberOfBytes parameter (but not both) in every GenerateDataKey request.
key_spec No Specifies the length of the data key. Use AES_128 to generate a 128-bit symmetric key, or AES_256 to generate a 256-bit symmetric key. You must specify either the KeySpec or the NumberOfBytes parameter (but not both) in every GenerateDataKey request.
grant_tokens No 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 .
recipient No 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...
dry_run No 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 .

Output

GenerateDataKeyOutput.

Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.

Field Type Presence References
ciphertext_blob bytes | None Always present —
plaintext bytes | None Always present —
key_id str | None Always present —
ciphertext_for_recipient bytes | None Always present —
key_material_id str | None Always present —

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

DataKeySpec, GenerateDataKeyOutput, RecipientInfo

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

No generated paginator for this operation.

No output stream.

Errors

Import from rboto_kms.exceptions:

DependencyTimeoutError, DisabledError, DryRunOperationError, InvalidGrantTokenError, InvalidKeyUsageError, KMSInternalError, KMSInvalidStateError, KeyUnavailableError, NotFoundError.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Service guide · Pinned model