BIO_PUSH(3ossl)
π BIO_PUSH β OpenSSL manual, but make it make sense π«Ά
okay so bestie, this is the tea on BIO_push, BIO_pop, and BIO_set_next from the OpenSSL manual (that's the 3ossl manual, section 3, iykyk) β three little functions that add and remove BIOs from a chain. literally the friend-group of BIO functions. π¦
β¨ NAME β¨
BIO_push, BIO_pop, BIO_set_next β add and remove BIOs from a chain π
πΈ 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 π
So BIO_push() pushes b on next, right? But here's the thing β if b is NULL, the function does literally nothing and just returns next. no drama, no notes, nothing happens.
Otherwise it prepends b to next β and b doesn't have to be a single BIO, it can be a whole entire chain of BIOs, slay. It does this unless next is NULL, in which case, well, you know. Then it makes a control call on b and returns b. periodt.
BIO_pop π¦
BIO_pop() removes the BIO b from any chain it's part of. if b is NULL, the function does nothing and returns NULL β iconically uneventful.
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 no association with the original chain β so it's free real estate, you can free it or pop it into a completely different chain. π
BIO_set_next π
BIO_set_next() replaces the existing next BIO in a chain with the BIO pointed to by next. and get this β the new chain may include some of the same BIOs from the old chain, or it may be completely different. main character energy, it can be whatever it wants to be. β¨
π NOTES π
ngl, the names of these functions are perhaps a little misleading. let me break it down:
BIO_push()actually joins two BIO chains β not what "push" makes you thinkBIO_pop()deletes a single BIO from a chain, and that deleted BIO does not need to be at the end of a chain. it's giving "pop from the middle, who's gonna stop me"
Also important: the process of calling BIO_push() and BIO_pop() on a BIO may have additional consequences β because a control call is made to the affected BIOs. Any effects will be noted in the descriptions of the individual BIOs. so like, read those too bestie, don't skip. π
π 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. cute little cast of characters. π
If the call:
BIO_push(b64, f);
is made, then the new chain will be b64-f. ate.
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. the way that data just flows through the whole pipeline, obsessed. π₯
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 bestie, the chain works both ways.
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. bye md2, we hardly knew ye. π
π SEE ALSO π
β HISTORY β
The BIO_set_next() function was added in OpenSSL 1.1.0. a newer icon. π
π§ COPYRIGHT π§
Copyright 2000-2026 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>.
okay that's the whole page bestie, go forth and chain your BIOs responsibly π β¨
signing off from OpenSSL version 3.5.6, dated 2026-04-07, page BIO_PUSH(3ossl) π«ΆπΈ
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms