---
name: "libressl-d2i_PKCS8PrivateKey_bio"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-d2i_PKCS8PrivateKey_bio"
---

# libressl-d2i\_PKCS8PrivateKey\_bio(3)

PKCS#8 format private key functions

## NAME

**d2i\_PKCS8PrivateKey\_bio**, **d2i\_PKCS8PrivateKey\_fp**, **i2d\_PKCS8PrivateKey\_bio**, **i2d\_PKCS8PrivateKey\_fp**, **i2d\_PKCS8PrivateKey\_nid\_bio**, **i2d\_PKCS8PrivateKey\_nid\_fp** – PKCS#8 format private key functions

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/evp.h\>**

*EVP\_PKEY* *\**\

**d2i\_PKCS8PrivateKey\_bio**(*BIO \*bp*, *EVP\_PKEY \*\*x*, *pem\_password\_cb \*cb*, *void \*u*);

*EVP\_PKEY* *\**\

**d2i\_PKCS8PrivateKey\_fp**(*FILE \*fp*, *EVP\_PKEY \*\*x*, *pem\_password\_cb \*cb*, *void \*u*);

*int*\

**i2d\_PKCS8PrivateKey\_bio**(*BIO \*bp*, *EVP\_PKEY \*x*, *const EVP\_CIPHER \*enc*, *char \*kstr*, *int klen*, *pem\_password\_cb \*cb*, *void \*u*);

*int*\

**i2d\_PKCS8PrivateKey\_fp**(*FILE \*fp*, *EVP\_PKEY \*x*, *const EVP\_CIPHER \*enc*, *char \*kstr*, *int klen*, *pem\_password\_cb \*cb*, *void \*u*);

*int*\

**i2d\_PKCS8PrivateKey\_nid\_bio**(*BIO \*bp*, *EVP\_PKEY \*x*, *int nid*, *char \*kstr*, *int klen*, *pem\_password\_cb \*cb*, *void \*u*);

*int*\

**i2d\_PKCS8PrivateKey\_nid\_fp**(*FILE \*fp*, *EVP\_PKEY \*x*, *int nid*, *char \*kstr*, *int klen*, *pem\_password\_cb \*cb*, *void \*u*);

## DESCRIPTION

The PKCS#8 functions encode and decode private keys in PKCS#8 format using both PKCS#5 v1.5 and PKCS#5 v2.0 password based encryption algorithms.

Other than the use of DER as opposed to PEM these functions are identical to the corresponding functions described in PEM\_read\_PrivateKey(3).

These functions are currently the only way to store encrypted private keys using DER format.

Currently all the functions use *BIO* or *FILE* pointers. There are no functions which work directly on memory, though this can be readily worked around by converting the buffers to memory BIOs; see BIO\_s\_mem(3) for details.

## RETURN VALUES

**d2i\_PKCS8PrivateKey\_bio**() and **d2i\_PKCS8PrivateKey\_fp**() return a *EVP\_PKEY* object or NULL if an error occurs.

**i2d\_PKCS8PrivateKey\_bio**(), **i2d\_PKCS8PrivateKey\_fp**(), **i2d\_PKCS8PrivateKey\_nid\_bio**(), and **i2d\_PKCS8PrivateKey\_nid\_fp**() return 1 on success or 0 on error.

## SEE ALSO

d2i\_X509\_SIG(3), PEM\_write\_PKCS8PrivateKey(3), PKCS8\_PRIV\_KEY\_INFO\_new(3)

## HISTORY

These functions first appeared in OpenSSL 0.9.5 and have been available since OpenBSD 2.7.

## CAVEATS

Do not confuse these functions with i2d\_PKCS8PrivateKeyInfo\_bio(3) and i2d\_PKCS8PrivateKeyInfo\_fp(3), which write out private keys in **unencrypted** DER format.
