summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2022-12-16 23:56:57 +0000
committerschwarze <>2022-12-16 23:56:57 +0000
commite80fdd27afb9f1771736f998fd39b30cd3ecc8f3 (patch)
tree16e293377ebe4284fa981c6754b0295b9eb8044a
parent68cfe389d0ebb0d9cc9db2fd372db328d5499e1c (diff)
downloadopenbsd-e80fdd27afb9f1771736f998fd39b30cd3ecc8f3.tar.gz
openbsd-e80fdd27afb9f1771736f998fd39b30cd3ecc8f3.tar.bz2
openbsd-e80fdd27afb9f1771736f998fd39b30cd3ecc8f3.zip
In bio.h rev. 1.54, jsing@ and tb@ provided BIO_callback_fn_ex(3),
BIO_set_callback_ex(3), BIO_get_callback_ex(3), and BIO_callback_fn(3). Document them, in part by merging from the OpenSSL 1.1.1 branch, which is still under a free license, but heavily tweaked by me, in particular: * mention that BIO_set_callback_arg(3) is misnamed; * keep our more detailed explanation of the "ret" argument; * make the list of callback invocations more readable; * and update the HISTORY section.
-rw-r--r--src/lib/libcrypto/man/BIO_set_callback.3269
1 files changed, 192 insertions, 77 deletions
diff --git a/src/lib/libcrypto/man/BIO_set_callback.3 b/src/lib/libcrypto/man/BIO_set_callback.3
index 34b7c07a9f..248cdb5112 100644
--- a/src/lib/libcrypto/man/BIO_set_callback.3
+++ b/src/lib/libcrypto/man/BIO_set_callback.3
@@ -1,11 +1,10 @@
1.\" $OpenBSD: BIO_set_callback.3,v 1.9 2018/03/29 20:42:17 schwarze Exp $ 1.\" $OpenBSD: BIO_set_callback.3,v 1.10 2022/12/16 23:56:57 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
4.\" 3.\"
5.\" This file is a derived work. 4.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license: 5.\" The changes are covered by the following Copyright and license:
7.\" 6.\"
8.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org> 7.\" Copyright (c) 2018, 2022 Ingo Schwarze <schwarze@openbsd.org>
9.\" 8.\"
10.\" Permission to use, copy, modify, and distribute this software for any 9.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above 10.\" purpose with or without fee is hereby granted, provided that the above
@@ -66,10 +65,14 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 67.\"
69.Dd $Mdocdate: March 29 2018 $ 68.Dd $Mdocdate: December 16 2022 $
70.Dt BIO_SET_CALLBACK 3 69.Dt BIO_SET_CALLBACK 3
71.Os 70.Os
72.Sh NAME 71.Sh NAME
72.Nm BIO_callback_fn_ex ,
73.Nm BIO_set_callback_ex ,
74.Nm BIO_get_callback_ex ,
75.Nm BIO_callback_fn ,
73.Nm BIO_set_callback , 76.Nm BIO_set_callback ,
74.Nm BIO_get_callback , 77.Nm BIO_get_callback ,
75.Nm BIO_set_callback_arg , 78.Nm BIO_set_callback_arg ,
@@ -78,6 +81,35 @@
78.Nd BIO callback functions 81.Nd BIO callback functions
79.Sh SYNOPSIS 82.Sh SYNOPSIS
80.In openssl/bio.h 83.In openssl/bio.h
84.Ft typedef long
85.Fo (*BIO_callback_fn_ex)
86.Fa "BIO *b"
87.Fa "int oper"
88.Fa "const char *argp"
89.Fa "size_t len"
90.Fa "int argi"
91.Fa "long argl"
92.Fa "int ret"
93.Fa "size_t *processed"
94.Fc
95.Ft void
96.Fo BIO_set_callback_ex
97.Fa "BIO *b"
98.Fa "BIO_callback_fn_ex cb_ex"
99.Fc
100.Ft BIO_callback_fn_ex
101.Fo BIO_get_callback_ex
102.Fa "const BIO *b"
103.Fc
104.Ft typedef long
105.Fo (*BIO_callback_fn)
106.Fa "BIO *b"
107.Fa "int oper"
108.Fa "const char *argp"
109.Fa "int argi"
110.Fa "long argl"
111.Fa "long ret"
112.Fc
81.Ft void 113.Ft void
82.Fo BIO_set_callback 114.Fo BIO_set_callback
83.Fa "BIO *b" 115.Fa "BIO *b"
@@ -90,7 +122,7 @@
90.Ft void 122.Ft void
91.Fo BIO_set_callback_arg 123.Fo BIO_set_callback_arg
92.Fa "BIO *b" 124.Fa "BIO *b"
93.Fa "char *arg" 125.Fa "char *pointer"
94.Fc 126.Fc
95.Ft char * 127.Ft char *
96.Fo BIO_get_callback_arg 128.Fo BIO_get_callback_arg
@@ -105,60 +137,75 @@
105.Fa "long argl" 137.Fa "long argl"
106.Fa "long ret" 138.Fa "long ret"
107.Fc 139.Fc
108.Ft typedef long
109.Fo "(*BIO_callback_fn)"
110.Fa "BIO *b"
111.Fa "int oper"
112.Fa "const char *argp"
113.Fa "int argi"
114.Fa "long argl"
115.Fa "long ret"
116.Fc
117.Sh DESCRIPTION 140.Sh DESCRIPTION
118.Fn BIO_set_callback 141.Fn BIO_set_callback_ex
119and 142and
120.Fn BIO_get_callback 143.Fn BIO_get_callback_ex
121set and retrieve the BIO callback. 144set and retrieve the BIO callback.
122The callback is called during most high level BIO operations. 145The callback is called during most high-level BIO operations.
123It can be used for debugging purposes to trace operations on a BIO 146It can be used for debugging purposes to trace operations on a BIO
124or to modify its operation. 147or to modify its operation.
125.Pp 148.Pp
149.Fn BIO_set_callback
150and
151.Fn BIO_get_callback
152are deprecated functions that set and retrieve the old-style BIO callback,
153which is only used if no new-style callback is set with
154.Fn BIO_set_callback_ex .
155.Pp
126.Fn BIO_set_callback_arg 156.Fn BIO_set_callback_arg
157stores the
158.Fa pointer
159internally in
160.Fa b
127and 161and
128.Fn BIO_get_callback_arg 162.Fn BIO_get_callback_arg
129set and retrieve an argument for use in the callback. 163retrieves it from
164.Fa b .
165The name of these two functions is badly misleading: the
166.Fa pointer
167is never passed as an argument to any callback function.
168But of course, callback functions can call
169.Fn BIO_get_callback_arg
170and access the pointer, just like any other code can.
130.Pp 171.Pp
131.Fn BIO_debug_callback 172.Fn BIO_debug_callback
132is a standard debugging callback which prints 173is a standard debugging callback which prints
133out information relating to each BIO operation. 174out information related to each BIO operation.
134If the callback argument is set, it is interpreted as a BIO 175If
135to send the information to, otherwise stderr is used. 176.Fn BIO_set_callback_arg
136.Pp 177was called with a
137.Fn BIO_callback_fn 178.Pf non- Dv NULL
138is the type of the callback function. 179argument, information is sent to the BIO pointed to by the
139The meaning of each argument is described below. 180.Fa pointer ;
140.Pp 181otherwise, standard error output is used.
141The BIO the callback is attached to is passed in
142.Fa b .
143.Pp 182.Pp
144.Fa oper 183The arguments of the callback functions are as follows:
145is set to the operation being performed. 184.Bl -tag -width Ds
146For some operations the callback is called twice, 185.It Fa b
186The BIO the callback is attached to.
187.It Fa oper
188The operation being performed.
189For some operations, the callback is called twice,
147once before and once after the actual operation. 190once before and once after the actual operation.
148The latter case has 191The latter case has
149.Fa oper 192.Fa oper
150or'ed with 193OR'ed with
151.Dv BIO_CB_RETURN . 194.Dv BIO_CB_RETURN .
152.Pp 195.It Fa argp , argi , argl
153The meaning of the arguments 196The meaning of these three arguments depends on the value of
154.Fa argp , 197.Fa oper ,
155.Fa argi 198that is on the operation being performed.
156and 199.It Fa len
157.Fa argl 200The length of the data requested to be read or written.
158depends on the value of 201This is only useful if
159.Fa oper 202.Fa oper
160(i.e. the operation being performed). 203is
161.Pp 204.Dv BIO_CB_READ ,
205.Dv BIO_CB_WRITE ,
206or
207.Dv BIO_CB_GETS .
208.It Fa ret
162When 209When
163.Fa oper 210.Fa oper
164does not include 211does not include
@@ -185,43 +232,101 @@ if no callback were present.
185When a callback is present, the operation only passes this value 232When a callback is present, the operation only passes this value
186to the callback and instead of it returns the return value of the 233to the callback and instead of it returns the return value of the
187callback to the application. 234callback to the application.
235.It Fa processed
236The location pointed to is updated with the number of bytes
237actually read or written.
238Only used for
239.Dv BIO_CB_READ ,
240.Dv BIO_CB_WRITE ,
241.Dv BIO_CB_GETS ,
242and
243.Dv BIO_CB_PUTS .
244.El
188.Pp 245.Pp
189The callback should normally simply return 246The callback should normally simply return
190.Fa ret 247.Fa ret
191when it has finished processing, unless it specifically wishes to 248when it has finished processing, unless it specifically wishes to
192abort the operation or to modify the value returned to the application. 249abort the operation or to modify the value returned to the application.
193.Ss Callback operations 250.Pp
194.Bl -tag -width Ds 251The callbacks are called as follows:
195.It Fn BIO_free b 252.Bl -tag -width 1n
196.Fn callback b BIO_CB_FREE NULL 0L 0L 1L 253.It \&In Fn BIO_free "BIO *b" :
197is called before the free operation. 254.Bd -literal
198.It Fn BIO_read b out outl 255before the free operation:
199.Fn callback b BIO_CB_READ out outl 0L 1L 256cb_ex(b, BIO_CB_FREE, NULL, 0, 0, 0, 1, NULL)
200is called before the read and 257or cb(b, BIO_CB_FREE, NULL, 0, 0, 1)
201.Fn callback b BIO_CB_READ|BIO_CB_RETURN out outl 0L ret 258.Ed
202after. 259.It \&In Fn BIO_read "BIO *b" "void *out" "int outl" :
203.It Fn BIO_write b in inl 260.Bd -literal
204.Fn callback b BIO_CB_WRITE in inl 0L 1L 261before the read operation:
205is called before the write and 262cb_ex(b, BIO_CB_READ, out, outl, 0, 0, 1, NULL)
206.Fn callback b BIO_CB_WRITE|BIO_CB_RETURN in inl 0L ret 263or cb(b, BIO_CB_READ, out, outl, 0, 1)
207after. 264
208.It Fn BIO_gets b out outl 265after the read operation:
209.Fn callback b BIO_CB_GETS out outl 0L 1L 266cb_ex(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0, 0, ret, &bytes)
210is called before the operation and 267or cb(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0, ret)
211.Fn callback b BIO_CB_GETS|BIO_CB_RETURN out outl 0L ret 268.Ed
212after. 269.It \&In Fn BIO_write "BIO *b" "const void *in" "int inl" :
213.It Fn BIO_puts b in 270.Bd -literal
214.Fn callback b BIO_CB_PUTS in 0 0L 1L 271before the write operation:
215is called before the operation and 272cb_ex(b, BIO_CB_WRITE, in, inl, 0, 0, 1, NULL)
216.Fn callback b BIO_CB_PUTS|BIO_CB_RETURN in 0 0L ret 273or cb(b, BIO_CB_WRITE, in, inl, 0, 1)
217after. 274
218.It Fn BIO_ctrl b oper larg parg 275after the write operation:
219.Fn callback b BIO_CB_CTRL parg oper larg 1L 276cb_ex(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0, 0, ret, &bytes)
220is called before the call and 277or cb(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0, ret)
221.Fn callback b BIO_CB_CTRL|BIO_CB_RETURN parg oper larg ret 278.Ed
222after. 279.It \&In Fn BIO_gets "BIO *b" "char *out" "int outl" :
280.Bd -literal
281before the read operation:
282cb_ex(b, BIO_CB_GETS, out, outl, 0, 0, 1, NULL)
283or cb(b, BIO_CB_GETS, out, outl, 0, 1)
284
285after the read operation:
286cb_ex(b, BIO_CB_GETS|BIO_CB_RETURN, out, outl, 0, 0, ret, &bytes)
287or cb(b, BIO_CB_GETS|BIO_CB_RETURN, out, outl, 0, ret)
288.Ed
289.It \&In Fn BIO_puts "BIO *b" "const char *in" :
290.Bd -literal
291before the write operation:
292cb_ex(b, BIO_CB_PUTS, in, 0, 0, 0, 1, NULL)
293or cb(b, BIO_CB_PUTS, in, 0, 0, 1)
294
295after the write operation:
296cb_ex(b, BIO_CB_PUTS|BIO_CB_RETURN, in, 0, 0, 0, ret, &bytes)
297or cb(b, BIO_CB_PUTS|BIO_CB_RETURN, in, 0, 0, ret)
298.Ed
299.It \&In Fn BIO_ctrl "BIO *b" "int cmd" "long larg" "void *parg" :
300.Bd -literal
301before the control operation:
302cb_ex(b, BIO_CB_CTRL, parg, 0, cmd, larg, 1, NULL)
303or cb(b, BIO_CB_CTRL, parg, cmd, larg, 1)
304
305after the control operation:
306cb_ex(b, BIO_CB_CTRL|BIO_CB_RETURN, parg, 0, cmd, larg, ret, NULL)
307or cb(b, BIO_CB_CTRL|BIO_CB_RETURN, parg, cmd, larg, ret)
308.Ed
309.It \&In Fn BIO_callback_ctrl "BIO *b" "int cmd" "BIO_info_cb *fp" :
310.Bd -literal
311before the control operation:
312cb_ex(b, BIO_CB_CTRL, fp, 0, cmd, 0, 1, NULL)
313or cb(b, BIO_CB_CTRL, fp, cmd, 0, 1)
314
315after the control operation:
316cb_ex(b, BIO_CB_CTRL|BIO_CB_RETURN, fp, 0, cmd, 0, ret, NULL)
317or cb(b, BIO_CB_CTRL|BIO_CB_RETURN, fp, cmd, 0, ret)
318.Ed
223.El 319.El
224.Sh RETURN VALUES 320.Sh RETURN VALUES
321.Fn BIO_get_callback_ex
322returns a pointer to the function
323.Fa cb_ex
324previously installed with
325.Fn BIO_set_callback_cb ,
326or
327.Dv NULL
328if no such callback was installed.
329.Pp
225.Fn BIO_get_callback 330.Fn BIO_get_callback
226returns a pointer to the function 331returns a pointer to the function
227.Fa cb 332.Fa cb
@@ -229,16 +334,16 @@ previously installed with
229.Fn BIO_set_callback , 334.Fn BIO_set_callback ,
230or 335or
231.Dv NULL 336.Dv NULL
232if no callback was installed. 337if no such callback was installed.
233.Pp 338.Pp
234.Fn BIO_get_callback_arg 339.Fn BIO_get_callback_arg
235returns a pointer to the 340returns the
236.Fa arg 341.Fa pointer
237previously set with 342previously set with
238.Fn BIO_set_callback_arg , 343.Fn BIO_set_callback_arg ,
239or 344or
240.Dv NULL 345.Dv NULL
241if no such argument was set. 346if no such pointer was set.
242.Pp 347.Pp
243.Fn BIO_debug_callback 348.Fn BIO_debug_callback
244returns 349returns
@@ -265,5 +370,15 @@ and
265first appeared in SSLeay 0.6.0. 370first appeared in SSLeay 0.6.0.
266.Fn BIO_get_callback_arg 371.Fn BIO_get_callback_arg
267first appeared in SSLeay 0.8.0. 372first appeared in SSLeay 0.8.0.
268All these functions have been available since 373These functions have been available since
269.Ox 2.4 . 374.Ox 2.4 .
375.Pp
376.Fn BIO_callback_fn
377first appeared in OpenSSL 1.1.0.
378.Fn BIO_callback_fn_ex ,
379.Fn BIO_set_callback_ex ,
380and
381.Fn BIO_get_callback_ex
382first appeared in OpenSSL 1.1.1.
383These functions have been available since
384.Ox 7.1 .