Function esp_idf_svc::hal::sys::psa_raw_key_agreement

source ยท
pub unsafe extern "C" fn psa_raw_key_agreement(
    alg: u32,
    private_key: u32,
    peer_key: *const u8,
    peer_key_length: usize,
    output: *mut u8,
    output_size: usize,
    output_length: *mut usize,
) -> i32
Expand description

Perform a key agreement and return the raw shared secret.

\warning The raw result of a key agreement algorithm such as finite-field Diffie-Hellman or elliptic curve Diffie-Hellman has biases and should not be used directly as key material. It should instead be passed as input to a key derivation algorithm. To chain a key agreement with a key derivation, use psa_key_derivation_key_agreement() and other functions from the key derivation interface.

\param alg The key agreement algorithm to compute (\c PSA_ALG_XXX value such that #PSA_ALG_IS_RAW_KEY_AGREEMENT(\p alg) is true). \param private_key Identifier of the private key to use. It must allow the usage #PSA_KEY_USAGE_DERIVE. \param[in] peer_key Public key of the peer. It must be in the same format that psa_import_key() accepts. The standard formats for public keys are documented in the documentation of psa_export_public_key(). \param peer_key_length Size of \p peer_key in bytes. \param[out] output Buffer where the decrypted message is to be written. \param output_size Size of the \c output buffer in bytes. \param[out] output_length On success, the number of bytes that make up the returned output.

\retval #PSA_SUCCESS Success. \retval #PSA_ERROR_INVALID_HANDLE \emptydescription \retval #PSA_ERROR_NOT_PERMITTED \emptydescription \retval #PSA_ERROR_INVALID_ARGUMENT \p alg is not a key agreement algorithm, or \p private_key is not compatible with \p alg, or \p peer_key is not valid for \p alg or not compatible with \p private_key. \retval #PSA_ERROR_BUFFER_TOO_SMALL \p output_size is too small \retval #PSA_ERROR_NOT_SUPPORTED \p alg is not a supported key agreement 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 library has not been previously initialized by psa_crypto_init(). It is implementation-dependent whether a failure to initialize results in this error code.