BIO_FIND_TYPE(3)

πŸ“¦ version 4.1.0, in opensuse-leap 16.0

πŸ’– BIO_FIND_TYPE(3) πŸ’–

okay bestie, welcome to the Library Functions Manual page for BIO_FIND_TYPE(3) β€” we're talking BIO chain traversal, and it's honestly iconic. Grab a lil snack πŸ“, because this one's got functions, constants, and a whole cast of BIO types.


✨ NAME ✨

BIO_find_type, BIO_next, BIO_method_type, BIO_method_name β€” BIO chain traversal, periodt. πŸ’…


🌸 SYNOPSIS 🌸

#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

πŸ¦‹ DESCRIPTION πŸ¦‹

BIO_find_type() searches for a BIO matching the given type in the chain starting at bio. The way it matches is lowkey specific: 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. iykyk 🫢

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. πŸ’–

BIO_next() 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. main character traversal energy fr fr. πŸ”₯

BIO_method_type() returns the type of the given bio.

BIO_method_name() 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. ✨

  • BIO_TYPE_ACCEPT β€” name string socket accept β€” BIO_METHOD: BIO_s_accept(3)
  • BIO_TYPE_CONNECT β€” name string socket connect β€” BIO_METHOD: BIO_s_connect(3)
  • BIO_TYPE_DGRAM β€” name string datagram socket β€” BIO_METHOD: BIO_s_datagram(3)
  • BIO_TYPE_FD β€” name string file descriptor β€” BIO_METHOD: BIO_s_fd(3)
  • BIO_TYPE_SOCKET β€” name string socket β€” BIO_METHOD: 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. 🌈

  • BIO_TYPE_BIO β€” name string BIO pair β€” BIO_METHOD: BIO_s_bio(3)
  • BIO_TYPE_FILE β€” name string FILE pointer β€” BIO_METHOD: BIO_s_file(3)
  • BIO_TYPE_MEM β€” name string memory buffer β€” BIO_METHOD: BIO_s_mem(3)
  • BIO_TYPE_NULL β€” name string NULL β€” BIO_METHOD: 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. 🧚

  • BIO_TYPE_BASE64 β€” name string base64 encoding β€” BIO_METHOD: BIO_f_base64(3)
  • BIO_TYPE_BUFFER β€” name string buffer β€” BIO_METHOD: BIO_f_buffer(3)
  • BIO_TYPE_CIPHER β€” name string cipher β€” BIO_METHOD: BIO_f_cipher(3)
  • BIO_TYPE_MD β€” name string message digest β€” BIO_METHOD: BIO_f_md(3)
  • BIO_TYPE_NULL_FILTER β€” name string NULL filter β€” BIO_METHOD: BIO_f_null(3)
  • BIO_TYPE_SSL β€” name string ssl β€” BIO_METHOD: 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 correspond to deprecated BIO types that are intentionally undocumented. So like… they're giving mystery, but not the fun kind. πŸ’€

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. cute safety habit, no cap. πŸŽ€


πŸ’… RETURN VALUES πŸ’…

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. noted, bestie. 🫢


πŸ“ EXAMPLES πŸ“

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);
  }

🌈 SEE ALSO 🌈

BIO_meth_new(3), BIO_new(3) β€” go off, besties. πŸ‘‘


πŸ‘‘ HISTORY πŸ‘‘

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. iconic lineage behavior. πŸ¦‹


and that's the vibe check: this page is from Debian, dated July 26, 2023, and signs off as BIO_FIND_TYPE(3) β€” mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from