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 BIO BIO_METHOD structure. πŸ’–
  • BIO_new_from_core_bio() β€” returns a BIO structure on success, or NULL on failure. and when it fails? most commonly it's because the library context was not constructed using OSSL_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 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