BIO_FIND_TYPE(3ossl)
π BIO_FIND_TYPE(3ossl) β the OpenSSL manual page, bestie edition
Okay so this is BIO_FIND_TYPE(3ossl) from the OpenSSL manual, and it's literally just about walking down a chain of BIOs and finding the one you want. Three little functions, zero drama, maximum slay. Let's go πΈ
β¨ SYNOPSIS β¨
#include <openssl/bio.h>
BIO *BIO_find_type(BIO *b, int bio_type);
BIO *BIO_next(BIO *b);
int BIO_method_type(const BIO *b);
π¦ DESCRIPTION π¦
π BIO_find_type()
So BIO_find_type() goes digging for a BIO of a given type inside a chain, starting at the BIO called b. And the way it searches depends on what kind of type you hand it:
- If type is a specific type (think
BIO_TYPE_MEM), it searches for aBIOof exactly that type. - If type is a general type (think
BIO_TYPE_SOURCE_SINK), it searches for the next matchingBIOof that general type.
It returns the next matching BIO, or NULL if there isn't one. And bestie, listen: if type is BIO_TYPE_NONE, it will not find a match. Like, ever. Not a vibe, just facts π
The general types that are defined are:
BIO_TYPE_DESCRIPTORBIO_TYPE_FILTERBIO_TYPE_SOURCE_SINK
Want the full list of specific types? Go look at the <openssl/bio.h> header file, it's all in there π
β‘οΈ BIO_next()
BIO_next() hands you the next BIO in a chain. Use it on its own to walk every single BIO in a chain, or team it up with BIO_find_type() to round up all the BIOs of a certain type. Iconic duo behavior, honestly π«Ά
π·οΈ BIO_method_type()
BIO_method_type() returns the type of a BIO. That's it. That's the function. Simple, effective, ate β¨
π RETURN VALUES π
BIO_find_type()β returns a matchingBIO, orNULLif there's no match.BIO_next()β returns the nextBIOin a chain.BIO_method_type()β returns the type of theBIOb.
π₯ EXAMPLES π₯
Here's the whole move: traverse a chain looking for digest BIOs. Copy it exactly, no cap:
BIO *btmp;
btmp = in_bio; /* in_bio is chain to search through */
do {
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);
} while (btmp);
See how BIO_find_type() finds the digest BIO and then BIO_next() hops along to keep the loop going? That's the combo, periodt π
π COPYRIGHT π
Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
That's the whole page, diva π This version is 3.5.0, dated 2026-09-25 β go forth and traverse those chains πβ
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms