1.\" $OpenBSD: BIO_get_data.3,v 1.3 2018/03/23 23:18:17 schwarze Exp $ 2.\" selective merge up to: OpenSSL e90fc053 Jul 15 09:39:45 2017 -0400 3.\" 4.\" This file is a derived work. 5.\" The changes are covered by the following Copyright and license: 6.\" 7.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org> 8.\" 9.\" Permission to use, copy, modify, and distribute this software for any 10.\" purpose with or without fee is hereby granted, provided that the above 11.\" copyright notice and this permission notice appear in all copies. 12.\" 13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20.\" 21.\" The original file was written by Matt Caswell <matt@openssl.org>. 22.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved. 23.\" 24.\" Redistribution and use in source and binary forms, with or without 25.\" modification, are permitted provided that the following conditions 26.\" are met: 27.\" 28.\" 1. Redistributions of source code must retain the above copyright 29.\" notice, this list of conditions and the following disclaimer. 30.\" 31.\" 2. Redistributions in binary form must reproduce the above copyright 32.\" notice, this list of conditions and the following disclaimer in 33.\" the documentation and/or other materials provided with the 34.\" distribution. 35.\" 36.\" 3. All advertising materials mentioning features or use of this 37.\" software must display the following acknowledgment: 38.\" "This product includes software developed by the OpenSSL Project 39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 40.\" 41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 42.\" endorse or promote products derived from this software without 43.\" prior written permission. For written permission, please contact 44.\" openssl-core@openssl.org. 45.\" 46.\" 5. Products derived from this software may not be called "OpenSSL" 47.\" nor may "OpenSSL" appear in their names without prior written 48.\" permission of the OpenSSL Project. 49.\" 50.\" 6. Redistributions of any form whatsoever must retain the following 51.\" acknowledgment: 52.\" "This product includes software developed by the OpenSSL Project 53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 54.\" 55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" 68.Dd $Mdocdate: March 23 2018 $ 69.Dt BIO_GET_DATA 3 70.Os 71.Sh NAME 72.Nm BIO_set_data , 73.Nm BIO_get_data , 74.Nm BIO_set_init , 75.Nm BIO_set_shutdown , 76.Nm BIO_get_shutdown 77.Nd manage BIO state information 78.Sh SYNOPSIS 79.In openssl/bio.h 80.Ft void 81.Fo BIO_set_data 82.Fa "BIO *a" 83.Fa "void *ptr" 84.Fc 85.Ft void * 86.Fo BIO_get_data 87.Fa "BIO *a" 88.Fc 89.Ft void 90.Fo BIO_set_init 91.Fa "BIO *a" 92.Fa "int init" 93.Fc 94.Ft void 95.Fo BIO_set_shutdown 96.Fa "BIO *a" 97.Fa "int shutdown" 98.Fc 99.Ft int 100.Fo BIO_get_shutdown 101.Fa "BIO *a" 102.Fc 103.Sh DESCRIPTION 104These functions are mainly useful when implementing a custom BIO. 105.Pp 106The 107.Fn BIO_set_data 108function associates the custom data pointed to by 109.Fa ptr 110with the 111.Fa "BIO a" . 112This data can subsequently be retrieved via a call to 113.Fn BIO_get_data . 114This can be used by custom BIOs for storing implementation specific 115information. 116.Pp 117The 118.Fn BIO_set_init 119function sets the 120.Fa init 121flag in 122.Fa a 123to the specified value. 124A non-zero value indicates that initialisation is complete, 125whilst zero indicates that it is not. 126Often initialisation will complete 127during initial construction of the BIO. 128For some BIOs however, initialisation may not be complete until 129additional steps have been taken, for example through calling custom 130ctrls. 131.Pp 132The 133.Fn BIO_set_shutdown 134and 135.Fn BIO_get_shutdown 136functions are low-level interfaces to forcefully set and get the 137.Fa shutdown 138flag of 139.Fa a , 140circumventing type-dependent sanity checks, 141exclusively intended for implementing a new BIO type. 142The 143.Fa shutdown 144argument must be either 145.Dv BIO_CLOSE 146or 147.Dv BIO_NOCLOSE . 148When merely using a 149.Vt BIO 150object, call 151.Xr BIO_set_close 3 152and 153.Xr BIO_get_close 3 154instead. 155.Sh RETURN VALUES 156.Fn BIO_get_data 157returns a pointer to the implementation specific custom data associated 158with 159.Fa a , 160or 161.Dv NULL 162if none is set. 163.Pp 164.Fn BIO_get_shutdown 165returns the value previously set with 166.Fn BIO_set_shutdown 167or with 168.Xr BIO_set_close 3 . 169.Sh SEE ALSO 170.Xr BIO_meth_new 3 , 171.Xr BIO_new 3 , 172.Xr BIO_set_close 3 173.Sh HISTORY 174These functions first appeared in OpenSSL 1.1.0 175and have been available since 176.Ox 6.3 . 177