xref: /netbsd-src/crypto/external/bsd/openssl/dist/doc/man3/BIO_push.pod (revision b0d1725196a7921d003d2c66a14f186abda4176b)
113d40330Schristos=pod
213d40330Schristos
313d40330Schristos=head1 NAME
413d40330Schristos
513d40330SchristosBIO_push, BIO_pop, BIO_set_next - add and remove BIOs from a chain
613d40330Schristos
713d40330Schristos=head1 SYNOPSIS
813d40330Schristos
913d40330Schristos #include <openssl/bio.h>
1013d40330Schristos
1121497c5cSchristos BIO *BIO_push(BIO *b, BIO *next);
1213d40330Schristos BIO *BIO_pop(BIO *b);
1313d40330Schristos void BIO_set_next(BIO *b, BIO *next);
1413d40330Schristos
1513d40330Schristos=head1 DESCRIPTION
1613d40330Schristos
1721497c5cSchristosBIO_push() pushes I<b> on I<next>.
1821497c5cSchristosIf I<b> is NULL the function does nothing and returns I<next>.
1921497c5cSchristosOtherwise it prepends I<b>, which may be a single BIO or a chain of BIOs,
2021497c5cSchristosto I<next> (unless I<next> is NULL).
2121497c5cSchristosIt then makes a control call on I<b> and returns I<b>.
2213d40330Schristos
2321497c5cSchristosBIO_pop() removes the BIO I<b> from any chain is is part of.
2421497c5cSchristosIf I<b> is NULL the function does nothing and returns NULL.
2521497c5cSchristosOtherwise it makes a control call on I<b> and
2621497c5cSchristosreturns the next BIO in the chain, or NULL if there is no next BIO.
2721497c5cSchristosThe removed BIO becomes a single BIO with no association with
2821497c5cSchristosthe original chain, it can thus be freed or be made part of a different chain.
2913d40330Schristos
3013d40330SchristosBIO_set_next() replaces the existing next BIO in a chain with the BIO pointed to
3121497c5cSchristosby I<next>. The new chain may include some of the same BIOs from the old chain
3213d40330Schristosor it may be completely different.
3313d40330Schristos
3413d40330Schristos=head1 NOTES
3513d40330Schristos
3613d40330SchristosThe names of these functions are perhaps a little misleading. BIO_push()
3713d40330Schristosjoins two BIO chains whereas BIO_pop() deletes a single BIO from a chain,
3813d40330Schristosthe deleted BIO does not need to be at the end of a chain.
3913d40330Schristos
4013d40330SchristosThe process of calling BIO_push() and BIO_pop() on a BIO may have additional
4121497c5cSchristosconsequences (a control call is made to the affected BIOs).
4221497c5cSchristosAny effects will be noted in the descriptions of individual BIOs.
4313d40330Schristos
44a3b08d93Schristos=head1 RETURN VALUES
45a3b08d93Schristos
4621497c5cSchristosBIO_push() returns the head of the chain,
4721497c5cSchristoswhich usually is I<b>, or I<next> if I<b> is NULL.
48a3b08d93Schristos
4921497c5cSchristosBIO_pop() returns the next BIO in the chain,
5021497c5cSchristosor NULL if there is no next BIO.
51a3b08d93Schristos
5213d40330Schristos=head1 EXAMPLES
5313d40330Schristos
5421497c5cSchristosFor these examples suppose I<md1> and I<md2> are digest BIOs,
5521497c5cSchristosI<b64> is a base64 BIO and I<f> is a file BIO.
5613d40330Schristos
5713d40330SchristosIf the call:
5813d40330Schristos
5913d40330Schristos BIO_push(b64, f);
6013d40330Schristos
6121497c5cSchristosis made then the new chain will be I<b64-f>. After making the calls
6213d40330Schristos
6313d40330Schristos BIO_push(md2, b64);
6413d40330Schristos BIO_push(md1, md2);
6513d40330Schristos
6621497c5cSchristosthe new chain is I<md1-md2-b64-f>. Data written to I<md1> will be digested
6721497c5cSchristosby I<md1> and I<md2>, base64 encoded, and finally written to I<f>.
6813d40330Schristos
6913d40330SchristosIt should be noted that reading causes data to pass in the reverse
7021497c5cSchristosdirection, that is data is read from I<f>, base64 decoded,
7121497c5cSchristosand digested by I<md2> and then I<md1>.
7221497c5cSchristos
7321497c5cSchristosThe call:
7413d40330Schristos
7513d40330Schristos BIO_pop(md2);
7613d40330Schristos
7721497c5cSchristoswill return I<b64> and the new chain will be I<md1-b64-f>.
7821497c5cSchristosData can be written to and read from I<md1> as before,
7921497c5cSchristosexcept that I<md2> will no more be applied.
8013d40330Schristos
8113d40330Schristos=head1 SEE ALSO
8213d40330Schristos
83*b0d17251SchristosL<bio(7)>
8413d40330Schristos
8513d40330Schristos=head1 HISTORY
8613d40330Schristos
8713d40330SchristosThe BIO_set_next() function was added in OpenSSL 1.1.0.
8813d40330Schristos
8913d40330Schristos=head1 COPYRIGHT
9013d40330Schristos
9121497c5cSchristosCopyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
9213d40330Schristos
93*b0d17251SchristosLicensed under the Apache License 2.0 (the "License").  You may not use
9413d40330Schristosthis file except in compliance with the License.  You can obtain a copy
9513d40330Schristosin the file LICENSE in the source distribution or at
9613d40330SchristosL<https://www.openssl.org/source/license.html>.
9713d40330Schristos
9813d40330Schristos=cut
99