Function esp_idf_svc::hal::sys::psa_key_derivation_setup
source · pub unsafe extern "C" fn psa_key_derivation_setup(
operation: *mut psa_key_derivation_s,
alg: u32,
) -> i32
Expand description
Set up a key derivation operation.
A key derivation algorithm takes some inputs and uses them to generate a byte stream in a deterministic way. This byte stream can be used to produce keys and other cryptographic material.
To derive a key: -# Start with an initialized object of type #psa_key_derivation_operation_t. -# Call psa_key_derivation_setup() to select the algorithm. -# Provide the inputs for the key derivation by calling psa_key_derivation_input_bytes() or psa_key_derivation_input_key() as appropriate. Which inputs are needed, in what order, and whether they may be keys and if so of what type depends on the algorithm. -# Optionally set the operation’s maximum capacity with psa_key_derivation_set_capacity(). You may do this before, in the middle of or after providing inputs. For some algorithms, this step is mandatory because the output depends on the maximum capacity. -# To derive a key, call psa_key_derivation_output_key() or psa_key_derivation_output_key_ext(). To derive a byte string for a different purpose, call psa_key_derivation_output_bytes(). Successive calls to these functions use successive output bytes calculated by the key derivation algorithm. -# Clean up the key derivation operation object with psa_key_derivation_abort().
If this function returns an error, the key derivation operation object is not changed.
If an error occurs at any step after a call to psa_key_derivation_setup(), the operation will need to be reset by a call to psa_key_derivation_abort().
Implementations must reject an attempt to derive a key of size 0.
\param[in,out] operation The key derivation operation object to set up. It must have been initialized but not set up yet. \param alg The key derivation algorithm to compute (\c PSA_ALG_XXX value such that #PSA_ALG_IS_KEY_DERIVATION(\p alg) is true).
\retval #PSA_SUCCESS Success. \retval #PSA_ERROR_INVALID_ARGUMENT \c alg is not a key derivation algorithm. \retval #PSA_ERROR_NOT_SUPPORTED \c alg is not supported or is not a key derivation algorithm. \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription \retval #PSA_ERROR_HARDWARE_FAILURE \emptydescription \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription \retval #PSA_ERROR_STORAGE_FAILURE \emptydescription \retval #PSA_ERROR_BAD_STATE The operation state is not valid (it must be inactive), or 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.