---
name: "kcapi_akcipher_setkey"
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_akcipher_setkey"
---

# kcapi\_akcipher\_setkey(3)

set the private key for the cipher handle

## NAME

kcapi\_akcipher\_setkey - set the private key for the cipher handle

## SYNOPSIS

**int kcapi\_akcipher\_setkey(struct kcapi\_handle \*** *handle***, const uint8\_t \*** *key***, uint32\_t** *keylen***);**

## ARGUMENTS

*handle*

\[in\] cipher handle

*key*

\[in\] key buffer in DER format

*keylen*

\[in\] length of key buffer

## DESCRIPTION

With this function, the caller sets the key for subsequent cipher operations.

The key must be in DER format as follows

SEQUENCE { version INTEGER, n INTEGER ({ rsa\_get\_n }), e INTEGER ({ rsa\_get\_e }), d INTEGER ({ rsa\_get\_d }), prime1 INTEGER, prime2 INTEGER, exponent1 INTEGER, exponent2 INTEGER, coefficient INTEGER }

After the caller provided the key, the caller may securely destroy the key as it is now maintained by the kernel.

*return* upon success the value of the maximum size for the asymmetric operation is returned (e.g. the modulus size); a negative errno-style error code if an error occurred

## AUTHOR

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

Author.

## COPYRIGHT
