pub unsafe extern "C" fn psa_aead_set_lengths(
    operation: *mut psa_aead_operation_t,
    ad_length: usize,
    plaintext_length: usize
) -> psa_status_t
Expand description

Declare the lengths of the message and additional data for AEAD.

The application must call this function before calling psa_aead_update_ad() or psa_aead_update() if the algorithm for the operation requires it. If the algorithm does not require it, calling this function is optional, but if this function is called then the implementation must enforce the lengths.

You may call this function before or after setting the nonce with psa_aead_set_nonce() or psa_aead_generate_nonce().

  • For #PSA_ALG_CCM, calling this function is required.
  • For the other AEAD algorithms defined in this specification, calling this function is not required.
  • For vendor-defined algorithm, refer to the vendor documentation.

If this function returns an error status, the operation enters an error state and must be aborted by calling psa_aead_abort().

\param[in,out] operation Active AEAD operation. \param ad_length Size of the non-encrypted additional authenticated data in bytes. \param plaintext_length Size of the plaintext to encrypt in bytes.

\retval #PSA_SUCCESS Success. \retval #PSA_ERROR_INVALID_ARGUMENT At least one of the lengths is not acceptable for the chosen 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_BAD_STATE The operation state is not valid (it must be active, and psa_aead_update_ad() and psa_aead_update() must not have been called yet), 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.