psa_raw_key_agreement() function
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.
Arguments
alg
The key agreement algorithm to compute (\c PSA_ALG_XXX value such that #PSA_ALG_IS_RAW_KEY_AGREEMENT(\p alg) is true).
private_key
Identifier of the private key to use. It must allow the usage #PSA_KEY_USAGE_DERIVE.
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().
peer_key_length
Size of \p peer_key in bytes.
output
Buffer where the decrypted message is to be written.
output_size
Size of the \c output buffer in bytes.
output_length
On success, the number of bytes that make up the returned output.
Return value
#PSA_SUCCESS Success. #PSA_ERROR_INVALID_HANDLE \emptydescription #PSA_ERROR_NOT_PERMITTED \emptydescription #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. #PSA_ERROR_BUFFER_TOO_SMALL \p output_size is too small #PSA_ERROR_NOT_SUPPORTED \p alg is not a supported key agreement algorithm. #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription #PSA_ERROR_HARDWARE_FAILURE \emptydescription #PSA_ERROR_CORRUPTION_DETECTED \emptydescription #PSA_ERROR_STORAGE_FAILURE \emptydescription #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.