Function esp_idf_svc::hal::sys::psa_generate_key
source · pub unsafe extern "C" fn psa_generate_key(
attributes: *const psa_key_attributes_s,
key: *mut u32,
) -> i32
Expand description
\brief Generate a key or key pair.
The key is generated randomly. Its location, usage policy, type and size are taken from \p attributes.
Implementations must reject an attempt to generate a key of size 0.
The following type-specific considerations apply:
- For RSA keys (#PSA_KEY_TYPE_RSA_KEY_PAIR), the public exponent is 65537. The modulus is a product of two probabilistic primes between 2^{n-1} and 2^n where n is the bit size specified in the attributes.
\note This function is equivalent to calling psa_generate_key_ext()
with the production parameters #PSA_KEY_PRODUCTION_PARAMETERS_INIT
and params_data_length == 0
(i.e. params->data
is empty).
\param[in] attributes The attributes for the new key. \param[out] key On success, an identifier for the newly created key. For persistent keys, this is the key identifier defined in \p attributes. \c 0 on failure.
\retval #PSA_SUCCESS Success. If the key is persistent, the key material and the key’s metadata have been saved to persistent storage. \retval #PSA_ERROR_ALREADY_EXISTS This is an attempt to create a persistent key, and there is already a persistent key with the given identifier. \retval #PSA_ERROR_NOT_SUPPORTED \emptydescription \retval #PSA_ERROR_INVALID_ARGUMENT \emptydescription \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription \retval #PSA_ERROR_INSUFFICIENT_ENTROPY \emptydescription \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription \retval #PSA_ERROR_HARDWARE_FAILURE \emptydescription \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription \retval #PSA_ERROR_INSUFFICIENT_STORAGE \emptydescription \retval #PSA_ERROR_DATA_INVALID \emptydescription \retval #PSA_ERROR_DATA_CORRUPT \emptydescription \retval #PSA_ERROR_STORAGE_FAILURE \emptydescription \retval #PSA_ERROR_BAD_STATE The library has not been previously initialized by psa_crypto_init(). It is implementation-dependent whether a failure to initialize results in this error code.