---
name: "kcapi_pad_iv"
section: "3"
platform: "linux"
package: "libkcapi-dev"
version: "1.4.0-1+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/kcapi_pad_iv"
---

# kcapi\_pad\_iv(3)

realign the IV as necessary for cipher

## 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

## AUTHOR

**Stephan Mueller** \<smueller@chronox.de\>

Author.

## COPYRIGHT
