BIO_S_CORE(3ossl)
π BIO_S_CORE β the OpenSSL 3ossl girlie's guide
okay so real talk, this one's for the provider authors out there β the 3ossl girlies building the actual crypto machinery. It's BIO_s_core and BIO_new_from_core_bio, aka the OSSL_CORE_BIO functions. Come sit with me, I gotchu. π«Ά
β¨ SYNOPSIS β¨
like, the whole vibe in two lines:
#include <openssl/bio.h>
const BIO_METHOD *BIO_s_core(void);
BIO *BIO_new_from_core_bio(OSSL_LIB_CTX *libctx, OSSL_CORE_BIO *corebio);
πΈ DESCRIPTION πΈ
So BIO_s_core() hands you the core BIO method function. That's it. That's the whole job. β¨
A core BIO is lowkey a source/sink BIO that talks to some external BIO. It's giving middleman, but in a useful way. This is primarily useful to provider authors β iykyk. Because here's the tea: a bunch of calls coming from libcrypto into a provider hand you an OSSL_CORE_BIO parameter. That thing represents a BIO inside libcrypto, and you literally cannot use it directly from a provider. Rude, I know. Instead you have to wrap it using a BIO_s_core(). π
Once you've constructed a BIO based on BIO_s_core(), you set the associated OSSL_CORE_BIO object on it with BIO_set_data(3). But bestie, listen β the BIO will only operate correctly if it's associated with a library context constructed using OSSL_LIB_CTX_new_from_dispatch(3). That's not optional, that's the vibe check. To associate the BIO with a library context, construct it using BIO_new_ex(3).
Then there's BIO_new_from_core_bio() β the convenience function, the main character, the one who does it all for you. π It constructs a new BIO based on BIO_s_core(), associates it with the library context you gave it, and also sets the OSSL_CORE_BIO object on the BIO using BIO_set_data(3). Two steps, one function, no notes. π
π¦ RETURN VALUES π¦
BIO_s_core()returns a core BIOBIO_METHODstructure. Slay.BIO_new_from_core_bio()returns aBIOstructure on success, orNULLon failure. And what's the most common reason for failure? Bestie. It's because the library context wasn't constructed usingOSSL_LIB_CTX_new_from_dispatch(3). That's it, that's the gotcha. π
β HISTORY β
BIO_s_core() and BIO_new_from_core_bio() were added in OpenSSL 3.0. Icons only. π
π₯ EXAMPLES π₯
Create a core BIO and write some data to it β watch me:
int some_function(OSSL_LIB_CTX *libctx, OSSL_CORE_BIO *corebio) {
BIO *cbio = BIO_new_from_core_bio(libctx, corebio);
if (cbio == NULL)
return 0;
BIO_puts(cbio, "Hello World\n");
BIO_free(cbio);
return 1;
}
Hello World\n β the original flex. Never gets old. π
π COPYRIGHT π
Copyright 2021-2022 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>.
k bye bestie!! π§ This has been BIO_S_CORE(3ossl) from the OpenSSL fam β version 3.5.6, dated 2026-04-07. Go wrap those core BIOs, you got this, mwah ππ
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms