xref: /freebsd/crypto/openssl/doc/man3/SSL_set_bio.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5e71b7053SJung-uk KimSSL_set_bio, SSL_set0_rbio, SSL_set0_wbio - connect the SSL object with a BIO
6e71b7053SJung-uk Kim
7e71b7053SJung-uk Kim=head1 SYNOPSIS
8e71b7053SJung-uk Kim
9e71b7053SJung-uk Kim #include <openssl/ssl.h>
10e71b7053SJung-uk Kim
11e71b7053SJung-uk Kim void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio);
12e71b7053SJung-uk Kim void SSL_set0_rbio(SSL *s, BIO *rbio);
13e71b7053SJung-uk Kim void SSL_set0_wbio(SSL *s, BIO *wbio);
14e71b7053SJung-uk Kim
15e71b7053SJung-uk Kim=head1 DESCRIPTION
16e71b7053SJung-uk Kim
17e71b7053SJung-uk KimSSL_set0_rbio() connects the BIO B<rbio> for the read operations of the B<ssl>
18e71b7053SJung-uk Kimobject. The SSL engine inherits the behaviour of B<rbio>. If the BIO is
1958f35182SJung-uk Kimnonblocking then the B<ssl> object will also have nonblocking behaviour. This
20e71b7053SJung-uk Kimfunction transfers ownership of B<rbio> to B<ssl>. It will be automatically
21e71b7053SJung-uk Kimfreed using L<BIO_free_all(3)> when the B<ssl> is freed. On calling this
22e71b7053SJung-uk Kimfunction, any existing B<rbio> that was previously set will also be freed via a
23e71b7053SJung-uk Kimcall to L<BIO_free_all(3)> (this includes the case where the B<rbio> is set to
24e71b7053SJung-uk Kimthe same value as previously).
25e71b7053SJung-uk Kim
26e71b7053SJung-uk KimSSL_set0_wbio() works in the same as SSL_set0_rbio() except that it connects
27e71b7053SJung-uk Kimthe BIO B<wbio> for the write operations of the B<ssl> object. Note that if the
28e71b7053SJung-uk Kimrbio and wbio are the same then SSL_set0_rbio() and SSL_set0_wbio() each take
2958f35182SJung-uk Kimownership of one reference. Therefore, it may be necessary to increment the
30e71b7053SJung-uk Kimnumber of references available using L<BIO_up_ref(3)> before calling the set0
31e71b7053SJung-uk Kimfunctions.
32e71b7053SJung-uk Kim
33e71b7053SJung-uk KimSSL_set_bio() is similar to SSL_set0_rbio() and SSL_set0_wbio() except
34e71b7053SJung-uk Kimthat it connects both the B<rbio> and the B<wbio> at the same time, and
35e71b7053SJung-uk Kimtransfers the ownership of B<rbio> and B<wbio> to B<ssl> according to
36e71b7053SJung-uk Kimthe following set of rules:
37e71b7053SJung-uk Kim
38e71b7053SJung-uk Kim=over 2
39e71b7053SJung-uk Kim
40e71b7053SJung-uk Kim=item *
41e71b7053SJung-uk Kim
42e71b7053SJung-uk KimIf neither the B<rbio> or B<wbio> have changed from their previous values
43e71b7053SJung-uk Kimthen nothing is done.
44e71b7053SJung-uk Kim
45e71b7053SJung-uk Kim=item *
46e71b7053SJung-uk Kim
47e71b7053SJung-uk KimIf the B<rbio> and B<wbio> parameters are different and both are different
48e71b7053SJung-uk Kimto their
49e71b7053SJung-uk Kimpreviously set values then one reference is consumed for the rbio and one
50e71b7053SJung-uk Kimreference is consumed for the wbio.
51e71b7053SJung-uk Kim
52e71b7053SJung-uk Kim=item *
53e71b7053SJung-uk Kim
54e71b7053SJung-uk KimIf the B<rbio> and B<wbio> parameters are the same and the B<rbio> is not
55e71b7053SJung-uk Kimthe same as the previously set value then one reference is consumed.
56e71b7053SJung-uk Kim
57e71b7053SJung-uk Kim=item *
58e71b7053SJung-uk Kim
59e71b7053SJung-uk KimIf the B<rbio> and B<wbio> parameters are the same and the B<rbio> is the
60e71b7053SJung-uk Kimsame as the previously set value, then no additional references are consumed.
61e71b7053SJung-uk Kim
62e71b7053SJung-uk Kim=item *
63e71b7053SJung-uk Kim
64e71b7053SJung-uk KimIf the B<rbio> and B<wbio> parameters are different and the B<rbio> is the
65e71b7053SJung-uk Kimsame as the
66e71b7053SJung-uk Kimpreviously set value then one reference is consumed for the B<wbio> and no
67e71b7053SJung-uk Kimreferences are consumed for the B<rbio>.
68e71b7053SJung-uk Kim
69e71b7053SJung-uk Kim=item *
70e71b7053SJung-uk Kim
71e71b7053SJung-uk KimIf the B<rbio> and B<wbio> parameters are different and the B<wbio> is the
72e71b7053SJung-uk Kimsame as the previously set value and the old B<rbio> and B<wbio> values
73e71b7053SJung-uk Kimwere the same as each other then one reference is consumed for the B<rbio>
74e71b7053SJung-uk Kimand no references are consumed for the B<wbio>.
75e71b7053SJung-uk Kim
76e71b7053SJung-uk Kim=item *
77e71b7053SJung-uk Kim
78e71b7053SJung-uk KimIf the B<rbio> and B<wbio> parameters are different and the B<wbio>
79e71b7053SJung-uk Kimis the same as the
80e71b7053SJung-uk Kimpreviously set value and the old B<rbio> and B<wbio> values were different
81*b077aed3SPierre Proncheryto each other, then one reference is consumed for the B<rbio> and one
82*b077aed3SPierre Proncheryreference is consumed for the B<wbio>.
83e71b7053SJung-uk Kim
84e71b7053SJung-uk Kim=back
85e71b7053SJung-uk Kim
86e71b7053SJung-uk KimBecause of this complexity, this function should be avoided;
87e71b7053SJung-uk Kimuse SSL_set0_rbio() and SSL_set0_wbio() instead.
88e71b7053SJung-uk Kim
89e71b7053SJung-uk Kim=head1 RETURN VALUES
90e71b7053SJung-uk Kim
91c9cf7b5cSJung-uk KimSSL_set_bio(), SSL_set0_rbio() and SSL_set0_wbio() cannot fail.
92e71b7053SJung-uk Kim
93e71b7053SJung-uk Kim=head1 SEE ALSO
94e71b7053SJung-uk Kim
95e71b7053SJung-uk KimL<SSL_get_rbio(3)>,
96e71b7053SJung-uk KimL<SSL_connect(3)>, L<SSL_accept(3)>,
97e71b7053SJung-uk KimL<SSL_shutdown(3)>, L<ssl(7)>, L<bio(7)>
98e71b7053SJung-uk Kim
99e71b7053SJung-uk Kim=head1 HISTORY
100e71b7053SJung-uk Kim
101e71b7053SJung-uk KimSSL_set0_rbio() and SSL_set0_wbio() were added in OpenSSL 1.1.0.
102e71b7053SJung-uk Kim
103e71b7053SJung-uk Kim=head1 COPYRIGHT
104e71b7053SJung-uk Kim
105*b077aed3SPierre ProncheryCopyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
106e71b7053SJung-uk Kim
107*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
108e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
109e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
110e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
111e71b7053SJung-uk Kim
112e71b7053SJung-uk Kim=cut
113