BIO_S_CORE(3ossl)
π BIO_S_CORE π
okay so you found the BIO_S_CORE(3ossl) manual page and honestly? iconic of you. this one's for the provider authors out there, iykyk π«Ά
β¨ NAME β¨
BIO_s_core, BIO_new_from_core_bio β the OSSL_CORE_BIO functions, bestie. that's the whole vibe. π
β¨ SYNOPSIS β¨
#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 back the core BIO method function. that's it. that's the function. β¨
a core BIO is treated as a source/sink BIO which communicates to some external BIO. primarily useful to provider authors, fr fr β a whole bunch of calls coming from libcrypto into a provider will hand you an OSSL_CORE_BIO parameter. it represents a BIO inside libcrypto, but bestieβ¦ you literally cannot use it directly as a provider π. instead it should be wrapped using a BIO_s_core().
once a BIO is constructed based on BIO_s_core(), the associated OSSL_CORE_BIO object should be set on it using BIO_set_data(3). β οΈ and here's the part where you gotta pay attention: the BIO will only operate correctly if it is associated with a library context constructed using OSSL_LIB_CTX_new_from_dispatch(3). to associate the BIO with a library context, construct it using BIO_new_ex(3). no shortcuts, bestie. π
BIO_new_from_core_bio() is the convenience function β the main character of this page honestly β and it constructs a new BIO based on BIO_s_core() that's associated with the given library context. then it also sets the OSSL_CORE_BIO object on the BIO using BIO_set_data(3). two steps, one function, we love efficiency. π
β¨ RETURN VALUES β¨
BIO_s_core()β returns a core BIOBIO_METHODstructure. πBIO_new_from_core_bio()β returns aBIOstructure on success, orNULLon failure. and when it fails? most commonly it's because the library context was not constructed usingOSSL_LIB_CTX_new_from_dispatch(3). so likeβ¦ check that first before you spiral. π
β¨ HISTORY β¨
BIO_s_core() and BIO_new_from_core_bio() were added in OpenSSL 3.0. glow-up era. β
β¨ EXAMPLES β¨
create a core BIO and write some data to it, periodt:
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;
}
look at that NULL check. look at that BIO_free. we love a responsible queen. πβ¨
β¨ 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>.
okay that's the whole page, bestie, you ate that π and for the sign-off: this was version 3.5.9, dated 2026-09-29 β go forth and wrap those BIOs responsibly π¦πΈ
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms