BIO_S_CORE(3SSL)

πŸ’– BIO_S_CORE πŸ’– (that's the 3SSL page from the OpenSSL manual, bestie)

okay so listen. this is the page for BIO_s_core and BIO_new_from_core_bio, aka the OSSL_CORE_BIO functions, and if you're a provider author you're gonna wanna lock in because this is literally your whole vibe. 🧚✨


🌸 NAME 🌸

BIO_s_core, BIO_new_from_core_bio β€” OSSL_CORE_BIO functions πŸ’…


✨ 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 πŸ¦‹

BIO_s_core() hands you back the core BIO method function. that's it, that's the whole job. 🫢

okay so a core BIO is treated as a source/sink BIO that communicates to some external BIO. ngl this is mostly for provider authors β€” if that's you, hi bestie, this page is for you. πŸ‘‘

here's the tea: a bunch of calls from libcrypto into a provider will supply you an OSSL_CORE_BIO parameter. and like… that thing represents a BIO inside libcrypto, but you cannot use it directly from a provider. no cap. 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). ✍️ but note: 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). iykyk πŸ’œ

BIO_new_from_core_bio() is the convenience function of the group chat β€” it constructs a new BIO based on BIO_s_core() and associates it with the given library context. then it also sets the OSSL_CORE_BIO object on the BIO using BIO_set_data(3). it's giving "i did the two steps for you, you're welcome." πŸŽ€


⭐ 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 a failure will most commonly be because the library context was not constructed using OSSL_LIB_CTX_new_from_dispatch(3). yeah. that one. we talked about it. 😭

🌈 HISTORY 🌈

BIO_s_core() and BIO_new_from_core_bio() were added in OpenSSL 3.0. so they're not ancient, they're just iconic. πŸ’…


πŸ”₯ EXAMPLES πŸ”₯

create a core BIO and write some data to it β€” here's the moment, the main character energy:

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. "Hello World\n". slay. πŸ“βœ¨


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>.

fr fr, read the license, it's not optional bestie πŸ™ˆ

and that's the whole page!! this was 4.0.3, dated 2026-09-29, and you were reading the BIO_S_CORE(3SSL) page the entire time. go wrap your OSSL_CORE_BIO, set your data, and get your library context from OSSL_LIB_CTX_new_from_dispatch(3). mwah. πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from