1e71b7053SJung-uk Kim=pod 2e71b7053SJung-uk Kim 3e71b7053SJung-uk Kim=head1 NAME 4e71b7053SJung-uk Kim 5e71b7053SJung-uk Kimbio - Basic I/O abstraction 6e71b7053SJung-uk Kim 7e71b7053SJung-uk Kim=head1 SYNOPSIS 8e71b7053SJung-uk Kim 9*b077aed3SPierre Pronchery=for openssl generic 10e71b7053SJung-uk Kim 11e71b7053SJung-uk Kim #include <openssl/bio.h> 12e71b7053SJung-uk Kim 13e71b7053SJung-uk Kim=head1 DESCRIPTION 14e71b7053SJung-uk Kim 15e71b7053SJung-uk KimA BIO is an I/O abstraction, it hides many of the underlying I/O 16e71b7053SJung-uk Kimdetails from an application. If an application uses a BIO for its 17e71b7053SJung-uk KimI/O it can transparently handle SSL connections, unencrypted network 18e71b7053SJung-uk Kimconnections and file I/O. 19e71b7053SJung-uk Kim 20*b077aed3SPierre ProncheryThere are two types of BIO, a source/sink BIO and a filter BIO. 21e71b7053SJung-uk Kim 22e71b7053SJung-uk KimAs its name implies a source/sink BIO is a source and/or sink of data, 23e71b7053SJung-uk Kimexamples include a socket BIO and a file BIO. 24e71b7053SJung-uk Kim 25e71b7053SJung-uk KimA filter BIO takes data from one BIO and passes it through to 26e71b7053SJung-uk Kimanother, or the application. The data may be left unmodified (for 27e71b7053SJung-uk Kimexample a message digest BIO) or translated (for example an 28e71b7053SJung-uk Kimencryption BIO). The effect of a filter BIO may change according 29e71b7053SJung-uk Kimto the I/O operation it is performing: for example an encryption 30e71b7053SJung-uk KimBIO will encrypt data if it is being written to and decrypt data 31e71b7053SJung-uk Kimif it is being read from. 32e71b7053SJung-uk Kim 33e71b7053SJung-uk KimBIOs can be joined together to form a chain (a single BIO is a chain 34*b077aed3SPierre Proncherywith one component). A chain normally consists of one source/sink 35e71b7053SJung-uk KimBIO and one or more filter BIOs. Data read from or written to the 36e71b7053SJung-uk Kimfirst BIO then traverses the chain to the end (normally a source/sink 37e71b7053SJung-uk KimBIO). 38e71b7053SJung-uk Kim 39e71b7053SJung-uk Kim 40e71b7053SJung-uk KimSome BIOs (such as memory BIOs) can be used immediately after calling 41e71b7053SJung-uk KimBIO_new(). Others (such as file BIOs) need some additional initialization, 42e71b7053SJung-uk Kimand frequently a utility function exists to create and initialize such BIOs. 43e71b7053SJung-uk Kim 44e71b7053SJung-uk KimIf BIO_free() is called on a BIO chain it will only free one BIO resulting 45e71b7053SJung-uk Kimin a memory leak. 46e71b7053SJung-uk Kim 47e71b7053SJung-uk KimCalling BIO_free_all() on a single BIO has the same effect as calling 48e71b7053SJung-uk KimBIO_free() on it other than the discarded return value. 49e71b7053SJung-uk Kim 50*b077aed3SPierre ProncheryNormally the I<type> argument is supplied by a function which returns a 51e71b7053SJung-uk Kimpointer to a BIO_METHOD. There is a naming convention for such functions: 52*b077aed3SPierre Proncherya source/sink BIO typically starts with I<BIO_s_> and 53*b077aed3SPierre Proncherya filter BIO with I<BIO_f_>. 54e71b7053SJung-uk Kim 55da327cd2SJung-uk Kim=head1 EXAMPLES 56e71b7053SJung-uk Kim 57e71b7053SJung-uk KimCreate a memory BIO: 58e71b7053SJung-uk Kim 59e71b7053SJung-uk Kim BIO *mem = BIO_new(BIO_s_mem()); 60e71b7053SJung-uk Kim 61e71b7053SJung-uk Kim=head1 SEE ALSO 62e71b7053SJung-uk Kim 63e71b7053SJung-uk KimL<BIO_ctrl(3)>, 64e71b7053SJung-uk KimL<BIO_f_base64(3)>, L<BIO_f_buffer(3)>, 65e71b7053SJung-uk KimL<BIO_f_cipher(3)>, L<BIO_f_md(3)>, 66e71b7053SJung-uk KimL<BIO_f_null(3)>, L<BIO_f_ssl(3)>, 67*b077aed3SPierre ProncheryL<BIO_f_readbuffer(3)>, 68e71b7053SJung-uk KimL<BIO_find_type(3)>, L<BIO_new(3)>, 69e71b7053SJung-uk KimL<BIO_new_bio_pair(3)>, 70e71b7053SJung-uk KimL<BIO_push(3)>, L<BIO_read_ex(3)>, 71e71b7053SJung-uk KimL<BIO_s_accept(3)>, L<BIO_s_bio(3)>, 72e71b7053SJung-uk KimL<BIO_s_connect(3)>, L<BIO_s_fd(3)>, 73e71b7053SJung-uk KimL<BIO_s_file(3)>, L<BIO_s_mem(3)>, 74e71b7053SJung-uk KimL<BIO_s_null(3)>, L<BIO_s_socket(3)>, 75e71b7053SJung-uk KimL<BIO_set_callback(3)>, 76e71b7053SJung-uk KimL<BIO_should_retry(3)> 77e71b7053SJung-uk Kim 78e71b7053SJung-uk Kim=head1 COPYRIGHT 79e71b7053SJung-uk Kim 80*b077aed3SPierre ProncheryCopyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved. 81e71b7053SJung-uk Kim 82*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 83e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 84e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 85e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 86e71b7053SJung-uk Kim 87e71b7053SJung-uk Kim=cut 88e71b7053SJung-uk Kim 89