1 .\" $OpenBSD: BIO_meth_new.3,v 1.5 2018/07/09 09:52:18 tb Exp $
2 .\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3 .\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
5 .\" This file is a derived work.
6 .\" The changes are covered by the following Copyright and license:
8 .\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
10 .\" Permission to use, copy, modify, and distribute this software for any
11 .\" purpose with or without fee is hereby granted, provided that the above
12 .\" copyright notice and this permission notice appear in all copies.
14 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 .\" The original file was written by Matt Caswell <matt@openssl.org>
23 .\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
25 .\" Redistribution and use in source and binary forms, with or without
26 .\" modification, are permitted provided that the following conditions
29 .\" 1. Redistributions of source code must retain the above copyright
30 .\" notice, this list of conditions and the following disclaimer.
32 .\" 2. Redistributions in binary form must reproduce the above copyright
33 .\" notice, this list of conditions and the following disclaimer in
34 .\" the documentation and/or other materials provided with the
37 .\" 3. All advertising materials mentioning features or use of this
38 .\" software must display the following acknowledgment:
39 .\" "This product includes software developed by the OpenSSL Project
40 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43 .\" endorse or promote products derived from this software without
44 .\" prior written permission. For written permission, please contact
45 .\" openssl-core@openssl.org.
47 .\" 5. Products derived from this software may not be called "OpenSSL"
48 .\" nor may "OpenSSL" appear in their names without prior written
49 .\" permission of the OpenSSL Project.
51 .\" 6. Redistributions of any form whatsoever must retain the following
53 .\" "This product includes software developed by the OpenSSL Project
54 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
69 .Dd $Mdocdate: July 9 2018 $
73 .Nm BIO_get_new_index ,
76 .Nm BIO_meth_get_write ,
77 .Nm BIO_meth_set_write ,
78 .Nm BIO_meth_get_read ,
79 .Nm BIO_meth_set_read ,
80 .Nm BIO_meth_get_puts ,
81 .Nm BIO_meth_set_puts ,
82 .Nm BIO_meth_get_gets ,
83 .Nm BIO_meth_set_gets ,
84 .Nm BIO_meth_get_ctrl ,
85 .Nm BIO_meth_set_ctrl ,
86 .Nm BIO_meth_get_create ,
87 .Nm BIO_meth_set_create ,
88 .Nm BIO_meth_get_destroy ,
89 .Nm BIO_meth_set_destroy ,
90 .Nm BIO_meth_get_callback_ctrl ,
91 .Nm BIO_meth_set_callback_ctrl
92 .Nd manipulate BIO_METHOD structures
96 .Fn BIO_get_new_index void
100 .Fa "const char *name"
104 .Fa "BIO_METHOD *biom"
107 .Fn "(*BIO_meth_get_write(const BIO_METHOD *biom))" "BIO *" "const char *" int
109 .Fo BIO_meth_set_write
110 .Fa "BIO_METHOD *biom"
111 .Fa "int (*write)(BIO *, const char *, int)"
114 .Fn "(*BIO_meth_get_read(const BIO_METHOD *biom))" "BIO *" "char *" int
116 .Fo BIO_meth_set_read
117 .Fa "BIO_METHOD *biom"
118 .Fa "int (*read)(BIO *, char *, int)"
121 .Fn "(*BIO_meth_get_puts(const BIO_METHOD *biom))" "BIO *" "const char *"
123 .Fo BIO_meth_set_puts
124 .Fa "BIO_METHOD *biom"
125 .Fa "int (*puts)(BIO *, const char *)"
128 .Fn "(*BIO_meth_get_gets(const BIO_METHOD *biom))" "BIO *" "char *" int
130 .Fo BIO_meth_set_gets
131 .Fa "BIO_METHOD *biom"
132 .Fa "int (*gets)(BIO *, char *, int)"
135 .Fn "(*BIO_meth_get_ctrl(const BIO_METHOD *biom))" "BIO *" int long "void *"
137 .Fo BIO_meth_set_ctrl
138 .Fa "BIO_METHOD *biom"
139 .Fa "long (*ctrl)(BIO *, int, long, void *)"
142 .Fn "(*BIO_meth_get_create(const BIO_METHOD *biom))" "BIO *"
144 .Fo BIO_meth_set_create
145 .Fa "BIO_METHOD *biom"
146 .Fa "int (*create)(BIO *)"
149 .Fn "(*BIO_meth_get_destroy(const BIO_METHOD *biom))" "BIO *"
151 .Fo BIO_meth_set_destroy
152 .Fa "BIO_METHOD *biom"
153 .Fa "int (*destroy)(BIO *)"
156 .Fo "(*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))"
162 .Fo BIO_meth_set_callback_ctrl
163 .Fa "BIO_METHOD *biom"
164 .Fa "long (*callback_ctrl)(BIO *, int, BIO_info_cb *)"
169 structure stores function pointers implementing a
174 for more information about
182 It requires a unique integer
185 .Fn BIO_get_new_index
188 Currently, the user can only create up to 127 different BIO types, and
190 is limited to the range 129\(en255.
193 pointer is stored in the structure and will not be freed by
196 The standard BIO types are listed in
198 Some examples include
201 .Dv BIO_TYPE_CIPHER .
204 of filter BIOs should have the
207 Source/sink BIOs should have the
208 .Dv BIO_TYPE_SOURCE_SINK
210 File descriptor based BIOs (e.g. socket, fd, connect, accept etc.\&)
211 should additionally have the
212 .Dv BIO_TYPE_DESCRIPTOR
216 for more information.
222 .Fn BIO_meth_get_write ,
223 .Fn BIO_meth_set_write ,
224 .Fn BIO_meth_get_read ,
226 .Fn BIO_meth_set_read
227 get and set the functions
231 used for writing and reading arbitrary length data to and from the
233 These functions are called from
238 The parameters and return values of
242 have the same meaning as for
247 .Fn BIO_meth_get_puts
249 .Fn BIO_meth_set_puts
250 get and set the function
252 used for writing a NUL-terminated string to the
254 This function is called from
256 The parameters and the return value of
258 have the same meaning as for
261 .Fn BIO_meth_get_gets
263 .Fn BIO_meth_set_gets
264 get and set the function
266 used for reading a line of data from the
268 This function is called from
270 The parameters and the return value of
272 have the same meaning as for
275 .Fn BIO_meth_get_ctrl
277 .Fn BIO_meth_set_ctrl
278 get and set the function
280 used for processing control messages in the
282 This function is called from
284 The parameters and return value of
286 have the same meaning as for
289 .Fn BIO_meth_get_create
291 .Fn BIO_meth_set_create
292 get and set a function
294 used while initializing a new instance of the
296 This function is called from
300 function allocates the memory for the new
302 and a pointer to this newly allocated structure is passed
306 .Fn BIO_meth_get_destroy
308 .Fn BIO_meth_set_destroy
309 get and set a function
311 used while destroying an instance of a
313 This function is called from
317 to be destroyed is passed as the parameter.
320 function is intended to perform clean-up specific to the
325 itself must not be freed by this function.
327 .Fn BIO_meth_get_callback_ctrl
329 .Fn BIO_meth_set_callback_ctrl
330 get and set the function
332 used for processing callback control messages in the
334 This function is called from
335 .Xr BIO_callback_ctrl 3 .
336 The parameters and return value of
338 have the same meaning as for
339 .Xr BIO_callback_ctrl 3 .
341 .Fn BIO_get_new_index
342 returns the new BIO type value or \-1 if an error occurs.
353 functions return 1 on success or 0 on error.
354 Currently, they cannot fail.
358 functions return function pointers.
361 .Xr BIO_find_type 3 ,
365 These functions first appeared in OpenSSL 1.1.0
366 and have been available since