Skip to main content

GenerateDataKeyWithoutPlaintext

Generates an encrypted data key that you can use in your application.

Description

The GenerateDataKeyWithoutPlaintext operation returns only the encrypted copy of the data key. This operation is useful when you need to generate a data key but don't need to use it immediately.

note
  • The KMS key that you use for this operation must be in a compatible key state.
  • This operation is identical to GenerateDataKey but returns only the encrypted copy of the data key.
  • To get the plaintext data key, call the Decrypt operation on the encrypted data key.
  • This operation is useful when you need to move encrypted data keys across security boundaries.

Request Syntax

Headers

NameDescriptionRequiredType
Content-TypeMust be "application/x-amz-json-1.1"Yesstring
X-Amz-TargetMust be "TrentService.GenerateDataKeyWithoutPlaintext"Yesstring

Request Body

NameDescriptionRequiredType
KeyIdThe identifier of the KMS key to use to encrypt the data key. This can be the key ID or key ARN of the KMS key.Yesstring
KeySpecThe length and type of data key to generate.

Valid Values: AES_256, AES_128.
Nostring
NumberOfBytesThe length of the data key in bytes. Use either this parameter or KeySpec, but not both.Nonumber
EncryptionContextA set of key-value pairs that will be cryptographically bound to the data key.Noobject
GrantTokensA list of grant tokens that represent grants that can be used to generate the data key.Noarray
POST / HTTP/1.1
Content-Type: application/x-amz-json-1.1
X-Amz-Target: TrentService.GenerateDataKeyWithoutPlaintext
{ "KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab", "KeySpec": "AES_256", "EncryptionContext": { "Department": "Finance" } }
Values in italics indicate user input and should be replaced with actual values.

Response Elements

NameDescriptionRequiredType
CiphertextBlobThe encrypted copy of the data key.NoString
KeyIdThe Amazon Resource Name (ARN) of the KMS key that was used to encrypt the data key.NoString

Special Errors

Error CodeDescription
DependencyTimeoutExceptionThe system timed out while trying to fulfill the request.
DisabledExceptionThe request was rejected because the specified KMS key is disabled.
InvalidGrantTokenExceptionThe request was rejected because the specified grant token is not valid.
InvalidKeyUsageExceptionThe request was rejected because the specified KeyId value cannot be used for this operation.
KeyUnavailableExceptionThe request was rejected because the specified KMS key was not available.
KMSInternalExceptionAn internal error occurred.
KMSInvalidStateExceptionThe request was rejected because the key state is not valid for this operation.
NotFoundExceptionThe request was rejected because the specified key was not found.

Permissions

To use the GenerateDataKeyWithoutPlaintext operation, you must have the following permissions:

  • kms:GenerateDataKeyWithoutPlaintext on the KMS key (specified in the policy)

Try It Out

Test GenerateDataKeyWithoutPlaintext

Generate an encrypted data key.

Coming Soon

This feature is currently under development and will be available soon.