BIO_PUSH(3ossl)

πŸ’– BIO_PUSH πŸ’–

okay bestie, so this is the OpenSSL manual page for BIO_PUSH, and it's lowkey one of the most important little pages in the whole bio(7) cinematic universe. it's giving ✨chain management✨. let's get into it. πŸ¦‹


🌸 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 πŸŽ€

okay so here's the tea β˜•

BIO_push() pushes b on next. if b is NULL the function does literally nothing and just returns next β€” no drama, no notes, she's unbothered. otherwise it prepends b, which can be a single BIO or a whole entire chain of BIOs, to next (unless next is NULL, in which case... yeah). then it makes a control call on b and returns b. slay. πŸ’…

BIO_pop() removes the BIO b from any chain it's part of. if b is NULL the function 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's no next BIO. and here's the glow-up moment: the removed BIO becomes a single BIO with no association with the original chain, so it can be freed πŸ•ŠοΈ or be made part of a completely different chain. main character energy, honestly.

BIO_set_next() replaces the existing next BIO in a chain with the BIO pointed to by next. the new chain may include some of the same BIOs from the old chain, or it may be completely different. no cap. πŸ”₯


πŸ‘‘ NOTES πŸ‘‘

not me about to say the names of these functions are maybe a little misleading πŸ™ˆ but like, genuinely, they are:

  • BIO_push() joins two BIO chains
  • BIO_pop() deletes a single BIO from a chain

and the deleted BIO does not need to be at the end of a chain. the way that pop doesn't mean "pop off the end" here... it's giving chaotic naming. πŸ’€

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 the individual BIOs. so check those, bestie. 🫢


πŸ’œ RETURN VALUES πŸ’œ

  • BIO_push() returns the head of the chain, which usually is b, or next if b is NULL.
  • BIO_pop() returns the next BIO in the chain, or NULL if 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. (iykyk 🧚)

if the call:

BIO_push(b64, f);

is made, then the new chain will be b64-f. then 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. iconic pipeline behaviour. ✨

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 girl, bidirectional. πŸ”

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's gone, she left the group chat. 😭


πŸ¦‹ SEE ALSO πŸ¦‹


⭐ HISTORY ⭐

the BIO_set_next() function was added in OpenSSL 1.1.0. a newer icon in the lineup. πŸ’…


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 and that's the whole page bestie!! πŸŽ€ this came from the OpenSSL 3.5.9 release, dated 2026-09-29, filed under BIO_PUSH(3ossl). periodt. πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from