Platform Security Architecture — cryptography and keystore interface  beta 2 — 2019-02-22
Classes | Functions
Random generation

Classes

struct  psa_generate_key_extra_rsa
 

Functions

psa_status_t psa_generate_random (uint8_t *output, size_t output_size)
 Generate random bytes. More...
 
psa_status_t psa_generate_key (psa_key_handle_t handle, psa_key_type_t type, size_t bits, const void *extra, size_t extra_size)
 Generate a key or key pair. More...
 

Detailed Description

Function Documentation

psa_status_t psa_generate_key ( psa_key_handle_t  handle,
psa_key_type_t  type,
size_t  bits,
const void *  extra,
size_t  extra_size 
)

Generate a key or key pair.

Parameters
handleHandle to the slot where the key will be stored. It must have been obtained by calling psa_allocate_key() or psa_create_key() and must not contain key material yet.
typeKey type (a PSA_KEY_TYPE_XXX value).
bitsKey size in bits.
[in]extraExtra parameters for key generation. The interpretation of this parameter depends on type. All types support NULL to use default parameters. Implementation that support the generation of vendor-specific key types that allow extra parameters shall document the format of these extra parameters and the default values. For standard parameters, the meaning of extra is as follows:
extra_sizeSize of the buffer that extra points to, in bytes. Note that if extra is NULL then extra_size must be zero.
Return values
PSA_SUCCESSSuccess. If the key is persistent, the key material and the key's metadata have been saved to persistent storage.
PSA_ERROR_INVALID_HANDLE
PSA_ERROR_OCCUPIED_SLOTThere is already a key in the specified slot.
PSA_ERROR_NOT_SUPPORTED
PSA_ERROR_INVALID_ARGUMENT
PSA_ERROR_INSUFFICIENT_MEMORY
PSA_ERROR_INSUFFICIENT_ENTROPY
PSA_ERROR_COMMUNICATION_FAILURE
PSA_ERROR_HARDWARE_FAILURE
PSA_ERROR_TAMPERING_DETECTED
PSA_ERROR_BAD_STATEThe library has not been previously initialized by psa_crypto_init(). It is implementation-dependent whether a failure to initialize results in this error code.
psa_status_t psa_generate_random ( uint8_t *  output,
size_t  output_size 
)

Generate random bytes.

Warning
This function can fail! Callers MUST check the return status and MUST NOT use the content of the output buffer if the return status is not PSA_SUCCESS.
Note
To generate a key, use psa_generate_key() instead.
Parameters
[out]outputOutput buffer for the generated data.
output_sizeNumber of bytes to generate and output.
Return values
PSA_SUCCESS
PSA_ERROR_NOT_SUPPORTED
PSA_ERROR_INSUFFICIENT_ENTROPY
PSA_ERROR_COMMUNICATION_FAILURE
PSA_ERROR_HARDWARE_FAILURE
PSA_ERROR_TAMPERING_DETECTED
PSA_ERROR_BAD_STATEThe library has not been previously initialized by psa_crypto_init(). It is implementation-dependent whether a failure to initialize results in this error code.