diff options
| author | schwarze <> | 2022-12-16 23:56:57 +0000 |
|---|---|---|
| committer | schwarze <> | 2022-12-16 23:56:57 +0000 |
| commit | 6b4e4a87fbd0cc42db7aaa3dfaf0aeb51306af07 (patch) | |
| tree | 16e293377ebe4284fa981c6754b0295b9eb8044a /src/lib/libcrypto/man | |
| parent | cd13c74f1006cfe752042b24c510330b368487fe (diff) | |
| download | openbsd-6b4e4a87fbd0cc42db7aaa3dfaf0aeb51306af07.tar.gz openbsd-6b4e4a87fbd0cc42db7aaa3dfaf0aeb51306af07.tar.bz2 openbsd-6b4e4a87fbd0cc42db7aaa3dfaf0aeb51306af07.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.
Diffstat (limited to 'src/lib/libcrypto/man')
| -rw-r--r-- | src/lib/libcrypto/man/BIO_set_callback.3 | 269 |
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 |
| 119 | and | 142 | and |
| 120 | .Fn BIO_get_callback | 143 | .Fn BIO_get_callback_ex |
| 121 | set and retrieve the BIO callback. | 144 | set and retrieve the BIO callback. |
| 122 | The callback is called during most high level BIO operations. | 145 | The callback is called during most high-level BIO operations. |
| 123 | It can be used for debugging purposes to trace operations on a BIO | 146 | It can be used for debugging purposes to trace operations on a BIO |
| 124 | or to modify its operation. | 147 | or to modify its operation. |
| 125 | .Pp | 148 | .Pp |
| 149 | .Fn BIO_set_callback | ||
| 150 | and | ||
| 151 | .Fn BIO_get_callback | ||
| 152 | are deprecated functions that set and retrieve the old-style BIO callback, | ||
| 153 | which 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 |
| 157 | stores the | ||
| 158 | .Fa pointer | ||
| 159 | internally in | ||
| 160 | .Fa b | ||
| 127 | and | 161 | and |
| 128 | .Fn BIO_get_callback_arg | 162 | .Fn BIO_get_callback_arg |
| 129 | set and retrieve an argument for use in the callback. | 163 | retrieves it from |
| 164 | .Fa b . | ||
| 165 | The name of these two functions is badly misleading: the | ||
| 166 | .Fa pointer | ||
| 167 | is never passed as an argument to any callback function. | ||
| 168 | But of course, callback functions can call | ||
| 169 | .Fn BIO_get_callback_arg | ||
| 170 | and access the pointer, just like any other code can. | ||
| 130 | .Pp | 171 | .Pp |
| 131 | .Fn BIO_debug_callback | 172 | .Fn BIO_debug_callback |
| 132 | is a standard debugging callback which prints | 173 | is a standard debugging callback which prints |
| 133 | out information relating to each BIO operation. | 174 | out information related to each BIO operation. |
| 134 | If the callback argument is set, it is interpreted as a BIO | 175 | If |
| 135 | to send the information to, otherwise stderr is used. | 176 | .Fn BIO_set_callback_arg |
| 136 | .Pp | 177 | was called with a |
| 137 | .Fn BIO_callback_fn | 178 | .Pf non- Dv NULL |
| 138 | is the type of the callback function. | 179 | argument, information is sent to the BIO pointed to by the |
| 139 | The meaning of each argument is described below. | 180 | .Fa pointer ; |
| 140 | .Pp | 181 | otherwise, standard error output is used. |
| 141 | The BIO the callback is attached to is passed in | ||
| 142 | .Fa b . | ||
| 143 | .Pp | 182 | .Pp |
| 144 | .Fa oper | 183 | The arguments of the callback functions are as follows: |
| 145 | is set to the operation being performed. | 184 | .Bl -tag -width Ds |
| 146 | For some operations the callback is called twice, | 185 | .It Fa b |
| 186 | The BIO the callback is attached to. | ||
| 187 | .It Fa oper | ||
| 188 | The operation being performed. | ||
| 189 | For some operations, the callback is called twice, | ||
| 147 | once before and once after the actual operation. | 190 | once before and once after the actual operation. |
| 148 | The latter case has | 191 | The latter case has |
| 149 | .Fa oper | 192 | .Fa oper |
| 150 | or'ed with | 193 | OR'ed with |
| 151 | .Dv BIO_CB_RETURN . | 194 | .Dv BIO_CB_RETURN . |
| 152 | .Pp | 195 | .It Fa argp , argi , argl |
| 153 | The meaning of the arguments | 196 | The meaning of these three arguments depends on the value of |
| 154 | .Fa argp , | 197 | .Fa oper , |
| 155 | .Fa argi | 198 | that is on the operation being performed. |
| 156 | and | 199 | .It Fa len |
| 157 | .Fa argl | 200 | The length of the data requested to be read or written. |
| 158 | depends on the value of | 201 | This is only useful if |
| 159 | .Fa oper | 202 | .Fa oper |
| 160 | (i.e. the operation being performed). | 203 | is |
| 161 | .Pp | 204 | .Dv BIO_CB_READ , |
| 205 | .Dv BIO_CB_WRITE , | ||
| 206 | or | ||
| 207 | .Dv BIO_CB_GETS . | ||
| 208 | .It Fa ret | ||
| 162 | When | 209 | When |
| 163 | .Fa oper | 210 | .Fa oper |
| 164 | does not include | 211 | does not include |
| @@ -185,43 +232,101 @@ if no callback were present. | |||
| 185 | When a callback is present, the operation only passes this value | 232 | When a callback is present, the operation only passes this value |
| 186 | to the callback and instead of it returns the return value of the | 233 | to the callback and instead of it returns the return value of the |
| 187 | callback to the application. | 234 | callback to the application. |
| 235 | .It Fa processed | ||
| 236 | The location pointed to is updated with the number of bytes | ||
| 237 | actually read or written. | ||
| 238 | Only used for | ||
| 239 | .Dv BIO_CB_READ , | ||
| 240 | .Dv BIO_CB_WRITE , | ||
| 241 | .Dv BIO_CB_GETS , | ||
| 242 | and | ||
| 243 | .Dv BIO_CB_PUTS . | ||
| 244 | .El | ||
| 188 | .Pp | 245 | .Pp |
| 189 | The callback should normally simply return | 246 | The callback should normally simply return |
| 190 | .Fa ret | 247 | .Fa ret |
| 191 | when it has finished processing, unless it specifically wishes to | 248 | when it has finished processing, unless it specifically wishes to |
| 192 | abort the operation or to modify the value returned to the application. | 249 | abort the operation or to modify the value returned to the application. |
| 193 | .Ss Callback operations | 250 | .Pp |
| 194 | .Bl -tag -width Ds | 251 | The 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" : |
| 197 | is called before the free operation. | 254 | .Bd -literal |
| 198 | .It Fn BIO_read b out outl | 255 | before the free operation: |
| 199 | .Fn callback b BIO_CB_READ out outl 0L 1L | 256 | cb_ex(b, BIO_CB_FREE, NULL, 0, 0, 0, 1, NULL) |
| 200 | is called before the read and | 257 | or 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 |
| 202 | after. | 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 | 261 | before the read operation: |
| 205 | is called before the write and | 262 | cb_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 | 263 | or cb(b, BIO_CB_READ, out, outl, 0, 1) |
| 207 | after. | 264 | |
| 208 | .It Fn BIO_gets b out outl | 265 | after the read operation: |
| 209 | .Fn callback b BIO_CB_GETS out outl 0L 1L | 266 | cb_ex(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0, 0, ret, &bytes) |
| 210 | is called before the operation and | 267 | or 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 |
| 212 | after. | 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 | 271 | before the write operation: |
| 215 | is called before the operation and | 272 | cb_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 | 273 | or cb(b, BIO_CB_WRITE, in, inl, 0, 1) |
| 217 | after. | 274 | |
| 218 | .It Fn BIO_ctrl b oper larg parg | 275 | after the write operation: |
| 219 | .Fn callback b BIO_CB_CTRL parg oper larg 1L | 276 | cb_ex(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0, 0, ret, &bytes) |
| 220 | is called before the call and | 277 | or 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 |
| 222 | after. | 279 | .It \&In Fn BIO_gets "BIO *b" "char *out" "int outl" : |
| 280 | .Bd -literal | ||
| 281 | before the read operation: | ||
| 282 | cb_ex(b, BIO_CB_GETS, out, outl, 0, 0, 1, NULL) | ||
| 283 | or cb(b, BIO_CB_GETS, out, outl, 0, 1) | ||
| 284 | |||
| 285 | after the read operation: | ||
| 286 | cb_ex(b, BIO_CB_GETS|BIO_CB_RETURN, out, outl, 0, 0, ret, &bytes) | ||
| 287 | or 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 | ||
| 291 | before the write operation: | ||
| 292 | cb_ex(b, BIO_CB_PUTS, in, 0, 0, 0, 1, NULL) | ||
| 293 | or cb(b, BIO_CB_PUTS, in, 0, 0, 1) | ||
| 294 | |||
| 295 | after the write operation: | ||
| 296 | cb_ex(b, BIO_CB_PUTS|BIO_CB_RETURN, in, 0, 0, 0, ret, &bytes) | ||
| 297 | or 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 | ||
| 301 | before the control operation: | ||
| 302 | cb_ex(b, BIO_CB_CTRL, parg, 0, cmd, larg, 1, NULL) | ||
| 303 | or cb(b, BIO_CB_CTRL, parg, cmd, larg, 1) | ||
| 304 | |||
| 305 | after the control operation: | ||
| 306 | cb_ex(b, BIO_CB_CTRL|BIO_CB_RETURN, parg, 0, cmd, larg, ret, NULL) | ||
| 307 | or 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 | ||
| 311 | before the control operation: | ||
| 312 | cb_ex(b, BIO_CB_CTRL, fp, 0, cmd, 0, 1, NULL) | ||
| 313 | or cb(b, BIO_CB_CTRL, fp, cmd, 0, 1) | ||
| 314 | |||
| 315 | after the control operation: | ||
| 316 | cb_ex(b, BIO_CB_CTRL|BIO_CB_RETURN, fp, 0, cmd, 0, ret, NULL) | ||
| 317 | or 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 | ||
| 322 | returns a pointer to the function | ||
| 323 | .Fa cb_ex | ||
| 324 | previously installed with | ||
| 325 | .Fn BIO_set_callback_cb , | ||
| 326 | or | ||
| 327 | .Dv NULL | ||
| 328 | if no such callback was installed. | ||
| 329 | .Pp | ||
| 225 | .Fn BIO_get_callback | 330 | .Fn BIO_get_callback |
| 226 | returns a pointer to the function | 331 | returns 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 , |
| 230 | or | 335 | or |
| 231 | .Dv NULL | 336 | .Dv NULL |
| 232 | if no callback was installed. | 337 | if no such callback was installed. |
| 233 | .Pp | 338 | .Pp |
| 234 | .Fn BIO_get_callback_arg | 339 | .Fn BIO_get_callback_arg |
| 235 | returns a pointer to the | 340 | returns the |
| 236 | .Fa arg | 341 | .Fa pointer |
| 237 | previously set with | 342 | previously set with |
| 238 | .Fn BIO_set_callback_arg , | 343 | .Fn BIO_set_callback_arg , |
| 239 | or | 344 | or |
| 240 | .Dv NULL | 345 | .Dv NULL |
| 241 | if no such argument was set. | 346 | if no such pointer was set. |
| 242 | .Pp | 347 | .Pp |
| 243 | .Fn BIO_debug_callback | 348 | .Fn BIO_debug_callback |
| 244 | returns | 349 | returns |
| @@ -265,5 +370,15 @@ and | |||
| 265 | first appeared in SSLeay 0.6.0. | 370 | first appeared in SSLeay 0.6.0. |
| 266 | .Fn BIO_get_callback_arg | 371 | .Fn BIO_get_callback_arg |
| 267 | first appeared in SSLeay 0.8.0. | 372 | first appeared in SSLeay 0.8.0. |
| 268 | All these functions have been available since | 373 | These functions have been available since |
| 269 | .Ox 2.4 . | 374 | .Ox 2.4 . |
| 375 | .Pp | ||
| 376 | .Fn BIO_callback_fn | ||
| 377 | first appeared in OpenSSL 1.1.0. | ||
| 378 | .Fn BIO_callback_fn_ex , | ||
| 379 | .Fn BIO_set_callback_ex , | ||
| 380 | and | ||
| 381 | .Fn BIO_get_callback_ex | ||
| 382 | first appeared in OpenSSL 1.1.1. | ||
| 383 | These functions have been available since | ||
| 384 | .Ox 7.1 . | ||
