Name

kcapi_pad_iv — realign the IV as necessary for cipher

Synopsis

int kcapi_pad_iv (struct kcapi_handle * handle,
 const uint8_t * iv,
 uint32_t ivlen,
 uint8_t ** newiv,
 uint32_t * newivlen);
 

Arguments

handle

[in] cipher handle

iv

[in] current IV buffer

ivlen

[in] length of IV buffer

newiv

[out] buffer of aligned IV

newivlen

[out] length of newly aligned IV

Description

The function pads the least significant bits of the provided IV up to the block size of the cipher with zeros. In case the provided IV is longer than the block size, the least significant bits are truncated to the block size.

The function allocates memory for newiv in case the return code indicates success. The consumer must free the memory after use.

return 0 for success; a negative errno-style error code if an error occurred