qcrypto_cipher_final()

Updated: April 19, 2023

Finalize a cipher

Synopsis:

#include <qcrypto/qcrypto.h>
int qcrypto_cipher_final(qcrypto_ctx_t *ctx,
                         uint8_t *out,
                         size_t *outsize)

Arguments:

ctx
The algorithm context object.
out
The output data.
outsize
The combined size of the output data and the encrypted or decrypted data.

Library:

libqcrypto

Description:

This function finalizes an encryption or decryption operation by providing the last piece of data, if any. In the case of AEAD cipher modes, it allows qcrypto_cipher_get_tag() to retrieve the authentication tag after the encryption is successfully completed.

If padding is used, then the size of the out buffer should be at least as large as the cipher block size.

Although it appears that this function is not required for certain algorithms, it should always be called because cryptography plugins use it for cleanup operations when cipher operations are terminated.

Returns:

QCRYPTO_R_EOK if successful or qcrypto_errno if an error occurred.