Difference between revisions of "BIO"
(copied the content that I wrote about BIOs from the OpenSSL wikibook) |
|||
(6 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
BIOs come in two flavors: source/sink, or filter. BIOs can be chained together. Each chain always has exactly one source/sink, but can have any number (zero or more) of filters. | BIOs come in two flavors: source/sink, or filter. BIOs can be chained together. Each chain always has exactly one source/sink, but can have any number (zero or more) of filters. | ||
− | Reading from a BIO can be done with [ | + | Reading from a BIO can be done with [[Manual:BIO_read(3)]] and <code>BIO_gets</code>. |
Writing to a BIO can be done with <code>BIO_write</code>, <code>BIO_puts</code>, <code>BIO_printf</code>, and <code>BIO_vprintf</code>. | Writing to a BIO can be done with <code>BIO_write</code>, <code>BIO_puts</code>, <code>BIO_printf</code>, and <code>BIO_vprintf</code>. | ||
Line 9: | Line 9: | ||
== Filter BIOs == | == Filter BIOs == | ||
− | * [ | + | * [[Manual:BIO_f_base64(3)]] |
− | * [ | + | * [[Manual:BIO_f_buffer(3)]] |
− | * [ | + | * [[Manual:BIO_f_cipher(3)]] |
− | * [ | + | * [[Manual:BIO_f_md(3)]] |
− | * [ | + | * [[Manual:BIO_f_ssl(3)]] |
== Source/sink BIOs == | == Source/sink BIOs == | ||
− | * [ | + | * [[Manual:BIO_s_accept(3)]] |
− | * [ | + | * [[Manual:BIO_s_bio(3)]] |
− | * [ | + | * [[Manual:BIO_s_connect(3)]] |
− | * [ | + | * [[Manual:BIO_s_fd(3)]] |
− | * [ | + | * [[Manual:BIO_s_file(3)]] |
− | * [ | + | * [[Manual:BIO_s_mem(3)]] |
− | * [ | + | * [[Manual:BIO_s_null(3)]] |
− | * [ | + | * [[Manual:BIO_s_socket(3)]] |
+ | |||
+ | implementation of those bio are within bio/bss_xxx.c bss stading for Bio Source Sink | ||
+ | |||
+ | == Combining Filters and Source Sink BIOs == | ||
+ | |||
+ | * [[Manual:BIO_push(3)]] | ||
+ | |||
+ | new_head = BIO_push(BIO * local_head, BIO * tail) | ||
+ | |||
+ | will connect tail at end of local_head chain. | ||
+ | |||
+ | WARNING BIO_push will never fail, but can create invalid chains. | ||
+ | |||
+ | In standard usage end of a chain is a source sink, and all other elements are filters. | ||
+ | |||
+ | * [[Manual:BIO_s_bio(3)]] | ||
+ | |||
+ | two separated BIOs can then be connected with BIO_make_bio_pair() into a connected pair. |
Latest revision as of 07:37, 1 November 2014
A BIO is an I/O stream abstraction; essentially OpenSSL's answer to the C library's FILE *
. OpenSSL comes with a number of useful BIO types predefined, or you can create your own.
BIOs come in two flavors: source/sink, or filter. BIOs can be chained together. Each chain always has exactly one source/sink, but can have any number (zero or more) of filters.
Reading from a BIO can be done with Manual:BIO_read(3) and BIO_gets
.
Writing to a BIO can be done with BIO_write
, BIO_puts
, BIO_printf
, and BIO_vprintf
.
Filter BIOs[edit]
- Manual:BIO_f_base64(3)
- Manual:BIO_f_buffer(3)
- Manual:BIO_f_cipher(3)
- Manual:BIO_f_md(3)
- Manual:BIO_f_ssl(3)
Source/sink BIOs[edit]
- Manual:BIO_s_accept(3)
- Manual:BIO_s_bio(3)
- Manual:BIO_s_connect(3)
- Manual:BIO_s_fd(3)
- Manual:BIO_s_file(3)
- Manual:BIO_s_mem(3)
- Manual:BIO_s_null(3)
- Manual:BIO_s_socket(3)
implementation of those bio are within bio/bss_xxx.c bss stading for Bio Source Sink
Combining Filters and Source Sink BIOs[edit]
new_head = BIO_push(BIO * local_head, BIO * tail)
will connect tail at end of local_head chain.
WARNING BIO_push will never fail, but can create invalid chains.
In standard usage end of a chain is a source sink, and all other elements are filters.
two separated BIOs can then be connected with BIO_make_bio_pair() into a connected pair.