xref: /openbsd/lib/libcrypto/man/BIO_push.3 (revision 8529ddd3)
1.Dd $Mdocdate: February 16 2015 $
2.Dt BIO_PUSH 3
3.Os
4.Sh NAME
5.Nm BIO_push ,
6.Nm BIO_pop
7.Nd add and remove BIOs from a chain
8.Sh SYNOPSIS
9.In openssl/bio.h
10.Ft BIO *
11.Fo BIO_push
12.Fa "BIO *b"
13.Fa "BIO *append"
14.Fc
15.Ft BIO *
16.Fo BIO_pop
17.Fa "BIO *b"
18.Fc
19.Sh DESCRIPTION
20The
21.Fn BIO_push
22function appends the BIO
23.Fa append
24to
25.Fa b
26and returns
27.Fa b .
28.Pp
29.Fn BIO_pop
30removes the BIO
31.Fa b
32from a chain and returns the next BIO in the chain, or
33.Dv NULL
34if there is no next BIO.
35The removed BIO then becomes a single BIO with no association with the
36original chain, it can thus be freed or attached to a different chain.
37.Sh RETURN VALUES
38.Fn BIO_push
39returns the beginning of the chain,
40.Fa b .
41.Pp
42.Fn BIO_pop
43returns the next BIO in the chain, or
44.Dv NULL
45if there is no next BIO.
46.Sh NOTES
47The names of these functions are perhaps a little misleading.
48.Fn BIO_push
49joins two BIO chains whereas
50.Fn BIO_pop
51deletes a single BIO from a chain,
52the deleted BIO does not need to be at the end of a chain.
53.Pp
54The process of calling
55.Fn BIO_push
56and
57.Fn BIO_pop
58on a BIO may have additional consequences:
59a control call is made to the affected BIOs.
60Any effects will be noted in the descriptions of individual BIOs.
61.Sh EXAMPLES
62For these examples suppose
63.Sy md1
64and
65.Sy md2
66are digest BIOs,
67.Sy b64
68is a base64 BIO and
69.Sy f
70is a file BIO.
71.Pp
72If the call
73.Pp
74.Dl BIO_push(b64, f);
75.Pp
76is made then the new chain will be
77.Sy b64-f .
78After making the calls
79.Bd -literal -offset indent
80BIO_push(md2, b64);
81BIO_push(md1, md2);
82.Ed
83.Pp
84the new chain is
85.Sy md1-md2-b64-f .
86Data written to
87.Sy md1
88will be digested
89by
90.Sy md1
91and
92.Sy md2 ,
93.Sy base64
94encoded and written to
95.Sy f .
96.Pp
97It should be noted that reading causes data to pass
98in the reverse direction, that is data is read from
99.Sy f ,
100base64
101.Sy decoded
102and digested
103by
104.Sy md1
105and
106.Sy md2 .
107If this call is made:
108.Pp
109.Dl BIO_pop(md2);
110.Pp
111The call will return
112.Sy b64
113and the new chain will be
114.Sy md1-b64-f Ns ;
115data can be written to
116.Sy md1
117as before.
118