xref: /openssl/doc/man3/BIO_s_core.pod (revision fecb3aae)
1=pod
2
3=head1 NAME
4
5BIO_s_core, BIO_new_from_core_bio - OSSL_CORE_BIO functions
6
7=head1 SYNOPSIS
8
9 #include <openssl/bio.h>
10
11 const BIO_METHOD *BIO_s_core(void);
12
13 BIO *BIO_new_from_core_bio(OSSL_LIB_CTX *libctx, OSSL_CORE_BIO *corebio);
14
15=head1 DESCRIPTION
16
17BIO_s_core() returns the core BIO method function.
18
19A core BIO is treated as source/sink BIO which communicates to some external
20BIO. This is primarily useful to provider authors. A number of calls from
21libcrypto into a provider supply an OSSL_CORE_BIO parameter. This represents
22a BIO within libcrypto, but cannot be used directly by a provider. Instead it
23should be wrapped using a BIO_s_core().
24
25Once a BIO is constructed based on BIO_s_core(), the associated OSSL_CORE_BIO
26object should be set on it using BIO_set_data(3). Note that the BIO will only
27operate correctly if it is associated with a library context constructed using
28OSSL_LIB_CTX_new_from_dispatch(3). To associate the BIO with a library context
29construct it using BIO_new_ex(3).
30
31BIO_new_from_core_bio() is a convenience function that constructs a new BIO
32based on BIO_s_core() and that is associated with the given library context. It
33then also sets the OSSL_CORE_BIO object on the BIO using BIO_set_data(3).
34
35=head1 RETURN VALUES
36
37BIO_s_core() return a core BIO B<BIO_METHOD> structure.
38
39BIO_new_from_core_bio() returns a BIO structure on success or NULL on failure.
40A failure will most commonly be because the library context was not constructed
41using OSSL_LIB_CTX_new_from_dispatch(3).
42
43=head1 HISTORY
44
45BIO_s_core() and BIO_new_from_core_bio() were added in OpenSSL 3.0.
46
47=head1 EXAMPLES
48
49Create a core BIO and write some data to it:
50
51 int some_function(OSSL_LIB_CTX *libctx, OSSL_CORE_BIO *corebio) {
52     BIO *cbio = BIO_new_from_core_bio(libctx, corebio);
53
54     if (cbio == NULL)
55         return 0;
56
57     BIO_puts(cbio, "Hello World\n");
58
59     BIO_free(cbio);
60     return 1;
61 }
62
63=head1 COPYRIGHT
64
65Copyright 2021-2022 The OpenSSL Project Authors. All Rights Reserved.
66
67Licensed under the Apache License 2.0 (the "License").  You may not use
68this file except in compliance with the License.  You can obtain a copy
69in the file LICENSE in the source distribution or at
70L<https://www.openssl.org/source/license.html>.
71
72=cut
73