OpenBSD manual page server

Manual Page Search Parameters

BIO_FIND_TYPE(3) Library Functions Manual BIO_FIND_TYPE(3)

BIO_find_type, BIO_next, BIO_method_type, BIO_method_nameBIO chain traversal

#include <openssl/bio.h>

BIO *
BIO_find_type(BIO *bio, int type);

BIO *
BIO_next(BIO *bio);

int
BIO_method_type(const BIO *bio);

const char *
BIO_method_name(const BIO *bio);

#define BIO_TYPE_NONE 0
#define BIO_TYPE_START 128

() searches for a BIO matching the given type in the chain starting at bio. If the least significant byte of the type argument is non-zero, only exact matches of the type are accepted. Otherwise, a match only requires that any of the bits set in the type argument is also set in the candidate BIO.

Types with a least significant byte in the range from 0 to BIO_TYPE_START, inclusive, are reserved for BIO types built into the library. Types with a least significant byte greater than BIO_TYPE_START are available for user-defined BIO types; see BIO_get_new_index(3) for details.

() returns the next BIO in the chain after bio. This function can be used to traverse all BIOs in a chain or in conjunction with BIO_find_type() to find all BIOs of a certain type.

() returns the type of the given bio.

() returns an ASCII string representing the type of the bio.

The following are the built-in source/sink BIO types that operate on file descriptors. They all have both of the bits BIO_TYPE_SOURCE_SINK and BIO_TYPE_DESCRIPTOR but not the bit BIO_TYPE_FILTER set in their type constant.

type constant string BIO_METHOD
socket accept BIO_s_accept(3)
socket connect BIO_s_connect(3)
datagram socket BIO_s_datagram(3)
file descriptor BIO_s_fd(3)
socket BIO_s_socket(3)

The following are the built-in source/sink BIO types that do not directly operate on file descriptors. They all have the bit BIO_TYPE_SOURCE_SINK but not the bits BIO_TYPE_DESCRIPTOR and BIO_TYPE_FILTER set in their type constant.

type constant string BIO_METHOD
BIO pair BIO_s_bio(3)
FILE pointer BIO_s_file(3)
memory buffer BIO_s_mem(3)
NULL BIO_s_null(3)

The following are the built-in filter BIO types. They all have the bit BIO_TYPE_FILTER but not the bits BIO_TYPE_SOURCE_SINK and BIO_TYPE_DESCRIPTOR set in their type constant.

type constant string BIO_METHOD
base64 encoding BIO_f_base64(3)
buffer BIO_f_buffer(3)
cipher BIO_f_cipher(3)
message digest BIO_f_md(3)
NULL filter BIO_f_null(3)
ssl BIO_f_ssl(3)

The constants BIO_TYPE_BER, BIO_TYPE_PROXY_CLIENT, and BIO_TYPE_PROXY_SERVER do not correspond to any BIO types implemented by the library and are not intended to be used for application-defined types, either. The constants BIO_TYPE_COMP, BIO_TYPE_LINEBUFFER, and BIO_TYPE_NBIO_TEST corresponds to a deprecated BIO types that are intentionally undocumented.

If a variable in an application program is intended to store a BIO type but temporarily does not refer to any BIO or refers to a BIO of an unknown type, setting the variable to BIO_TYPE_NONE is recommended.

BIO_find_type() returns the next matching BIO or NULL if bio is a NULL pointer or if no matching BIO is found.

BIO_next() returns the next BIO or NULL if bio is a NULL pointer or points to the last BIO in a chain.

BIO_method_type() returns one of the BIO_TYPE_* constants.

BIO_method_name() returns an internal pointer to a string.

Traverse a chain looking for digest BIOs:

BIO *btmp;

btmp = in_bio;	/* in_bio is the chain to search through */
while (btmp != NULL) {
	btmp = BIO_find_type(btmp, BIO_TYPE_MD);
	if (btmp == NULL)
		break;	/* Not found */

	/* btmp is a digest BIO, do something with it ... */
	...

	btmp = BIO_next(btmp);
}

BIO_meth_new(3), BIO_new(3)

BIO_method_type() and BIO_method_name() first appeared in SSLeay 0.6.0. BIO_find_type() first appeared in SSLeay 0.6.6. These functions have been available since OpenBSD 2.4.

BIO_next() first appeared in OpenSSL 0.9.6 and has been available since OpenBSD 2.9.

July 26, 2023 OpenBSD-7.5