B2I_PVK_BIO_EX(3SSL)
π b2i_PVK_bio, b2i_PVK_bio_ex, i2b_PVK_bio, i2b_PVK_bio_ex β the OpenSSL girlies π
okay bestie, welcome to B2I_PVK_BIO_EX, a page from the OpenSSL manual (section 3SSL, the library functions section). This one is about a little family of four functions whose whole job is decoding and encoding MSBLOB format private keys β so like, reading them in and writing them back out. Grab a strawberry π and let's go.
β¨ NAME β¨
b2i_PVK_bio, b2i_PVK_bio_ex, i2b_PVK_bio, i2b_PVK_bio_ex β Decode and encode functions for reading and writing MSBLOB format private keys. π
πΈ SYNOPSIS πΈ
#include <openssl/pem.h>
EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
EVP_PKEY *b2i_PVK_bio_ex(BIO *in, pem_password_cb *cb, void *u,
OSSL_LIB_CTX *libctx, const char *propq);
int i2b_PVK_bio(BIO *out, const EVP_PKEY *pk, int enclevel,
pem_password_cb *cb, void *u);
int i2b_PVK_bio_ex(BIO *out, const EVP_PKEY *pk, int enclevel,
pem_password_cb *cb, void *u,
OSSL_LIB_CTX *libctx, const char *propq);
like, they're all in <openssl/pem.h, and the _ex girlies just get extra args at the end (libctx and propq). iykyk π
π DESCRIPTION π
π¦ The decode era: b2i_PVK_bio_ex() and b2i_PVK_bio()
So b2i_PVK_bio_ex() decodes a private key of MSBLOB format that it reads from a BIO. It's giving "let me figure this out myself" energy because it attempts to automatically determine the key type. no cap.
And if the key is encrypted? Then cb gets called with the user data u, all so it can get a password to decrypt that key. π
The supplied library context libctx and property query string propq are used in any decrypt operation. periodt.
Then b2i_PVK_bio() does exactly the same thing as b2i_PVK_bio_ex() β literally identical, bestie β except that the default library context and property query string are used. that's the whole difference. π
π The encode era: i2b_PVK_bio_ex() and i2b_PVK_bio()
i2b_PVK_bio_ex() encodes pk using MSBLOB format. slay.
Now listen, this part matters:
- if
enclevelis1β a password obtained viapem_password_cbis used to encrypt the private key π - if
enclevelis0β no encryption is applied at all. bare. open. π
The user data in u is passed to the password callback. And the supplied library context libctx and property query string propq are used in any decrypt operation.
And i2b_PVK_bio() does the same as i2b_PVK_bio_ex(), except that the default library context and property query string are used. iconic behavior, honestly.
π RETURN VALUES π
b2i_PVK_bio() and b2i_PVK_bio_ex()
They return a valid EVP_KEY structure. or NULL if an error occurs π. You can get that error code by calling ERR_get_error(3).
i2b_PVK_bio() and i2b_PVK_bio_ex()
They return the number of bytes successfully encoded, or a negative value if an error occurs. Again, the error code can be obtained by calling ERR_get_error(3). π«Ά
π₯ SEE ALSO π₯
β HISTORY β
b2i_PVK_bio_ex() and i2b_PVK_bio_ex() were added in OpenSSL 3.0. the _ex girls are the new kids, and they ate. β¨
π COPYRIGHT π
Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
okay bestie real talk: don't sleep on the license, fr fr. read it before you go using this file. π
and that's the whole page, no notes, 10/10. this was OpenSSL 4.0.3, dated 2026-09-29 β main character energy from start to finish. go forth and handle your MSBLOB keys, babes π§π πΈ
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms