D2I_PKCS8PRIVATEKEY_BIO(3)
πΈ NAME πΈ
okay bestie, welcome to D2I_PKCS8PRIVATEKEY_BIO(3) from the Library Functions Manual β yes, the name is a whole tongue-twister, but it's iconic π
. This page is all about:
d2i_PKCS8PrivateKey_biod2i_PKCS8PrivateKey_fpi2d_PKCS8PrivateKey_bioi2d_PKCS8PrivateKey_fpi2d_PKCS8PrivateKey_nid_bioi2d_PKCS8PrivateKey_nid_fp
β¦and they're the PKCS#8 format private key functions. Slay.
β¨ SYNOPSIS β¨
library βlibcryptoβ #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 π
So the PKCS#8 functions encode and decode private keys in PKCS#8 format, and they use both PKCS#5 v1.5 and PKCS#5 v2.0 password based encryption algorithms. Very demure, very mindful π.
Other than the use of DER as opposed to PEM, these functions are identical to the corresponding functions described in PEM_read_PrivateKey(3). Like, same energy, different format bestie β¨.
These functions are currently the only way to store encrypted private keys using DER format. That's the whole main character moment right there π.
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. No cap, that's the workaround π.
π RETURN VALUES π
d2i_PKCS8PrivateKey_bio()andd2i_PKCS8PrivateKey_fp()return aEVP_PKEYobject orNULLif an error occurs. Bestie either gets the key or getsNULL, no in-between π.i2d_PKCS8PrivateKey_bio(),i2d_PKCS8PrivateKey_fp(),i2d_PKCS8PrivateKey_nid_bio(), andi2d_PKCS8PrivateKey_nid_fp()return1on success or0on error. Clean, simple, periodt π .
π₯ SEE ALSO π₯
π¦ HISTORY π¦
These functions first appeared in OpenSSL 0.9.5 and have been available since OpenBSD 2.7. Little legends from way back, fr fr π«Ά.
π CAVEATS π
Do not confuse these functions withi2d_PKCS8PrivateKeyInfo_bio(3)andi2d_PKCS8PrivateKeyInfo_fp(3), which write out private keys in unencrypted DER format. That's a different vibe entirely, and you do not want to mix them up bestie π.
kisses and sparkles, this cute little page is from Debian, dated June 8, 2025, and its title is D2I_PKCS8PRIVATEKEY_BIO(3) ππ
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2002, 2016, 2017 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms