Calculating the size of ciphertext created by versioned keys
To calculate the size of ciphertext
Call the I_C_CalculateOutputSizeForKey
API to determine the size of the ciphertext. You need to know this to allocate enough space for the ciphertext.
When using versioned keys, I_C_CalculateOutputSize
does not return the correct value. You must use I_C_CalculateOutputSizeForKey
instead.
Use I_C_CalculateOutputSizeForKey
to determine the size of the ciphertext when the size of the plaintext and the cipher are input.
Example
rc = I_C_CalculateOutputSizeForKey(session, cipherspec, I_T_Operation_Encrypt,indatalen, &encdatalen);