/AWS1/IF_KMS=>GENERATERANDOM()¶
About GenerateRandom¶
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.
Method Signature¶
METHODS /AWS1/IF_KMS~GENERATERANDOM
IMPORTING
!IV_NUMBEROFBYTES TYPE /AWS1/KMSNUMBEROFBYTESTYPE OPTIONAL
!IV_CUSTOMKEYSTOREID TYPE /AWS1/KMSCUSTOMKEYSTOREIDTYPE OPTIONAL
!IO_RECIPIENT TYPE REF TO /AWS1/CL_KMSRECIPIENTINFO OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_kmsgeneraterandomrsp
RAISING
/AWS1/CX_KMSCUSTKEYSTOREINVS00
/AWS1/CX_KMSCUSTKEYSTORENOTF00
/AWS1/CX_KMSDEPENDENCYTMOUTEX
/AWS1/CX_KMSKMSINTERNALEX
/AWS1/CX_KMSUNSUPPORTEDOPEX
/AWS1/CX_KMSCLIENTEXC
/AWS1/CX_KMSSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Optional arguments:¶
iv_numberofbytes TYPE /AWS1/KMSNUMBEROFBYTESTYPE /AWS1/KMSNUMBEROFBYTESTYPE¶
The length of the random byte string. This parameter is required.
iv_customkeystoreid TYPE /AWS1/KMSCUSTOMKEYSTOREIDTYPE /AWS1/KMSCUSTOMKEYSTOREIDTYPE¶
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,
GenerateRandomthrows anUnsupportedOperationException.
io_recipient TYPE REF TO /AWS1/CL_KMSRECIPIENTINFO /AWS1/CL_KMSRECIPIENTINFO¶
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
CiphertextForRecipientfield in the response. This ciphertext can be decrypted only with the private key in the attested environment. ThePlaintextfield 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.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_kmsgeneraterandomrsp /AWS1/CL_KMSGENERATERANDOMRSP¶
Domain /AWS1/RT_ACCOUNT_ID Primitive Type NUMC
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->generaterandom(
io_recipient = new /aws1/cl_kmsrecipientinfo(
iv_attestationdocument = '5347567362473873563239796247513D'
iv_keyencryptionalgorithm = |string|
)
iv_customkeystoreid = |string|
iv_numberofbytes = 123
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
lv_plaintexttype = lo_result->get_plaintext( ).
lv_ciphertexttype = lo_result->get_ciphertextforrecipient( ).
ENDIF.
To generate random data¶
The following example generates 32 bytes of random data.
DATA(lo_result) = lo_client->generaterandom( iv_numberofbytes = 32 ) .