xref: /freebsd-src/crypto/openssl/doc/man7/bio.pod (revision e71b70530d95c4f34d8bdbd78d1242df1ba4a945)
1*e71b7053SJung-uk Kim=pod
2*e71b7053SJung-uk Kim
3*e71b7053SJung-uk Kim=head1 NAME
4*e71b7053SJung-uk Kim
5*e71b7053SJung-uk Kimbio - Basic I/O abstraction
6*e71b7053SJung-uk Kim
7*e71b7053SJung-uk Kim=head1 SYNOPSIS
8*e71b7053SJung-uk Kim
9*e71b7053SJung-uk Kim=for comment generic
10*e71b7053SJung-uk Kim
11*e71b7053SJung-uk Kim #include <openssl/bio.h>
12*e71b7053SJung-uk Kim
13*e71b7053SJung-uk Kim=head1 DESCRIPTION
14*e71b7053SJung-uk Kim
15*e71b7053SJung-uk KimA BIO is an I/O abstraction, it hides many of the underlying I/O
16*e71b7053SJung-uk Kimdetails from an application. If an application uses a BIO for its
17*e71b7053SJung-uk KimI/O it can transparently handle SSL connections, unencrypted network
18*e71b7053SJung-uk Kimconnections and file I/O.
19*e71b7053SJung-uk Kim
20*e71b7053SJung-uk KimThere are two type of BIO, a source/sink BIO and a filter BIO.
21*e71b7053SJung-uk Kim
22*e71b7053SJung-uk KimAs its name implies a source/sink BIO is a source and/or sink of data,
23*e71b7053SJung-uk Kimexamples include a socket BIO and a file BIO.
24*e71b7053SJung-uk Kim
25*e71b7053SJung-uk KimA filter BIO takes data from one BIO and passes it through to
26*e71b7053SJung-uk Kimanother, or the application. The data may be left unmodified (for
27*e71b7053SJung-uk Kimexample a message digest BIO) or translated (for example an
28*e71b7053SJung-uk Kimencryption BIO). The effect of a filter BIO may change according
29*e71b7053SJung-uk Kimto the I/O operation it is performing: for example an encryption
30*e71b7053SJung-uk KimBIO will encrypt data if it is being written to and decrypt data
31*e71b7053SJung-uk Kimif it is being read from.
32*e71b7053SJung-uk Kim
33*e71b7053SJung-uk KimBIOs can be joined together to form a chain (a single BIO is a chain
34*e71b7053SJung-uk Kimwith one component). A chain normally consist of one source/sink
35*e71b7053SJung-uk KimBIO and one or more filter BIOs. Data read from or written to the
36*e71b7053SJung-uk Kimfirst BIO then traverses the chain to the end (normally a source/sink
37*e71b7053SJung-uk KimBIO).
38*e71b7053SJung-uk Kim
39*e71b7053SJung-uk Kim
40*e71b7053SJung-uk KimSome BIOs (such as memory BIOs) can be used immediately after calling
41*e71b7053SJung-uk KimBIO_new(). Others (such as file BIOs) need some additional initialization,
42*e71b7053SJung-uk Kimand frequently a utility function exists to create and initialize such BIOs.
43*e71b7053SJung-uk Kim
44*e71b7053SJung-uk KimIf BIO_free() is called on a BIO chain it will only free one BIO resulting
45*e71b7053SJung-uk Kimin a memory leak.
46*e71b7053SJung-uk Kim
47*e71b7053SJung-uk KimCalling BIO_free_all() on a single BIO has the same effect as calling
48*e71b7053SJung-uk KimBIO_free() on it other than the discarded return value.
49*e71b7053SJung-uk Kim
50*e71b7053SJung-uk KimNormally the B<type> argument is supplied by a function which returns a
51*e71b7053SJung-uk Kimpointer to a BIO_METHOD. There is a naming convention for such functions:
52*e71b7053SJung-uk Kima source/sink BIO is normally called BIO_s_*() and a filter BIO
53*e71b7053SJung-uk KimBIO_f_*();
54*e71b7053SJung-uk Kim
55*e71b7053SJung-uk Kim=head1 EXAMPLE
56*e71b7053SJung-uk Kim
57*e71b7053SJung-uk KimCreate a memory BIO:
58*e71b7053SJung-uk Kim
59*e71b7053SJung-uk Kim BIO *mem = BIO_new(BIO_s_mem());
60*e71b7053SJung-uk Kim
61*e71b7053SJung-uk Kim=head1 SEE ALSO
62*e71b7053SJung-uk Kim
63*e71b7053SJung-uk KimL<BIO_ctrl(3)>,
64*e71b7053SJung-uk KimL<BIO_f_base64(3)>, L<BIO_f_buffer(3)>,
65*e71b7053SJung-uk KimL<BIO_f_cipher(3)>, L<BIO_f_md(3)>,
66*e71b7053SJung-uk KimL<BIO_f_null(3)>, L<BIO_f_ssl(3)>,
67*e71b7053SJung-uk KimL<BIO_find_type(3)>, L<BIO_new(3)>,
68*e71b7053SJung-uk KimL<BIO_new_bio_pair(3)>,
69*e71b7053SJung-uk KimL<BIO_push(3)>, L<BIO_read_ex(3)>,
70*e71b7053SJung-uk KimL<BIO_s_accept(3)>, L<BIO_s_bio(3)>,
71*e71b7053SJung-uk KimL<BIO_s_connect(3)>, L<BIO_s_fd(3)>,
72*e71b7053SJung-uk KimL<BIO_s_file(3)>, L<BIO_s_mem(3)>,
73*e71b7053SJung-uk KimL<BIO_s_null(3)>, L<BIO_s_socket(3)>,
74*e71b7053SJung-uk KimL<BIO_set_callback(3)>,
75*e71b7053SJung-uk KimL<BIO_should_retry(3)>
76*e71b7053SJung-uk Kim
77*e71b7053SJung-uk Kim=head1 COPYRIGHT
78*e71b7053SJung-uk Kim
79*e71b7053SJung-uk KimCopyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
80*e71b7053SJung-uk Kim
81*e71b7053SJung-uk KimLicensed under the OpenSSL license (the "License").  You may not use
82*e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
83*e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
84*e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
85*e71b7053SJung-uk Kim
86*e71b7053SJung-uk Kim=cut
87*e71b7053SJung-uk Kim
88