BIO_PUSH(3ossl)
π BIO_PUSH(3ossl) β the OpenSSL queen of chain-building
Okay bestie, so this one's from the OpenSSL manual, and it's literally all about linking BIOs into a chain and un-linking them again. BIO_push, BIO_pop, BIO_set_next β the holy trinity of "who's next in line" π
β¨ NAME β¨
BIO_push, BIO_pop, BIO_set_next β add and remove BIOs from a chain. That's it, that's the whole vibe π¦
πΈ SYNOPSIS πΈ
#include <openssl/bio.h>
BIO *BIO_push(BIO *b, BIO *next);
BIO *BIO_pop(BIO *b);
void BIO_set_next(BIO *b, BIO *next);
π DESCRIPTION π
BIO_push() β the "you're coming with me" move π
BIO_push() pushes b on next. Real talk: if b is NULL, the function does nothing and just returns next (iconic low-effort behaviour, honestly). Otherwise it prepends b β which can be a single BIO or a whole chain of BIOs β to next (unless next is NULL, in which case, you know, nothing to prepend to). Then it makes a control call on b and returns b.
BIO_pop() β the "we need to talk" move π
BIO_pop() removes the BIO b from any chain it's part of. If b is NULL, it does nothing and returns NULL. Otherwise it makes a control call on b and returns the next BIO in the chain, or NULL if there is no next BIO. The removed BIO becomes a single BIO with zero association to the original chain β so it's free to be freed or to go be part of a different chain. Glow-up era β¨
BIO_set_next() β the "plot twist" move π
BIO_set_next() replaces the existing next BIO in a chain with the BIO pointed to by next. And ngl, the new chain can include some of the same BIOs from the old chain, or it can be completely different. No rules, we love that for her π
π«Ά NOTES π«Ά
The names of these functions are, perhaps, a little misleading β okay they're kind of a lot misleading. BIO_push() joins two BIO chains, whereas BIO_pop() deletes a single BIO from a chain, and the deleted BIO doesn't need to be at the end of a chain. The way that "pop" sounds like a stack thing? Yeah no, that's not what's happening here π
Also, the process of calling BIO_push() and BIO_pop() on a BIO may have additional consequences β a control call is made to the affected BIOs. Any effects will be noted in the descriptions of individual BIOs. So, like, check those before you get surprised, bestie π
π₯ RETURN VALUES π₯
BIO_push()β returns the head of the chain, which usually isb, ornextifbisNULL.BIO_pop()β returns the next BIO in the chain, orNULLif there is no next BIO.
π EXAMPLES π
For these examples, suppose md1 and md2 are digest BIOs, b64 is a base64 BIO, and f is a file BIO.
If the call:
BIO_push(b64, f);
is made, then the new chain will be b64-f. Slay.
After making the calls:
BIO_push(md2, b64);
BIO_push(md1, md2);
the new chain is md1-md2-b64-f. Data written to md1 will be digested by md1 and md2, base64 encoded, and finally written to f. Look at her go, a whole pipeline π
It should be noted that reading causes data to pass in the reverse direction β that is, data is read from f, base64 decoded, and digested by md2 and then md1. Yes, it goes both ways, main character energy π
The call:
BIO_pop(md2);
will return b64, and the new chain will be md1-b64-f. Data can be written to and read from md1 as before, except that md2 will no more be applied. She said "not me participating anymore" π
π SEE ALSO π
π HISTORY π
The BIO_set_next() function was added in OpenSSL 1.1.0. A whole era π
π COPYRIGHT π
Copyright 2000-2021 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>.
Fr fr, this is version 3.5.0 and it's dated 2026-09-25 β so bestie, that's the BIO_PUSH(3ossl) page, OpenSSL edition, fully documented and looking expensive π
β¨
π¦ 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