1 .\" $OpenBSD: BIO_new.3,v 1.8 2017/03/25 17:15:59 schwarze Exp $
2 .\" OpenSSL doc/man3/BIO_new.pod ca3a82c3 Mar 25 11:31:18 2015 -0400
3 .\" OpenSSL doc/man7/bio.pod a9c85cea Nov 11 09:33:55 2016 +0100
5 .\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
6 .\" Copyright (c) 2000, 2015, 2016 The OpenSSL Project. All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in
17 .\" the documentation and/or other materials provided with the
20 .\" 3. All advertising materials mentioning features or use of this
21 .\" software must display the following acknowledgment:
22 .\" "This product includes software developed by the OpenSSL Project
23 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 .\" endorse or promote products derived from this software without
27 .\" prior written permission. For written permission, please contact
28 .\" openssl-core@openssl.org.
30 .\" 5. Products derived from this software may not be called "OpenSSL"
31 .\" nor may "OpenSSL" appear in their names without prior written
32 .\" permission of the OpenSSL Project.
34 .\" 6. Redistributions of any form whatsoever must retain the following
36 .\" "This product includes software developed by the OpenSSL Project
37 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
52 .Dd $Mdocdate: March 25 2017 $
61 .Nd construct and destruct I/O abstraction objects
66 .Fa "BIO_METHOD *type"
71 .Fa "BIO_METHOD *type"
88 is an I/O abstraction object, hiding many of the underlying I/O
89 details from an application.
90 If an application uses BIOs for its I/O, it can transparently handle
91 SSL connections, unencrypted network connections, and file I/O.
95 function constructs a new
99 There are two groups of BIO types, source/sink BIOs and filter BIOs.
101 Source/sink BIOs provide input or consume output.
102 Examples include socket BIOs and file BIOs.
104 Filter BIOs take data from one BIO and pass it through to another,
105 or to the application, forming a chain of BIOs.
106 The data may be left unmodified (for example by a message digest BIO)
107 or translated (for example by an encryption BIO).
108 The effect of a filter BIO may change according to the I/O operation
109 it is performing: for example an encryption BIO will encrypt data
110 if it is written to and decrypt data if it is read from.
112 Some BIOs (such as memory BIOs) can be used immediately after calling
114 Others (such as file BIOs) need some additional initialization, and
115 utility functions exists to construct and initialize such BIOs.
119 argument is supplied by a function which returns a pointer to a
121 There is a naming convention for such functions:
122 the methods for source/sink BIOs are called
124 and those for filter BIOs
128 sets the method of an already existing BIO.
133 destruct a single BIO, which may also have some effect on the
134 underlying I/O structure, for example it may close the file being
135 referred to under certain circumstances.
140 pointer, no action occurs.
143 is called on a BIO chain, it will only destruct one BIO,
144 resulting in a memory leak.
147 destructs an entire BIO chain.
148 It does not halt if an error occurs
149 destructing an individual BIO in the chain.
154 pointer, no action occurs.
157 on a single BIO has the same effect as
160 Common I/O functions are documented in
162 Forming chains is explained in
164 inspecting them is explained in
165 .Xr BIO_find_type 3 .
166 For more details about the different kinds of BIOs, see the individual
171 returns a newly constructed
180 return 1 for success or 0 for failure.
184 .Dl BIO *mem = BIO_new(BIO_s_mem());
193 .Xr BIO_find_type 3 ,
194 .Xr BIO_get_ex_new_index 3 ,
200 .Xr BIO_s_connect 3 ,
206 .Xr BIO_set_callback 3 ,
207 .Xr BIO_should_retry 3