summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorschwarze <>2015-02-16 16:42:14 +0000
committerschwarze <>2015-02-16 16:42:14 +0000
commit9a3026fb0a89a15ea2def3629cc13a69f1fc678c (patch)
tree28ac935f3dd22b133413a78861848f9501389a34 /src
parent4ab59c54f9da1075f740a1004c326b0784ed4de0 (diff)
downloadopenbsd-9a3026fb0a89a15ea2def3629cc13a69f1fc678c.tar.gz
openbsd-9a3026fb0a89a15ea2def3629cc13a69f1fc678c.tar.bz2
openbsd-9a3026fb0a89a15ea2def3629cc13a69f1fc678c.zip
third batch of perlpod(1) to mdoc(7) conversion
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/man/BIO_push.3117
-rw-r--r--src/lib/libcrypto/man/BIO_read.3115
-rw-r--r--src/lib/libcrypto/man/BIO_s_accept.3279
-rw-r--r--src/lib/libcrypto/man/BIO_s_bio.3295
-rw-r--r--src/lib/libcrypto/man/BIO_s_connect.3332
-rw-r--r--src/lib/libcrypto/man/BIO_s_fd.3137
-rw-r--r--src/lib/libcrypto/man/BIO_s_file.3248
-rw-r--r--src/lib/libcrypto/man/BIO_s_mem.3190
-rw-r--r--src/lib/libcrypto/man/BIO_s_null.332
-rw-r--r--src/lib/libcrypto/man/BIO_s_socket.399
-rw-r--r--src/lib/libcrypto/man/BIO_set_callback.3129
-rw-r--r--src/lib/libcrypto/man/BIO_should_retry.3145
-rw-r--r--src/lib/libcrypto/man/Makefile6
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_push.pod67
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_read.pod66
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_accept.pod189
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_bio.pod185
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_connect.pod191
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_fd.pod91
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_file.pod150
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_mem.pod112
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_null.pod35
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_socket.pod61
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_set_callback.pod105
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_should_retry.pod112
25 files changed, 2121 insertions, 1367 deletions
diff --git a/src/lib/libcrypto/man/BIO_push.3 b/src/lib/libcrypto/man/BIO_push.3
new file mode 100644
index 0000000000..848a09ba53
--- /dev/null
+++ b/src/lib/libcrypto/man/BIO_push.3
@@ -0,0 +1,117 @@
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.
diff --git a/src/lib/libcrypto/man/BIO_read.3 b/src/lib/libcrypto/man/BIO_read.3
new file mode 100644
index 0000000000..3114ab3da4
--- /dev/null
+++ b/src/lib/libcrypto/man/BIO_read.3
@@ -0,0 +1,115 @@
1.Dd $Mdocdate: February 16 2015 $
2.Dt BIO_READ 3
3.Os
4.Sh NAME
5.Nm BIO_read ,
6.Nm BIO_write ,
7.Nm BIO_gets ,
8.Nm BIO_puts
9.Nd BIO I/O functions
10.Sh SYNOPSIS
11.In openssl/bio.h
12.Ft int
13.Fo BIO_read
14.Fa "BIO *b"
15.Fa "void *buf"
16.Fa "int len"
17.Fc
18.Ft int
19.Fo BIO_gets
20.Fa "BIO *b"
21.Fa "char *buf"
22.Fa "int size"
23.Fc
24.Ft int
25.Fo BIO_write
26.Fa "BIO *b"
27.Fa "const void *buf"
28.Fa "int len"
29.Fc
30.Ft int
31.Fo BIO_puts
32.Fa "BIO *b"
33.Fa "const char *buf"
34.Fc
35.Sh DESCRIPTION
36.Fn BIO_read
37attempts to read
38.Fa len
39bytes from BIO
40.Fa b
41and places the data in
42.Fa buf .
43.Pp
44.Fn BIO_gets
45performs the BIOs "gets" operation and places the data in
46.Fa buf .
47Usually this operation will attempt to read a line of data
48from the BIO of maximum length
49.Fa len .
50There are exceptions to this however, for example
51.Fn BIO_gets
52on a digest BIO will calculate and return the digest
53and other BIOs may not support
54.Fn BIO_gets
55at all.
56.Pp
57.Fn BIO_write
58attempts to write
59.Fa len
60bytes from
61.Fa buf
62to BIO
63.Fa b .
64.Pp
65.Fn BIO_puts
66attempts to write a null terminated string
67.Fa buf
68to BIO
69.Fa b .
70.Sh RETURN VALUES
71All these functions return either the amount of data successfully
72read or written (if the return value is positive) or that no data
73was successfully read or written if the result is 0 or -1.
74If the return value is -2, then the operation is not implemented
75in the specific BIO type.
76.Sh NOTES
77A 0 or -1 return is not necessarily an indication of an error.
78In particular when the source/sink is non-blocking or of a certain type
79it may merely be an indication that no data is currently available and that
80the application should retry the operation later.
81.Pp
82One technique sometimes used with blocking sockets
83is to use a system call (such as
84.Xr select 2 ,
85.Xr poll 2
86or equivalent) to determine when data is available and then call
87.Xr read 3
88to read the data.
89The equivalent with BIOs (that is call
90.Xr select 2
91on the underlying I/O structure and then call
92.Fn BIO_read
93to read the data) should
94.Em not
95be used because a single call to
96.Fn BIO_read
97can cause several reads (and writes in the case of SSL BIOs)
98on the underlying I/O structure and may block as a result.
99Instead
100.Xr select 2
101(or equivalent) should be combined with non blocking I/O
102so successive reads will request a retry instead of blocking.
103.Pp
104See
105.Xr BIO_should_retry 3
106for details of how to determine the cause of a retry and other I/O issues.
107.Pp
108If the
109.Fn BIO_gets
110function is not supported by a BIO then it is possible to
111work around this by adding a buffering BIO
112.Xr BIO_f_buffer 3
113to the chain.
114.Sh SEE ALSO
115.Xr BIO_should_retry 3
diff --git a/src/lib/libcrypto/man/BIO_s_accept.3 b/src/lib/libcrypto/man/BIO_s_accept.3
new file mode 100644
index 0000000000..f5adfcc07c
--- /dev/null
+++ b/src/lib/libcrypto/man/BIO_s_accept.3
@@ -0,0 +1,279 @@
1.Dd $Mdocdate: February 16 2015 $
2.Dt BIO_S_ACCEPT 3
3.Os
4.Sh NAME
5.Nm BIO_s_accept ,
6.Nm BIO_set_accept_port ,
7.Nm BIO_get_accept_port ,
8.Nm BIO_new_accept ,
9.Nm BIO_set_nbio_accept ,
10.Nm BIO_set_accept_bios ,
11.Nm BIO_set_bind_mode ,
12.Nm BIO_get_bind_mode ,
13.Nm BIO_do_accept
14.Nd accept BIO
15.Sh SYNOPSIS
16.In openssl/bio.h
17.Ft BIO_METHOD *
18.Fo BIO_s_accept
19.Fa void
20.Fc
21.Ft long
22.Fo BIO_set_accept_port
23.Fa "BIO *b"
24.Fa "char *name"
25.Fc
26.Ft char *
27.Fo BIO_get_accept_port
28.Fa "BIO *b"
29.Fc
30.Ft BIO *
31.Fo BIO_new_accept
32.Fa "char *host_port"
33.Fc
34.Ft long
35.Fo BIO_set_nbio_accept
36.Fa "BIO *b"
37.Fa "int n"
38.Fc
39.Ft long
40.Fo BIO_set_accept_bios
41.Fa "BIO *b"
42.Fa "char *bio"
43.Fc
44.Ft long
45.Fo BIO_set_bind_mode
46.Fa "BIO *b"
47.Fa "long mode"
48.Fc
49.Ft long
50.Fo BIO_get_bind_mode
51.Fa "BIO *b"
52.Fa "long dummy"
53.Fc
54.Fd #define BIO_BIND_NORMAL 0
55.Fd #define BIO_BIND_REUSEADDR_IF_UNUSED 1
56.Fd #define BIO_BIND_REUSEADDR 2
57.Ft int
58.Fo BIO_do_accept
59.Fa "BIO *b"
60.Fc
61.Sh DESCRIPTION
62.Fn BIO_s_accept
63returns the accept BIO method.
64This is a wrapper round the platform's TCP/IP socket accept routines.
65.Pp
66Using accept BIOs, TCP/IP connections can be accepted
67and data transferred using only BIO routines.
68In this way any platform specific operations
69are hidden by the BIO abstraction.
70.Pp
71Read and write operations on an accept BIO
72will perform I/O on the underlying connection.
73If no connection is established and the port (see below) is set up
74properly then the BIO waits for an incoming connection.
75.Pp
76Accept BIOs support
77.Xr BIO_puts 3
78but not
79.Xr BIO_gets 3 .
80.Pp
81If the close flag is set on an accept BIO, then any active
82connection on that chain is shutdown and the socket closed when
83the BIO is freed.
84.Pp
85Calling
86.Xr BIO_reset 3
87on a accept BIO will close any active connection and reset the BIO
88into a state where it awaits another incoming connection.
89.Pp
90.Xr BIO_get_fd 3
91and
92.Xr BIO_set_fd 3
93can be called to retrieve or set the accept socket.
94See
95.Xr BIO_s_fd 3 .
96.Pp
97.Fn BIO_set_accept_port
98uses the string
99.Fa name
100to set the accept port.
101The port is represented as a string of the form
102.Ar host : Ns Ar port ,
103where
104.Ar host
105is the interface to use and
106.Ar port
107is the port.
108Either or both values can be
109.Qq *
110which is interpreted as meaning any interface or port respectively.
111.Ar port
112has the same syntax as the port specified in
113.Xr BIO_set_conn_port 3
114for connect BIOs.
115It can be a numerical port string or a string to lookup using
116.Xr getservbyname 3
117and a string table.
118.Pp
119.Fn BIO_new_accept
120combines
121.Xr BIO_new 3
122and
123.Fn BIO_set_accept_port
124into a single call.
125It creates a new accept BIO with port
126.Fa host_port .
127.Pp
128.Fn BIO_set_nbio_accept
129sets the accept socket to blocking mode (the default) if
130.Fa n
131is 0 or non blocking mode if
132.Fa n
133is 1.
134.Pp
135.Fn BIO_set_accept_bios
136can be used to set a chain of BIOs which will be duplicated
137and prepended to the chain when an incoming connection is received.
138This is useful if, for example, a buffering or SSL BIO
139is required for each connection.
140The chain of BIOs must not be freed after this call,
141they will be automatically freed when the accept BIO is freed.
142.Pp
143.Fn BIO_set_bind_mode
144and
145.Fn BIO_get_bind_mode
146set and retrieve the current bind mode.
147If
148.Dv BIO_BIND_NORMAL Pq the default
149is set, then another socket cannot be bound to the same port.
150If
151.Dv BIO_BIND_REUSEADDR
152is set, then other sockets can bind to the same port.
153If
154.Dv BIO_BIND_REUSEADDR_IF_UNUSED
155is set, then an attempt is first made to use
156.Dv BIO_BIN_NORMAL ;
157if this fails and the port is not in use,
158then a second attempt is made using
159.Dv BIO_BIND_REUSEADDR .
160.Pp
161.Fn BIO_do_accept
162serves two purposes.
163When it is first called, after the accept BIO has been setup,
164it will attempt to create the accept socket and bind an address to it.
165Second and subsequent calls to
166.Fn BIO_do_accept
167will await an incoming connection, or request a retry in non blocking mode.
168.Sh NOTES
169When an accept BIO is at the end of a chain, it will await an
170incoming connection before processing I/O calls.
171When an accept BIO is not at then end of a chain,
172it passes I/O calls to the next BIO in the chain.
173.Pp
174When a connection is established a new socket BIO is created
175for the connection and appended to the chain.
176That is the chain is now accept->socket.
177This effectively means that attempting I/O on an initial accept
178socket will await an incoming connection then perform I/O on it.
179.Pp
180If any additional BIOs have been set using
181.Fn BIO_set_accept_bios ,
182then they are placed between the socket and the accept BIO,
183that is the chain will be accept->otherbios->socket.
184.Pp
185If a server wishes to process multiple connections (as is normally
186the case), then the accept BIO must be made available for further
187incoming connections.
188This can be done by waiting for a connection and then calling:
189.Pp
190.Dl connection = BIO_pop(accept);
191.Pp
192After this call,
193.Sy connection
194will contain a BIO for the recently established connection and
195.Sy accept
196will now be a single BIO again which can be used
197to await further incoming connections.
198If no further connections will be accepted, the
199.Sy accept
200can be freed using
201.Xr BIO_free 3 .
202.Pp
203If only a single connection will be processed,
204it is possible to perform I/O using the accept BIO itself.
205This is often undesirable however because the accept BIO
206will still accept additional incoming connections.
207This can be resolved by using
208.Xr BIO_pop 3
209(see above) and freeing up the accept BIO after the initial connection.
210.Pp
211If the underlying accept socket is non-blocking and
212.Fn BIO_do_accept
213is called to await an incoming connection, it is possible for
214.Xr BIO_should_io_special 3
215with the reason
216.Dv BIO_RR_ACCEPT .
217If this happens, then it is an indication that an accept attempt
218would block: the application should take appropriate action
219to wait until the underlying socket has accepted a connection
220and retry the call.
221.Pp
222.Fn BIO_set_accept_port ,
223.Fn BIO_get_accept_port ,
224.Fn BIO_set_nbio_accept ,
225.Fn BIO_set_accept_bios ,
226.Fn BIO_set_bind_mode ,
227.Fn BIO_get_bind_mode ,
228and
229.Fn BIO_do_accept
230are macros.
231.Sh EXAMPLES
232This example accepts two connections on port 4444,
233sends messages down each and finally closes both down.
234.Bd -literal -offset 2n
235BIO *abio, *cbio, *cbio2;
236ERR_load_crypto_strings();
237abio = BIO_new_accept("4444");
238
239/* First call to BIO_accept() sets up accept BIO */
240if (BIO_do_accept(abio) <= 0) {
241 fprintf(stderr, "Error setting up accept\en");
242 ERR_print_errors_fp(stderr);
243 exit(0);
244}
245
246/* Wait for incoming connection */
247if (BIO_do_accept(abio) <= 0) {
248 fprintf(stderr, "Error accepting connection\en");
249 ERR_print_errors_fp(stderr);
250 exit(0);
251}
252fprintf(stderr, "Connection 1 established\en");
253
254/* Retrieve BIO for connection */
255cbio = BIO_pop(abio);
256
257BIO_puts(cbio, "Connection 1: Sending out Data on initial connection\en");
258fprintf(stderr, "Sent out data on connection 1\en");
259
260/* Wait for another connection */
261if (BIO_do_accept(abio) <= 0) {
262 fprintf(stderr, "Error accepting connection\en");
263 ERR_print_errors_fp(stderr);
264 exit(0);
265}
266fprintf(stderr, "Connection 2 established\en");
267
268/* Close accept BIO to refuse further connections */
269cbio2 = BIO_pop(abio);
270BIO_free(abio);
271
272BIO_puts(cbio2, "Connection 2: Sending out Data on second\en");
273fprintf(stderr, "Sent out data on connection 2\en");
274BIO_puts(cbio, "Connection 1: Second connection established\en");
275
276/* Close the two established connections */
277BIO_free(cbio);
278BIO_free(cbio2);
279.Ed
diff --git a/src/lib/libcrypto/man/BIO_s_bio.3 b/src/lib/libcrypto/man/BIO_s_bio.3
new file mode 100644
index 0000000000..af7bdabd33
--- /dev/null
+++ b/src/lib/libcrypto/man/BIO_s_bio.3
@@ -0,0 +1,295 @@
1.Dd $Mdocdate: February 16 2015 $
2.Dt BIO_S_BIO 3
3.Os
4.Sh NAME
5.Nm BIO_s_bio ,
6.Nm BIO_make_bio_pair ,
7.Nm BIO_destroy_bio_pair ,
8.Nm BIO_shutdown_wr ,
9.Nm BIO_set_write_buf_size ,
10.Nm BIO_get_write_buf_size ,
11.Nm BIO_new_bio_pair ,
12.Nm BIO_get_write_guarantee ,
13.Nm BIO_ctrl_get_write_guarantee ,
14.Nm BIO_get_read_request ,
15.Nm BIO_ctrl_get_read_request ,
16.Nm BIO_ctrl_reset_read_request
17.Nd BIO pair BIO
18.Sh SYNOPSIS
19.In openssl/bio.h
20.Ft BIO_METHOD *
21.Fo BIO_s_bio
22.Fa void
23.Fc
24.Bd -unfilled
25#define BIO_make_bio_pair(b1, b2) \e
26 (int)BIO_ctrl(b1, BIO_C_MAKE_BIO_PAIR, 0, b2)
27#define BIO_destroy_bio_pair(b) \e
28 (int)BIO_ctrl(b, BIO_C_DESTROY_BIO_PAIR, 0, NULL)
29#define BIO_shutdown_wr(b) \e
30 (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
31#define BIO_set_write_buf_size(b, size) \e
32 (int)BIO_ctrl(b, BIO_C_SET_WRITE_BUF_SIZE, size, NULL)
33#define BIO_get_write_buf_size(b, size) \e
34 (size_t)BIO_ctrl(b, BIO_C_GET_WRITE_BUF_SIZE, size, NULL)
35.Ed
36.Pp
37.Ft int
38.Fo BIO_new_bio_pair
39.Fa "BIO **bio1"
40.Fa "size_t writebuf1"
41.Fa "BIO **bio2"
42.Fa "size_t writebuf2"
43.Fc
44.Bd -unfilled
45#define BIO_get_write_guarantee(b) \e
46 (int)BIO_ctrl(b, BIO_C_GET_WRITE_GUARANTEE, 0, NULL)
47.Ed
48.Pp
49.Ft size_t
50.Fo BIO_ctrl_get_write_guarantee
51.Fa "BIO *b"
52.Fc
53.Bd -unfilled
54#define BIO_get_read_request(b) \e
55 (int)BIO_ctrl(b, BIO_C_GET_READ_REQUEST, 0, NULL)
56.Ed
57.Pp
58.Ft size_t
59.Fo BIO_ctrl_get_read_request
60.Fa "BIO *b"
61.Fc
62.Ft int
63.Fo BIO_ctrl_reset_read_request
64.Fa "BIO *b"
65.Fc
66.Sh DESCRIPTION
67.Fn BIO_s_bio
68returns the method for a BIO pair.
69A BIO pair is a pair of source/sink BIOs where data written to either
70half of the pair is buffered and can be read from the other half.
71Both halves must usually be handled by the same application thread
72since no locking is done on the internal data structures.
73.Pp
74Since BIO chains typically end in a source/sink BIO,
75it is possible to make this one half of a BIO pair and
76have all the data processed by the chain under application control.
77.Pp
78One typical use of BIO pairs is
79to place TLS/SSL I/O under application control.
80This can be used when the application wishes to use a non standard
81transport for TLS/SSL or the normal socket routines are inappropriate.
82.Pp
83Calls to
84.Xr BIO_read 3
85will read data from the buffer or request a retry if no data is available.
86.Pp
87Calls to
88.Xr BIO_write 3
89will place data in the buffer or request a retry if the buffer is full.
90.Pp
91The standard calls
92.Xr BIO_ctrl_pending 3
93and
94.Xr BIO_ctrl_wpending 3
95can be used to determine the amount of pending data
96in the read or write buffer.
97.Pp
98.Xr BIO_reset 3
99clears any data in the write buffer.
100.Pp
101.Fn BIO_make_bio_pair
102joins two separate BIOs into a connected pair.
103.Pp
104.Fn BIO_destroy_pair
105destroys the association between two connected BIOs.
106Freeing up any half of the pair will automatically destroy the association.
107.Pp
108.Fn BIO_shutdown_wr
109is used to close down a BIO
110.Fa b .
111After this call no further writes on BIO
112.Fa b
113are allowed; they will return an error.
114Reads on the other half of the pair will return any pending data
115or EOF when all pending data has been read.
116.Pp
117.Fn BIO_set_write_buf_size
118sets the write buffer size of BIO
119.Fa b
120to
121.Fa size .
122If the size is not initialized a default value is used.
123This is currently 17K, sufficient for a maximum size TLS record.
124.Pp
125.Fn BIO_get_write_buf_size
126returns the size of the write buffer.
127.Pp
128.Fn BIO_new_bio_pair
129combines the calls to
130.Xr BIO_new 3 ,
131.Fn BIO_make_bio_pair
132and
133.Fn BIO_set_write_buf_size
134to create a connected pair of BIOs
135.Fa bio1
136and
137.Fa bio2
138with write buffer sizes
139.Fa writebuf1
140and
141.Fa writebuf2 .
142If either size is zero, then the default size is used.
143.Fn BIO_new_bio_pair
144does not check whether
145.Fa bio1
146or
147.Fa bio2
148do point to some other BIO, the values are overwritten,
149.Xr BIO_free 3
150is not called.
151.Pp
152.Fn BIO_get_write_guarantee
153and
154.Fn BIO_ctrl_get_write_guarantee
155return the maximum length of data
156that can be currently written to the BIO.
157Writes larger than this value will return a value from
158.Xr BIO_write 3
159less than the amount requested or if the buffer is full request a retry.
160.Fn BIO_ctrl_get_write_guarantee
161is a function whereas
162.Fn BIO_get_write_guarantee
163is a macro.
164.Pp
165.Fn BIO_get_read_request
166and
167.Fn BIO_ctrl_get_read_request
168return the amount of data requested, or the buffer size if it is less,
169if the last read attempt at the other half of the BIO pair failed
170due to an empty buffer.
171This can be used to determine how much data should be
172written to the BIO so the next read will succeed:
173this is most useful in TLS/SSL applications where the amount of
174data read is usually meaningful rather than just a buffer size.
175After a successful read this call will return zero.
176It also will return zero once new data has been written
177satisfying the read request or part of it.
178Note that
179.Fn BIO_get_read_request
180never returns an amount larger than that returned by
181.Fn BIO_get_write_guarantee .
182.Pp
183.Fn BIO_ctrl_reset_read_request
184can also be used to reset the value returned by
185.Fn BIO_get_read_request
186to zero.
187.Sh RETURN VALUES
188.Fn BIO_new_bio_pair
189returns 1 on success, with the new BIOs available in
190.Fa bio1
191and
192.Fa bio2 ,
193or 0 on failure, with NULL pointers stored into the locations for
194.Fa bio1
195and
196.Fa bio2 .
197Check the error stack for more information.
198.\" XXX More return values need to be added here.
199.Sh NOTES
200Both halves of a BIO pair should be freed.
201Even if one half is implicitly freed due to a
202.Xr BIO_free_all 3
203or
204.Xr SSL_free 3
205call, the other half still needs to be freed.
206.Pp
207When used in bidirectional applications (such as TLS/SSL)
208care should be taken to flush any data in the write buffer.
209This can be done by calling
210.Xr BIO_pending 3
211on the other half of the pair and, if any data is pending,
212reading it and sending it to the underlying transport.
213This must be done before any normal processing (such as calling
214.Xr select 2 )
215due to a request and
216.Xr BIO_should_read 3
217being true.
218.Pp
219To see why this is important,
220consider a case where a request is sent using
221.Xr BIO_write 3
222and a response read with
223.Xr BIO_read 3 ,
224this can occur during an TLS/SSL handshake for example.
225.Xr BIO_write 3
226will succeed and place data in the write buffer.
227.Xr BIO_read 3
228will initially fail and
229.Xr BIO_should_read 3
230will be true.
231If the application then waits for data to become available
232on the underlying transport before flushing the write buffer,
233it will never succeed because the request was never sent.
234.Sh EXAMPLE
235The BIO pair can be used to have full control
236over the network access of an application.
237The application can call
238.Xr select 2
239on the socket as required without having to go through the SSL-interface.
240.Bd -literal -offset 2n
241BIO *internal_bio, *network_bio;
242\&...
243BIO_new_bio_pair(internal_bio, 0, network_bio, 0);
244SSL_set_bio(ssl, internal_bio, internal_bio);
245SSL_operations();
246\&...
247
248application | TLS-engine
249 | |
250 +----------> SSL_operations()
251 | /\e ||
252 | || \e/
253 | BIO-pair (internal_bio)
254 +----------< BIO-pair (network_bio)
255 | |
256 socket |
257
258\&...
259SSL_free(ssl); /* implicitly frees internal_bio */
260BIO_free(network_bio);
261\&...
262.Ed
263.Pp
264As the BIO pair will only buffer the data and never directly access
265the connection, it behaves non-blocking and will return as soon as
266the write buffer is full or the read buffer is drained.
267Then the application has to flush the write buffer
268and/or fill the read buffer.
269.Pp
270Use
271.Xr BIO_ctrl_pending 3
272to find out whether data is buffered in the BIO
273and must be transfered to the network.
274Use
275.Fn BIO_ctrl_get_read_request
276to find out how many bytes must be written into the buffer before the
277.Xr SSL_operation 3
278can successfully be continued.
279.Sh SEE ALSO
280.Xr bio 3 ,
281.Xr BIO_read 3 ,
282.Xr BIO_should_retry 3 ,
283.Xr ssl 3 ,
284.Xr SSL_set_bio 3
285.Sh CAVEATS
286As the data is buffered,
287.Xr SSL_operation 3
288may return with an
289.Dv ERROR_SSL_WANT_READ
290condition, but there is still data in the write buffer.
291An application must not rely on the error value of
292.Xr SSL_operation 3
293but must assure that the write buffer is always flushed first.
294Otherwise a deadlock may occur as the peer might be waiting
295for the data before being able to continue.
diff --git a/src/lib/libcrypto/man/BIO_s_connect.3 b/src/lib/libcrypto/man/BIO_s_connect.3
new file mode 100644
index 0000000000..960400e853
--- /dev/null
+++ b/src/lib/libcrypto/man/BIO_s_connect.3
@@ -0,0 +1,332 @@
1.Dd $Mdocdate: February 16 2015 $
2.Dt BIO_S_CONNECT 3
3.Os
4.Sh NAME
5.Nm BIO_s_connect ,
6.Nm BIO_new_connect ,
7.Nm BIO_set_conn_hostname ,
8.Nm BIO_set_conn_port ,
9.Nm BIO_set_conn_ip ,
10.Nm BIO_set_conn_int_port ,
11.Nm BIO_get_conn_hostname ,
12.Nm BIO_get_conn_port ,
13.Nm BIO_get_conn_ip ,
14.Nm BIO_get_conn_int_port ,
15.Nm BIO_set_nbio ,
16.Nm BIO_do_connect
17.Nd connect BIO
18.Sh SYNOPSIS
19.In openssl/bio.h
20.Ft BIO_METHOD *
21.Fo BIO_s_connect
22.Fa void
23.Fc
24.Ft BIO *
25.Fo BIO_new_connect
26.Fa "char *name"
27.Fc
28.Ft long
29.Fo BIO_set_conn_hostname
30.Fa "BIO *b"
31.Fa "char *name"
32.Fc
33.Ft long
34.Fo BIO_set_conn_port
35.Fa "BIO *b"
36.Fa "char *port"
37.Fc
38.Ft long
39.Fo BIO_set_conn_ip
40.Fa "BIO *b"
41.Fa "char *ip"
42.Fc
43.Ft long
44.Fo BIO_set_conn_int_port
45.Fa "BIO *b"
46.Fa "char *port"
47.Fc
48.Ft char *
49.Fo BIO_get_conn_hostname
50.Fa "BIO *b"
51.Fc
52.Ft char *
53.Fo BIO_get_conn_port
54.Fa "BIO *b"
55.Fc
56.Ft char *
57.Fo BIO_get_conn_ip
58.Fa "BIO *b"
59.Fa "dummy"
60.Fc
61.Ft long
62.Fo BIO_get_conn_int_port
63.Fa "BIO *b"
64.Fa "int port"
65.Fc
66.Ft long
67.Fo BIO_set_nbio
68.Fa "BIO *b"
69.Fa "long n"
70.Fc
71.Ft int
72.Fo BIO_do_connect
73.Fa "BIO *b"
74.Fc
75.Sh DESCRIPTION
76.Fn BIO_s_connect
77returns the connect BIO method.
78This is a wrapper around the platform's TCP/IP socket connection routines.
79.Pp
80Using connect BIOs, TCP/IP connections can be made and data
81transferred using only BIO routines.
82In this way any platform specific operations
83are hidden by the BIO abstraction.
84.Pp
85Read and write operations on a connect BIO will perform I/O
86on the underlying connection.
87If no connection is established and the port and hostname (see below)
88is set up properly, then a connection is established first.
89.Pp
90Connect BIOs support
91.Xr BIO_puts 3
92but not
93.Xr BIO_gets 3 .
94.Pp
95If the close flag is set on a connect BIO, then any active connection
96is shutdown and the socket closed when the BIO is freed.
97.Pp
98Calling
99.Xr BIO_reset 3
100on a connect BIO will close any active connection and reset the BIO
101into a state where it can connect to the same host again.
102.Pp
103.Xr BIO_get_fd 3
104places the underlying socket in
105.Fa c
106if it is not
107.Dv NULL ,
108it also returns the socket.
109If
110.Fa c
111is not
112.Dv NULL
113it should be of type
114.Vt "int *" .
115.Pp
116.Fn BIO_set_conn_hostname
117uses the string
118.Fa name
119to set the hostname.
120The hostname can be an IP address.
121The hostname can also include the port in the form
122.Ar hostname : Ns Ar port .
123It is also acceptable to use the forms
124.Ar hostname Ns / Ns Pa any/other/path
125or
126.Ar hostname : Ns Ar port Ns / Ns Pa any/other/path .
127.Pp
128.Fn BIO_set_conn_port
129sets the port to
130.Fa port .
131.Fa port
132can be the numerical form or a string such as
133.Cm http .
134A string will be looked up first using
135.Xr getservbyname 3
136on the host platform, but if that fails
137a built-in table of port names will be used.
138Currently the list is
139.Cm http ,
140.Cm telnet ,
141.Cm socks ,
142.Cm https ,
143.Cm ssl ,
144.Cm ftp ,
145.Cm gopher ,
146and
147.Cm wais .
148.Pp
149.Fn BIO_set_conn_ip
150sets the IP address to
151.Fa ip
152using binary form, that is four bytes specifying the IP address
153in big-endian form.
154.Pp
155.Fn BIO_set_conn_int_port
156sets the port using
157.Fa port .
158.Fa port
159should
160be of type
161.Vt "int *" .
162.Pp
163.Fn BIO_get_conn_hostname
164returns the hostname of the connect BIO or
165.Dv NULL
166if the BIO is initialized but no hostname is set.
167This return value is an internal pointer which should not be modified.
168.Pp
169.Fn BIO_get_conn_port
170returns the port as a string.
171.Pp
172.Fn BIO_get_conn_ip
173returns the IP address in binary form.
174.Pp
175.Fn BIO_get_conn_int_port
176returns the port as an
177.Vt int .
178.Pp
179.Fn BIO_set_nbio
180sets the non blocking I/O flag to
181.Fa n .
182If
183.Fa n
184is zero then blocking I/O is set.
185If
186.Fa n
187is 1 then non blocking I/O is set.
188Blocking I/O is the default.
189The call to
190.Fn BIO_set_nbio
191should be made before the connection is established
192because non blocking I/O is set during the connect process.
193.Pp
194.Fn BIO_new_connect
195combines
196.Xr BIO_new 3
197and
198.Fn BIO_set_conn_hostname
199into a single call.
200It creates a new connect BIO with
201.Fa name .
202.Pp
203.Fn BIO_do_connect
204attempts to connect the supplied BIO.
205It returns 1 if the connection was established successfully.
206A zero or negative value is returned if the connection
207could not be established.
208The call
209.Xr BIO_should_retry 3
210should be used for non blocking connect BIOs
211to determine if the call should be retried.
212.Sh NOTES
213If blocking I/O is set then a non positive return value from any
214I/O call is caused by an error condition, although a zero return
215will normally mean that the connection was closed.
216.Pp
217If the port name is supplied as part of the host name then this will
218override any value set with
219.Fn BIO_set_conn_port .
220This may be undesirable if the application does not wish to allow
221connection to arbitrary ports.
222This can be avoided by checking for the presence of the
223.Sq \&:
224character in the passed hostname and either indicating an error
225or truncating the string at that point.
226.Pp
227The values returned by
228.Fn BIO_get_conn_hostname ,
229.Fn BIO_get_conn_port ,
230.Fn BIO_get_conn_ip ,
231and
232.Fn BIO_get_conn_int_port
233are updated when a connection attempt is made.
234Before any connection attempt the values returned
235are those set by the application itself.
236.Pp
237Applications do not have to call
238.Fn BIO_do_connect
239but may wish to do so to separate the connection process
240from other I/O processing.
241.Pp
242If non-blocking I/O is set,
243then retries will be requested as appropriate.
244.Pp
245It addition to
246.Xr BIO_should_read 3
247and
248.Xr BIO_should_write 3
249it is also possible for
250.Xr BIO_should_io_special 3
251to be true during the initial connection process with the reason
252.Dv BIO_RR_CONNECT .
253If this is returned, it is an indication
254that a connection attempt would block.
255The application should then take appropriate action to wait
256until the underlying socket has connected and retry the call.
257.Pp
258.Fn BIO_set_conn_hostname ,
259.Fn BIO_set_conn_port ,
260.Fn BIO_set_conn_ip ,
261.Fn BIO_set_conn_int_port ,
262.Fn BIO_get_conn_hostname ,
263.Fn BIO_get_conn_port ,
264.Fn BIO_get_conn_ip ,
265.Fn BIO_get_conn_int_port ,
266.Fn BIO_set_nbio ,
267and
268.Fn BIO_do_connect
269are macros.
270.Sh RETURN VALUES
271.Fn BIO_s_connect
272returns the connect BIO method.
273.Pp
274.Xr BIO_get_fd 3
275returns the socket or -1 if the BIO has not been initialized.
276.Pp
277.Fn BIO_set_conn_hostname ,
278.Fn BIO_set_conn_port ,
279.Fn BIO_set_conn_ip ,
280and
281.Fn BIO_set_conn_int_port
282always return 1.
283.Pp
284.Fn BIO_get_conn_hostname
285returns the connected hostname or
286.Dv NULL
287if none is set.
288.Pp
289.Fn BIO_get_conn_port
290returns a string representing the connected port or
291.Dv NULL
292if not set.
293.Pp
294.Fn BIO_get_conn_ip
295returns a pointer to the connected IP address in binary form
296or all zeros if not set.
297.Pp
298.Fn BIO_get_conn_int_port
299returns the connected port or 0 if none was set.
300.Pp
301.Fn BIO_set_nbio
302always returns 1.
303.Pp
304.Fn BIO_do_connect
305returns 1 if the connection was successfully
306established and 0 or -1 if the connection failed.
307.Sh EXAMPLES
308This example connects to a webserver on the local host and attempts
309to retrieve a page and copy the result to standard output.
310.Bd -literal -offset 2n
311BIO *cbio, *out;
312int len;
313char tmpbuf[1024];
314
315ERR_load_crypto_strings();
316cbio = BIO_new_connect("localhost:http");
317out = BIO_new_fp(stdout, BIO_NOCLOSE);
318if (BIO_do_connect(cbio) <= 0) {
319 fprintf(stderr, "Error connecting to server\en");
320 ERR_print_errors_fp(stderr);
321 /* whatever ... */
322}
323BIO_puts(cbio, "GET / HTTP/1.0\en\en");
324for(;;) {
325 len = BIO_read(cbio, tmpbuf, 1024);
326 if (len <= 0)
327 break;
328 BIO_write(out, tmpbuf, len);
329}
330BIO_free(cbio);
331BIO_free(out);
332.Ed
diff --git a/src/lib/libcrypto/man/BIO_s_fd.3 b/src/lib/libcrypto/man/BIO_s_fd.3
new file mode 100644
index 0000000000..3d6a2a3ca9
--- /dev/null
+++ b/src/lib/libcrypto/man/BIO_s_fd.3
@@ -0,0 +1,137 @@
1.Dd $Mdocdate: February 16 2015 $
2.Dt BIO_S_FD 3
3.Os
4.Sh NAME
5.Nm BIO_s_fd ,
6.Nm BIO_set_fd ,
7.Nm BIO_get_fd ,
8.Nm BIO_new_fd
9.Nd file descriptor BIO
10.Sh SYNOPSIS
11.In openssl/bio.h
12.Ft BIO_METHOD *
13.Fo BIO_s_fd
14.Fa "void"
15.Fc
16.Fd #define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
17.Fd #define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)
18.Ft BIO *
19.Fo BIO_new_fd
20.Fa "int fd"
21.Fa "int close_flag"
22.Fc
23.Sh DESCRIPTION
24.Fn BIO_s_fd
25returns the file descriptor BIO method.
26This is a wrapper around the platform's file descriptor routines such as
27.Xr read 2
28and
29.Xr write 2 .
30.Pp
31.Xr BIO_read 3
32and
33.Xr BIO_write 3
34read or write the underlying descriptor.
35.Xr BIO_puts 3
36is supported but
37.Xr BIO_gets 3
38is not.
39.Pp
40If the close flag is set,
41.Xr close 2
42is called on the underlying file descriptor when the BIO is freed.
43.Pp
44.Xr BIO_reset 3
45attempts to set the file pointer to the start of the file using
46.Fn lseek fd 0 0 .
47.Pp
48.Xr BIO_seek 3
49sets the file pointer to position
50.Fa ofs
51from start of file using
52.Fn lseek fd ofs 0 .
53.Pp
54.Xr BIO_tell 3
55returns the current file position by calling
56.Fn lseek fd 0 1 .
57.Pp
58.Fn BIO_set_fd
59sets the file descriptor of BIO
60.Fa b
61to
62.Fa fd
63and the close flag to
64.Fa c .
65.Pp
66.Fn BIO_get_fd
67places the file descriptor in
68.Fa c
69if it is not
70.Dv NULL ,
71it also returns the file descriptor.
72If
73.Fa c
74is not
75.Dv NULL ,
76it should be of type
77.Vt "int *" .
78.Pp
79.Fn BIO_new_fd
80returns a file descriptor BIO using
81.Fa fd
82and
83.Fa close_flag .
84.Sh NOTES
85The behaviour of
86.Xr BIO_read 3
87and
88.Xr BIO_write 3
89depends on the behavior of the platform's
90.Xr read 2
91and
92.Xr write 2
93calls on the descriptor.
94If the underlying file descriptor is in a non blocking mode,
95then the BIO will behave in the manner described in the
96.Xr BIO_read 3
97and
98.Xr BIO_should_retry 3
99manual pages.
100.Pp
101File descriptor BIOs should not be used for socket I/O.
102Use socket BIOs instead.
103.Sh RETURN VALUES
104.Fn BIO_s_fd
105returns the file descriptor BIO method.
106.Pp
107.Xr BIO_reset 3
108returns zero for success and -1 if an error occurred.
109.Xr BIO_seek 3
110and
111.Xr BIO_tell 3
112return the current file position or -1 if an error occurred.
113These values reflect the underlying
114.Xr lseek 2
115behaviour.
116.Pp
117.Fn BIO_set_fd
118always returns 1.
119.Pp
120.Fn BIO_get_fd
121returns the file descriptor or -1 if the BIO has not been initialized.
122.Pp
123.Fn BIO_new_fd
124returns the newly allocated BIO or
125.Dv NULL
126if an error occurred.
127.Sh EXAMPLE
128This is a file descriptor BIO version of "Hello World":
129.Bd -literal -offset indent
130BIO *out;
131out = BIO_new_fd(fileno(stdout), BIO_NOCLOSE);
132BIO_printf(out, "Hello World\en");
133BIO_free(out);
134.Ed
135.Sh SEE ALSO
136.Xr BIO_read 3 ,
137.Xr BIO_seek 3
diff --git a/src/lib/libcrypto/man/BIO_s_file.3 b/src/lib/libcrypto/man/BIO_s_file.3
new file mode 100644
index 0000000000..c7075a3fb7
--- /dev/null
+++ b/src/lib/libcrypto/man/BIO_s_file.3
@@ -0,0 +1,248 @@
1.Dd $Mdocdate: February 16 2015 $
2.Dt BIO_S_FILE 3
3.Os
4.Sh NAME
5.Nm BIO_s_file ,
6.Nm BIO_new_file ,
7.Nm BIO_new_fp ,
8.Nm BIO_set_fp ,
9.Nm BIO_get_fp ,
10.Nm BIO_read_filename ,
11.Nm BIO_write_filename ,
12.Nm BIO_append_filename ,
13.Nm BIO_rw_filename
14.Nd FILE bio
15.Sh SYNOPSIS
16.In openssl/bio.h
17.Ft BIO_METHOD *
18.Fo BIO_s_file
19.Fa void
20.Fc
21.Ft BIO *
22.Fo BIO_new_file
23.Fa "const char *filename"
24.Fa "const char *mode"
25.Fc
26.Ft BIO *
27.Fo BIO_new_fp
28.Fa "FILE *stream"
29.Fa "int flags"
30.Fc
31.Ft long
32.Fo BIO_set_fp
33.Fa "BIO *b"
34.Fa "FILE *fp"
35.Fa "int flags"
36.Fc
37.Ft long
38.Fo BIO_get_fp
39.Fa "BIO *b"
40.Fa "FILE **fpp"
41.Fc
42.Ft int
43.Fo BIO_read_filename
44.Fa "BIO *b"
45.Fa "char *name"
46.Fc
47.Ft int
48.Fo BIO_write_filename
49.Fa "BIO *b"
50.Fa "char *name"
51.Fc
52.Ft int
53.Fo BIO_append_filename
54.Fa "BIO *b"
55.Fa "char *name"
56.Fc
57.Ft int
58.Fo BIO_rw_filename
59.Fa "BIO *b"
60.Fa "char *name"
61.Fc
62.Sh DESCRIPTION
63.Fn BIO_s_file
64returns the BIO file method.
65As its name implies, it is a wrapper around the stdio
66.Vt FILE
67structure and it is a source/sink BIO.
68.Pp
69Calls to
70.Xr BIO_read 3
71and
72.Xr BIO_write 3
73read and write data to the underlying stream.
74.Xr BIO_gets 3
75and
76.Xr BIO_puts 3
77are supported on file BIOs.
78.Pp
79.Xr BIO_flush 3
80on a file BIO calls the
81.Xr fflush 3
82function on the wrapped stream.
83.Pp
84.Xr BIO_reset 3
85attempts to change the file pointer to the start of file using
86.Fn fseek stream 0 0 .
87.Pp
88.Xr BIO_seek 3
89sets the file pointer to position
90.Fa ofs
91from the start of the file using
92.Fn fseek stream ofs 0 .
93.Pp
94.Xr BIO_eof 3
95calls
96.Xr feof 3 .
97.Pp
98Setting the
99.Dv BIO_CLOSE
100flag calls
101.Xr fclose 3
102on the stream when the BIO is freed.
103.Pp
104.Fn BIO_new_file
105creates a new file BIO with mode
106.Fa mode .
107The meaning of
108.Fa mode
109is the same as for the stdio function
110.Xr fopen 3 .
111The
112.Dv BIO_CLOSE
113flag is set on the returned BIO.
114.Pp
115.Fn BIO_new_fp
116creates a file BIO wrapping
117.Fa stream .
118Flags can be:
119.Dv BIO_CLOSE , BIO_NOCLOSE Pq the close flag ,
120.Dv BIO_FP_TEXT
121(sets the underlying stream to text mode, default is binary:
122this only has any effect under Win32).
123.Pp
124.Fn BIO_set_fp
125set the file pointer of a file BIO to
126.Fa fp .
127.Fa flags
128has the same meaning as in
129.Fn BIO_new_fp .
130.Fn BIO_set_fp
131is a macro.
132.Pp
133.Fn BIO_get_fp
134retrieves the file pointer of a file BIO, it is a macro.
135.Pp
136.Xr BIO_seek 3
137is a macro that sets the position pointer to
138.Fa offset
139bytes from the start of file.
140.Pp
141.Xr BIO_tell 3
142returns the value of the position pointer.
143.Pp
144.Fn BIO_read_filename ,
145.Fn BIO_write_filename ,
146.Fn BIO_append_filename ,
147and
148.Fn BIO_rw_filename
149set the file BIO
150.Fa b
151to use file
152.Fa name
153for reading, writing, append or read write respectively.
154.Sh NOTES
155When wrapping stdout, stdin, or stderr, the underlying stream
156should not normally be closed, so the
157.Dv BIO_NOCLOSE
158flag should be set.
159.Pp
160Because the file BIO calls the underlying stdio functions, any quirks
161in stdio behaviour will be mirrored by the corresponding BIO.
162.Pp
163On Windows,
164.Fn BIO_new_files
165reserves for the filename argument to be UTF-8 encoded.
166In other words, if you have to make it work in a multi-lingual
167environment, encode file names in UTF-8.
168.Sh RETURN VALUES
169.Fn BIO_s_file
170returns the file BIO method.
171.Pp
172.Fn BIO_new_file
173and
174.Fn BIO_new_fp
175return a file BIO or
176.Dv NULL
177if an error occurred.
178.Pp
179.Fn BIO_set_fp
180and
181.Fn BIO_get_fp
182return 1 for success or 0 for failure (although the current
183implementation never returns 0).
184.Pp
185.Xr BIO_seek 3
186returns the same value as the underlying
187.Xr fseek 3
188function: 0 for success or -1 for failure.
189.Pp
190.Xr BIO_tell 3
191returns the current file position.
192.Pp
193.Fn BIO_read_filename ,
194.Fn BIO_write_filename ,
195.Fn BIO_append_filename ,
196and
197.Fn BIO_rw_filename
198return 1 for success or 0 for failure.
199.Sh EXAMPLES
200File BIO "hello world":
201.Bd -literal -offset indent
202BIO *bio_out;
203bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
204BIO_printf(bio_out, "Hello World\en");
205.Ed
206.Pp
207Alternative technique:
208.Bd -literal -offset indent
209BIO *bio_out;
210bio_out = BIO_new(BIO_s_file());
211if(bio_out == NULL) /* Error ... */
212if(!BIO_set_fp(bio_out, stdout, BIO_NOCLOSE)) /* Error ... */
213BIO_printf(bio_out, "Hello World\en");
214.Ed
215.Pp
216Write to a file:
217.Bd -literal -offset indent
218BIO *out;
219out = BIO_new_file("filename.txt", "w");
220if(!out) /* Error occurred */
221BIO_printf(out, "Hello World\en");
222BIO_free(out);
223.Ed
224.Pp
225Alternative technique:
226.Bd -literal -offset indent
227BIO *out;
228out = BIO_new(BIO_s_file());
229if(out == NULL) /* Error ... */
230if(!BIO_write_filename(out, "filename.txt")) /* Error ... */
231BIO_printf(out, "Hello World\en");
232BIO_free(out);
233.Ed
234.Sh SEE ALSO
235.Xr BIO_read 3 ,
236.Xr BIO_seek 3
237.Sh BUGS
238.Xr BIO_reset 3
239and
240.Xr BIO_seek 3
241are implemented using
242.Xr fseek 3
243on the underlying stream.
244The return value for
245.Xr fseek 3
246is 0 for success or -1 if an error occurred.
247This differs from other types of BIO which will typically return
2481 for success and a non positive value if an error occurred.
diff --git a/src/lib/libcrypto/man/BIO_s_mem.3 b/src/lib/libcrypto/man/BIO_s_mem.3
new file mode 100644
index 0000000000..a37b4bff98
--- /dev/null
+++ b/src/lib/libcrypto/man/BIO_s_mem.3
@@ -0,0 +1,190 @@
1.Dd $Mdocdate: February 16 2015 $
2.Dt BIO_S_MEM 3
3.Os
4.Sh NAME
5.Nm BIO_s_mem ,
6.Nm BIO_set_mem_eof_return ,
7.Nm BIO_get_mem_data ,
8.Nm BIO_set_mem_buf ,
9.Nm BIO_get_mem_ptr ,
10.Nm BIO_new_mem_buf
11.Nd memory BIO
12.Sh SYNOPSIS
13.In openssl/bio.h
14.Ft BIO_METHOD *
15.Fo BIO_s_mem
16.Fa "void"
17.Fc
18.Ft long
19.Fo BIO_set_mem_eof_return
20.Fa "BIO *b"
21.Fa "int v"
22.Fc
23.Ft long
24.Fo BIO_get_mem_data
25.Fa "BIO *b"
26.Fa "char **pp"
27.Fc
28.Ft long
29.Fo BIO_set_mem_buf
30.Fa "BIO *b"
31.Fa "BUF_MEM *bm"
32.Fa "int c"
33.Fc
34.Ft long
35.Fo BIO_get_mem_ptr
36.Fa "BIO *b"
37.Fa "BUF_MEM **pp"
38.Fc
39.Ft BIO *
40.Fo BIO_new_mem_buf
41.Fa "void *buf"
42.Fa "int len"
43.Fc
44.Sh DESCRIPTION
45.Fn BIO_s_mem
46returns the memory BIO method function.
47.Pp
48A memory BIO is a source/sink BIO which uses memory for its I/O.
49Data written to a memory BIO is stored in a
50.Vt BUF_MEM
51structure which is extended as appropriate to accommodate the stored data.
52.Pp
53Any data written to a memory BIO can be recalled by reading from it.
54Unless the memory BIO is read only,
55any data read from it is deleted from the BIO.
56.Pp
57Memory BIOs support
58.Xr BIO_gets 3
59and
60.Xr BIO_puts 3 .
61.Pp
62If the
63.Dv BIO_CLOSE
64flag is set when a memory BIO is freed, the underlying
65.Dv BUF_MEM
66structure is also freed.
67.Pp
68Calling
69.Xr BIO_reset 3
70on a read/write memory BIO clears any data in it.
71On a read only BIO it restores the BIO to its original state
72and the read only data can be read again.
73.Pp
74.Xr BIO_eof 3
75is true if no data is in the BIO.
76.Pp
77.Xr BIO_ctrl_pending 3
78returns the number of bytes currently stored.
79.Pp
80.Xr BIO_set_mem_eof_return 3
81sets the behaviour of memory BIO
82.Fa b
83when it is empty.
84If
85.Fa v
86is zero, then an empty memory BIO will return EOF:
87It will return zero and
88.Fn BIO_should_retry
89will be false.
90If
91.Fa v
92is non-zero then it will return
93.Fa v
94when it is empty and it will set the read retry flag:
95.Fn BIO_read_retry
96is true.
97To avoid ambiguity with a normal positive return value
98.Fa v
99should be set to a negative value, typically -1.
100.Pp
101.Fn BIO_get_mem_data
102sets
103.Fa pp
104to a pointer to the start of the memory BIO's data
105and returns the total amount of data available.
106It is implemented as a macro.
107.Pp
108.Fn BIO_set_mem_buf
109sets the internal BUF_MEM structure to
110.Fa bm
111and sets the close flag to
112.Fa c ,
113that is
114.Fa c
115should be either
116.Dv BIO_CLOSE
117or
118.Dv BIO_NOCLOSE .
119.Fn BIO_set_mem_buf
120is a macro.
121.Pp
122.Fn BIO_get_mem_ptr
123places the underlying
124.Vt BUF_MEM
125structure in
126.Fa pp .
127It is a macro.
128.Pp
129.Fn BIO_new_mem_buf
130creates a memory BIO using
131.Fa len
132bytes of data at
133.Fa buf .
134If
135.Fa len
136is -1, then
137.Fa buf
138is assumed to be NUL terminated and its length is determined by
139.Xr strlen 3 .
140The BIO is set to a read only state and as a result cannot be written to.
141This is useful when some data needs to be made available
142from a static area of memory in the form of a BIO.
143The supplied data is read directly from the supplied buffer:
144it is
145.Em not
146copied first, so the supplied area of memory must be unchanged
147until the BIO is freed.
148.Sh NOTES
149Writes to memory BIOs will always succeed if memory is available:
150their size can grow indefinitely.
151.Pp
152Every read from a read/write memory BIO will remove the data just read
153with an internal copy operation.
154If a BIO contains a lot of data and it is read in small chunks,
155the operation can be very slow.
156The use of a read only memory BIO avoids this problem.
157If the BIO must be read/write then adding a buffering BIO
158to the chain will speed up the process.
159.Sh EXAMPLES
160Create a memory BIO and write some data to it:
161.Bd -literal -offset indent
162BIO *mem = BIO_new(BIO_s_mem());
163BIO_puts(mem, "Hello World\en");
164.Ed
165.Pp
166Create a read only memory BIO:
167.Bd -literal -offset indent
168char data[] = "Hello World";
169BIO *mem;
170mem = BIO_new_mem_buf(data, -1);
171.Ed
172.Pp
173Extract the
174.Vt BUF_MEM
175structure from a memory BIO and then free up the BIO:
176.Bd -literal -offset indent
177BUF_MEM *bptr;
178BIO_get_mem_ptr(mem, &bptr);
179/* Make sure BIO_free() leaves BUF_MEM alone. */
180BIO_set_close(mem, BIO_NOCLOSE);
181BIO_free(mem);
182.Ed
183.Sh BUGS
184There should be an option to set the maximum size of a memory BIO.
185.Pp
186There should be a way to "rewind" a read/write BIO without destroying
187its contents.
188.Pp
189The copying operation should not occur after every small read
190of a large BIO to improve efficiency.
diff --git a/src/lib/libcrypto/man/BIO_s_null.3 b/src/lib/libcrypto/man/BIO_s_null.3
new file mode 100644
index 0000000000..05008aabfc
--- /dev/null
+++ b/src/lib/libcrypto/man/BIO_s_null.3
@@ -0,0 +1,32 @@
1.Dd $Mdocdate: February 16 2015 $
2.Dt BIO_S_NULL 3
3.Os
4.Sh NAME
5.Nm BIO_s_null
6.Nd null data sink
7.Sh SYNOPSIS
8.In openssl/bio.h
9.Ft BIO_METHOD *
10.Fo BIO_s_null
11.Fa void
12.Fc
13.Sh DESCRIPTION
14.Fn BIO_s_null
15returns the null sink BIO method.
16Data written to the null sink is discarded, reads return EOF.
17.Sh NOTES
18A null sink BIO behaves in a similar manner to the
19.Xr null 4
20device.
21.Pp
22A null bio can be placed on the end of a chain to discard any data
23passed through it.
24.Pp
25A null sink is useful if, for example, an application wishes
26to digest some data by writing through a digest bio
27but not send the digested data anywhere.
28Since a BIO chain must normally include a source/sink BIO,
29this can be achieved by adding a null sink BIO to the end of the chain.
30.Sh RETURN VALUES
31.Fn BIO_s_null
32returns the null sink BIO method.
diff --git a/src/lib/libcrypto/man/BIO_s_socket.3 b/src/lib/libcrypto/man/BIO_s_socket.3
new file mode 100644
index 0000000000..f7aff6a4c8
--- /dev/null
+++ b/src/lib/libcrypto/man/BIO_s_socket.3
@@ -0,0 +1,99 @@
1.Dd $Mdocdate: February 16 2015 $
2.Dt BIO_S_SOCKET 3
3.Os
4.Sh NAME
5.Nm BIO_s_socket ,
6.Nm BIO_new_socket
7.Nd socket BIO
8.Sh SYNOPSIS
9.In openssl/bio.h
10.Ft BIO_METHOD *
11.Fo BIO_s_socket
12.Fa void
13.Fc
14.Ft long
15.Fo BIO_set_fd
16.Fa "BIO *b"
17.Fa "int fd"
18.Fa "long close_flag"
19.Fc
20.Ft long
21.Fo BIO_get_fd
22.Fa "BIO *b"
23.Fa "int *c"
24.Fc
25.Ft BIO *
26.Fo BIO_new_socket
27.Fa "int sock"
28.Fa "int close_flag"
29.Fc
30.Sh DESCRIPTION
31.Fn BIO_s_socket
32returns the socket BIO method.
33This is a wrapper around the platform's socket routines.
34.Pp
35.Xr BIO_read 3
36and
37.Xr BIO_write 3
38read or write the underlying socket.
39.Xr BIO_puts 3
40is supported but
41.Xr BIO_gets 3
42is not.
43.Pp
44If the close flag is set, then the socket is shut down and closed
45when the BIO is freed.
46.Pp
47.Fn BIO_set_fd
48sets the socket of BIO
49.Fa b
50to
51.Fa fd
52and the close flag to
53.Fa close_flag .
54.Pp
55.Fn BIO_get_fd
56places the socket in
57.Fa c
58if it is not
59.Dv NULL ,
60it also returns the socket.
61If
62.Fa c
63is not
64.Dv NULL
65it should be of type
66.Vt "int *" .
67.Pp
68.Fn BIO_new_socket
69returns a socket BIO using
70.Fa sock
71and
72.Fa close_flag .
73.Sh NOTES
74Socket BIOs also support any relevant functionality of file descriptor BIOs.
75.Pp
76The reason for having separate file descriptor and socket BIOs
77is that on some platforms, sockets are not file descriptors
78and use distinct I/O routines.
79Windows is one such platform.
80Any code mixing the two will not work on all platforms.
81.Pp
82.Fn BIO_set_fd
83and
84.Fn BIO_get_fd
85are macros.
86.Sh RETURN VALUES
87.Fn BIO_s_socket
88returns the socket BIO method.
89.Pp
90.Fn BIO_set_fd
91always returns 1.
92.Pp
93.Fn BIO_get_fd
94returns the socket or -1 if the BIO has not been initialized.
95.Pp
96.Fn BIO_new_socket
97returns the newly allocated BIO or
98.Dv NULL
99if an error occurred.
diff --git a/src/lib/libcrypto/man/BIO_set_callback.3 b/src/lib/libcrypto/man/BIO_set_callback.3
new file mode 100644
index 0000000000..39d284890e
--- /dev/null
+++ b/src/lib/libcrypto/man/BIO_set_callback.3
@@ -0,0 +1,129 @@
1.Dd $Mdocdate: February 16 2015 $
2.Dt BIO_SET_CALLBACK 3
3.Os
4.Sh NAME
5.Nm BIO_set_callback ,
6.Nm BIO_get_callback ,
7.Nm BIO_set_callback_arg ,
8.Nm BIO_get_callback_arg ,
9.Nm BIO_debug_callback
10.Nd BIO callback functions
11.Sh SYNOPSIS
12.In openssl/bio.h
13.Fd #define BIO_set_callback(b,cb) ((b)->callback=(cb))
14.Fd #define BIO_get_callback(b) ((b)->callback)
15.Fd #define BIO_set_callback_arg(b,arg) ((b)->cb_arg=(char *)(arg))
16.Fd #define BIO_get_callback_arg(b) ((b)->cb_arg)
17.Ft long
18.Fo BIO_debug_callback
19.Fa "BIO *bio"
20.Fa "int cmd"
21.Fa "const char *argp"
22.Fa "int argi"
23.Fa "long argl"
24.Fa "long ret"
25.Fc
26.Ft typedef long *
27.Fo callback
28.Fa "BIO *b"
29.Fa "int oper"
30.Fa "const char *argp"
31.Fa "int argi"
32.Fa "long argl"
33.Fa "long retvalue"
34.Fc
35.Sh DESCRIPTION
36.Fn BIO_set_callback
37and
38.Fn BIO_get_callback
39set and retrieve the BIO callback, they are both macros.
40The callback is called during most high level BIO operations.
41It can be used for debugging purposes to trace operations on a BIO
42or to modify its operation.
43.Pp
44.Fn BIO_set_callback_arg
45and
46.Fn BIO_get_callback_arg
47are macros which can be used to set and retrieve an argument
48for use in the callback.
49.Pp
50.Fn BIO_debug_callback
51is a standard debugging callback which prints
52out information relating to each BIO operation.
53If the callback argument is set, it is interpreted as a BIO
54to send the information to, otherwise stderr is used.
55.Pp
56.Fn callback
57is the callback function itself.
58The meaning of each argument is described below.
59.Pp
60The BIO the callback is attached to is passed in
61.Fa b .
62.Pp
63.Fa oper
64is set to the operation being performed.
65For some operations the callback is called twice,
66once before and once after the actual operation.
67The latter case has
68.Fa oper
69or'ed with
70.Dv BIO_CB_RETURN .
71.Pp
72The meaning of the arguments
73.Fa argp ,
74.Fa argi
75and
76.Fa argl
77depends on the value of
78.Fa oper ,
79that is the operation being performed.
80.Pp
81.Fa retvalue
82is the return value that would be returned to the application
83if no callback were present.
84The actual value returned is the return value of the callback itself.
85In the case of callbacks called before the actual BIO operation,
861 is placed in retvalue.
87If the return value is not positive, it will be immediately returned to
88the application and the BIO operation will not be performed.
89.Pp
90The callback should normally simply return
91.Fa retvalue
92when it has finished processing, unless it specifically wishes
93to modify the value returned to the application.
94.Ss Callback operations
95.Bl -tag -width Ds
96.It Fn BIO_free b
97.Fn callback b BIO_CB_FREE NULL 0L 0L 1L
98is called before the free operation.
99.It Fn BIO_read b out outl
100.Fn callback b BIO_CB_READ out outl 0L 1L
101is called before the read and
102.Fn callback b BIO_CB_READ|BIO_CB_RETURN out outl 0L retvalue
103after.
104.It Fn BIO_write b in inl
105.Fn callback b BIO_CB_WRITE in inl 0L 1L
106is called before the write and
107.Fn callback b BIO_CB_WRITE|BIO_CB_RETURN in inl 0L retvalue
108after.
109.It Fn BIO_gets b out outl
110.Fn callback b BIO_CB_GETS out outl 0L 1L
111is called before the operation and
112.Fn callback b BIO_CB_GETS|BIO_CB_RETURN out outl 0L retvalue
113after.
114.It Fn BIO_puts b in
115.Fn callback b BIO_CB_WRITE in 0 0L 1L
116is called before the operation and
117.Fn callback b BIO_CB_WRITE|BIO_CB_RETURN in 0 0L retvalue
118after.
119.It Fn BIO_ctrl b cmd larg parg
120.Fn callback b BIO_CB_CTRL parg cmd larg 1L
121is called before the call and
122.Fn callback b BIO_CB_CTRL|BIO_CB_RETURN parg cmd larg ret
123after.
124.El
125.Sh EXAMPLES
126The
127.Fn BIO_debug_callback
128function is a good example, its source is in the file
129.Pa crypto/bio/bio_cb.c .
diff --git a/src/lib/libcrypto/man/BIO_should_retry.3 b/src/lib/libcrypto/man/BIO_should_retry.3
new file mode 100644
index 0000000000..cb5eda3121
--- /dev/null
+++ b/src/lib/libcrypto/man/BIO_should_retry.3
@@ -0,0 +1,145 @@
1.Dd $Mdocdate: February 16 2015 $
2.Dt BIO_SHOULD_RETRY 3
3.Os
4.Sh NAME
5.Nm BIO_should_retry ,
6.Nm BIO_should_read ,
7.Nm BIO_should_write ,
8.Nm BIO_should_io_special ,
9.Nm BIO_retry_type ,
10.Nm BIO_get_retry_BIO ,
11.Nm BIO_get_retry_reason
12.Nd BIO retry functions
13.Sh SYNOPSIS
14.In openssl/bio.h
15.Pp
16.Fd #define BIO_should_read(a) ((a)->flags & BIO_FLAGS_READ)
17.Fd #define BIO_should_write(a) ((a)->flags & BIO_FLAGS_WRITE)
18.Fd #define BIO_should_io_special(a) ((a)->flags & BIO_FLAGS_IO_SPECIAL)
19.Fd #define BIO_retry_type(a) ((a)->flags & BIO_FLAGS_RWS)
20.Fd #define BIO_should_retry(a) ((a)->flags & BIO_FLAGS_SHOULD_RETRY)
21.Fd #define BIO_FLAGS_READ 0x01
22.Fd #define BIO_FLAGS_WRITE 0x02
23.Fd #define BIO_FLAGS_IO_SPECIAL 0x04
24.Fd #define BIO_FLAGS_RWS \e
25.Fd \& (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
26.Fd #define BIO_FLAGS_SHOULD_RETRY 0x08
27.Ft BIO *
28.Fo BIO_get_retry_BIO
29.Fa "BIO *bio"
30.Fa "int *reason"
31.Fc
32.Ft int
33.Fo BIO_get_retry_reason
34.Fa "BIO *bio"
35.Fc
36.Sh DESCRIPTION
37These functions determine why a BIO is not able to read or write data.
38They will typically be called after a failed
39.Xr BIO_read 3
40or
41.Xr BIO_write 3
42call.
43.Pp
44.Fn BIO_should_retry
45is true if the call that produced this condition
46should be retried at a later time.
47.Pp
48If
49.Fn BIO_should_retry
50is false, the cause is an error condition.
51.Pp
52.Fn BIO_should_read
53is true if the cause of the condition is that a BIO needs to read data.
54.Pp
55.Fn BIO_should_write
56is true if the cause of the condition is that a BIO needs to write data.
57.Pp
58.Fn BIO_should_io_special
59is true if some "special" condition, that is a reason other than
60reading or writing, is the cause of the condition.
61.Pp
62.Fn BIO_retry_type
63returns a mask of the cause of a retry condition consisting of the values
64.Dv BIO_FLAGS_READ ,
65.Dv BIO_FLAGS_WRITE ,
66.Dv BIO_FLAGS_IO_SPECIAL
67though current BIO types will only set one of these.
68.Pp
69.Fn BIO_get_retry_BIO
70determines the precise reason for the special condition.
71It returns the BIO that caused this condition and if
72.Fa reason
73is not
74.Dv NULL
75it contains the reason code.
76The meaning of the reason code and the action that should be taken
77depends on the type of BIO that resulted in this condition.
78.Pp
79.Fn BIO_get_retry_reason
80returns the reason for a special condition
81if passed the relevant BIO, for example as returned by
82.Fn BIO_get_retry_BIO .
83.Sh NOTES
84If
85.Fn BIO_should_retry
86returns false, then the precise "error condition" depends on
87the BIO type that caused it and the return code of the BIO operation.
88For example if a call to
89.Xr BIO_read 3
90on a socket BIO returns 0 and
91.Fn BIO_should_retry
92is false, then the cause will be that the connection closed.
93A similar condition on a file BIO will mean that it has reached EOF.
94Some BIO types may place additional information on the error queue.
95For more details see the individual BIO type manual pages.
96.Pp
97If the underlying I/O structure is in a blocking mode,
98almost all current BIO types will not request a retry,
99because the underlying I/O calls will not.
100If the application knows that the BIO type will never
101signal a retry then it need not call
102.Fn BIO_should_retry
103after a failed BIO I/O call.
104This is typically done with file BIOs.
105.Pp
106SSL BIOs are the only current exception to this rule:
107they can request a retry even if the underlying I/O structure
108is blocking, if a handshake occurs during a call to
109.Xr BIO_read 3 .
110An application can retry the failed call immediately
111or avoid this situation by setting
112.Dv SSL_MODE_AUTO_RETRY
113on the underlying SSL structure.
114.Pp
115While an application may retry a failed non blocking call immediately,
116this is likely to be very inefficient because the call will fail
117repeatedly until data can be processed or is available.
118An application will normally wait until the necessary condition
119is satisfied.
120How this is done depends on the underlying I/O structure.
121.Pp
122For example if the cause is ultimately a socket and
123.Fn BIO_should_read
124is true then a call to
125.Xr select 2
126may be made to wait until data is available
127and then retry the BIO operation.
128By combining the retry conditions of several non blocking BIOs in a single
129.Xr select 2
130call it is possible to service several BIOs in a single thread,
131though the performance may be poor if SSL BIOs are present because
132long delays can occur during the initial handshake process.
133.Pp
134It is possible for a BIO to block indefinitely if the underlying I/O
135structure cannot process or return any data.
136This depends on the behaviour of the platforms I/O functions.
137This is often not desirable: one solution is to use non blocking I/O
138and use a timeout on the
139.Xr select 2
140(or equivalent) call.
141.Sh BUGS
142The OpenSSL ASN1 functions cannot gracefully deal with non blocking I/O:
143they cannot retry after a partial read or write.
144This is usually worked around by only passing the relevant data to ASN1
145functions when the entire structure can be read or written.
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile
index fcf9416248..2ac6e5b6f6 100644
--- a/src/lib/libcrypto/man/Makefile
+++ b/src/lib/libcrypto/man/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.17 2015/02/14 14:09:01 schwarze Exp $ 1# $OpenBSD: Makefile,v 1.18 2015/02/16 16:42:14 schwarze Exp $
2 2
3.include <bsd.own.mk> # for NOMAN 3.include <bsd.own.mk> # for NOMAN
4 4
@@ -21,8 +21,6 @@ MAN= \
21 BIO_f_null.3 \ 21 BIO_f_null.3 \
22 BIO_find_type.3 \ 22 BIO_find_type.3 \
23 BIO_new.3 \ 23 BIO_new.3 \
24
25GENMAN= \
26 BIO_push.3 \ 24 BIO_push.3 \
27 BIO_read.3 \ 25 BIO_read.3 \
28 BIO_s_accept.3 \ 26 BIO_s_accept.3 \
@@ -35,6 +33,8 @@ GENMAN= \
35 BIO_s_socket.3 \ 33 BIO_s_socket.3 \
36 BIO_set_callback.3 \ 34 BIO_set_callback.3 \
37 BIO_should_retry.3 \ 35 BIO_should_retry.3 \
36
37GENMAN= \
38 BN_BLINDING_new.3 \ 38 BN_BLINDING_new.3 \
39 BN_CTX_new.3 \ 39 BN_CTX_new.3 \
40 BN_CTX_start.3 \ 40 BN_CTX_start.3 \
diff --git a/src/lib/libssl/src/doc/crypto/BIO_push.pod b/src/lib/libssl/src/doc/crypto/BIO_push.pod
deleted file mode 100644
index 39c964b272..0000000000
--- a/src/lib/libssl/src/doc/crypto/BIO_push.pod
+++ /dev/null
@@ -1,67 +0,0 @@
1=pod
2
3=head1 NAME
4
5BIO_push, BIO_pop - add and remove BIOs from a chain.
6
7=head1 SYNOPSIS
8
9 #include <openssl/bio.h>
10
11 BIO * BIO_push(BIO *b,BIO *append);
12 BIO * BIO_pop(BIO *b);
13
14=head1 DESCRIPTION
15
16The BIO_push() function appends the BIO B<append> to B<b>, and returns
17B<b>.
18
19BIO_pop() removes the BIO B<b> from a chain and returns the next BIO
20in the chain, or NULL if there is no next BIO. The removed BIO then
21becomes a single BIO with no association with the original chain,
22it can thus be freed or attached to a different chain.
23
24=head1 NOTES
25
26The names of these functions are perhaps a little misleading. BIO_push()
27joins two BIO chains whereas BIO_pop() deletes a single BIO from a chain,
28the deleted BIO does not need to be at the end of a chain.
29
30The process of calling BIO_push() and BIO_pop() on a BIO may have additional
31consequences (a control call is made to the affected BIOs) any effects will
32be noted in the descriptions of individual BIOs.
33
34=head1 EXAMPLES
35
36For these examples suppose B<md1> and B<md2> are digest BIOs, B<b64> is
37a base64 BIO and B<f> is a file BIO.
38
39If the call:
40
41 BIO_push(b64, f);
42
43is made then the new chain will be B<b64-f>. After making the calls
44
45 BIO_push(md2, b64);
46 BIO_push(md1, md2);
47
48the new chain is B<md1-md2-b64-f>. Data written to B<md1> will be digested
49by B<md1> and B<md2>, B<base64> encoded and written to B<f>.
50
51It should be noted that reading causes data to pass in the reverse
52direction, that is data is read from B<f>, base64 B<decoded> and digested
53by B<md1> and B<md2>. If the call:
54
55 BIO_pop(md2);
56
57The call will return B<b64> and the new chain will be B<md1-b64-f>; data can
58be written to B<md1> as before.
59
60=head1 RETURN VALUES
61
62BIO_push() returns the beginning of the chain, B<b>.
63
64BIO_pop() returns the next BIO in the chain, or NULL if there is no next
65BIO.
66
67=cut
diff --git a/src/lib/libssl/src/doc/crypto/BIO_read.pod b/src/lib/libssl/src/doc/crypto/BIO_read.pod
deleted file mode 100644
index e527bff8d0..0000000000
--- a/src/lib/libssl/src/doc/crypto/BIO_read.pod
+++ /dev/null
@@ -1,66 +0,0 @@
1=pod
2
3=head1 NAME
4
5BIO_read, BIO_write, BIO_gets, BIO_puts - BIO I/O functions
6
7=head1 SYNOPSIS
8
9 #include <openssl/bio.h>
10
11 int BIO_read(BIO *b, void *buf, int len);
12 int BIO_gets(BIO *b, char *buf, int size);
13 int BIO_write(BIO *b, const void *buf, int len);
14 int BIO_puts(BIO *b, const char *buf);
15
16=head1 DESCRIPTION
17
18BIO_read() attempts to read B<len> bytes from BIO B<b> and places
19the data in B<buf>.
20
21BIO_gets() performs the BIOs "gets" operation and places the data
22in B<buf>. Usually this operation will attempt to read a line of data
23from the BIO of maximum length B<len>. There are exceptions to this
24however, for example BIO_gets() on a digest BIO will calculate and
25return the digest and other BIOs may not support BIO_gets() at all.
26
27BIO_write() attempts to write B<len> bytes from B<buf> to BIO B<b>.
28
29BIO_puts() attempts to write a null terminated string B<buf> to BIO B<b>.
30
31=head1 RETURN VALUES
32
33All these functions return either the amount of data successfully read or
34written (if the return value is positive) or that no data was successfully
35read or written if the result is 0 or -1. If the return value is -2 then
36the operation is not implemented in the specific BIO type.
37
38=head1 NOTES
39
40A 0 or -1 return is not necessarily an indication of an error. In
41particular when the source/sink is non-blocking or of a certain type
42it may merely be an indication that no data is currently available and that
43the application should retry the operation later.
44
45One technique sometimes used with blocking sockets is to use a system call
46(such as select(), poll() or equivalent) to determine when data is available
47and then call read() to read the data. The equivalent with BIOs (that is call
48select() on the underlying I/O structure and then call BIO_read() to
49read the data) should B<not> be used because a single call to BIO_read()
50can cause several reads (and writes in the case of SSL BIOs) on the underlying
51I/O structure and may block as a result. Instead select() (or equivalent)
52should be combined with non blocking I/O so successive reads will request
53a retry instead of blocking.
54
55See L<BIO_should_retry(3)|BIO_should_retry(3)> for details of how to
56determine the cause of a retry and other I/O issues.
57
58If the BIO_gets() function is not supported by a BIO then it possible to
59work around this by adding a buffering BIO L<BIO_f_buffer(3)|BIO_f_buffer(3)>
60to the chain.
61
62=head1 SEE ALSO
63
64L<BIO_should_retry(3)|BIO_should_retry(3)>
65
66=cut
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod b/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod
deleted file mode 100644
index 5729d38193..0000000000
--- a/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod
+++ /dev/null
@@ -1,189 +0,0 @@
1=pod
2
3=head1 NAME
4
5BIO_s_accept, BIO_set_accept_port, BIO_get_accept_port, BIO_new_accept,
6BIO_set_nbio_accept, BIO_set_accept_bios, BIO_set_bind_mode,
7BIO_get_bind_mode, BIO_do_accept - accept BIO
8
9=head1 SYNOPSIS
10
11 #include <openssl/bio.h>
12
13 BIO_METHOD *BIO_s_accept(void);
14
15 long BIO_set_accept_port(BIO *b, char *name);
16 char *BIO_get_accept_port(BIO *b);
17
18 BIO *BIO_new_accept(char *host_port);
19
20 long BIO_set_nbio_accept(BIO *b, int n);
21 long BIO_set_accept_bios(BIO *b, char *bio);
22
23 long BIO_set_bind_mode(BIO *b, long mode);
24 long BIO_get_bind_mode(BIO *b, long dummy);
25
26 #define BIO_BIND_NORMAL 0
27 #define BIO_BIND_REUSEADDR_IF_UNUSED 1
28 #define BIO_BIND_REUSEADDR 2
29
30 int BIO_do_accept(BIO *b);
31
32=head1 DESCRIPTION
33
34BIO_s_accept() returns the accept BIO method. This is a wrapper
35round the platform's TCP/IP socket accept routines.
36
37Using accept BIOs, TCP/IP connections can be accepted and data
38transferred using only BIO routines. In this way any platform
39specific operations are hidden by the BIO abstraction.
40
41Read and write operations on an accept BIO will perform I/O
42on the underlying connection. If no connection is established
43and the port (see below) is set up properly then the BIO
44waits for an incoming connection.
45
46Accept BIOs support BIO_puts() but not BIO_gets().
47
48If the close flag is set on an accept BIO then any active
49connection on that chain is shutdown and the socket closed when
50the BIO is freed.
51
52Calling BIO_reset() on a accept BIO will close any active
53connection and reset the BIO into a state where it awaits another
54incoming connection.
55
56BIO_get_fd() and BIO_set_fd() can be called to retrieve or set
57the accept socket. See L<BIO_s_fd(3)|BIO_s_fd(3)>
58
59BIO_set_accept_port() uses the string B<name> to set the accept
60port. The port is represented as a string of the form "host:port",
61where "host" is the interface to use and "port" is the port.
62Either or both values can be "*" which is interpreted as meaning
63any interface or port respectively. "port" has the same syntax
64as the port specified in BIO_set_conn_port() for connect BIOs,
65that is it can be a numerical port string or a string to lookup
66using getservbyname() and a string table.
67
68BIO_new_accept() combines BIO_new() and BIO_set_accept_port() into
69a single call: that is it creates a new accept BIO with port
70B<host_port>.
71
72BIO_set_nbio_accept() sets the accept socket to blocking mode
73(the default) if B<n> is 0 or non blocking mode if B<n> is 1.
74
75BIO_set_accept_bios() can be used to set a chain of BIOs which
76will be duplicated and prepended to the chain when an incoming
77connection is received. This is useful if, for example, a
78buffering or SSL BIO is required for each connection. The
79chain of BIOs must not be freed after this call, they will
80be automatically freed when the accept BIO is freed.
81
82BIO_set_bind_mode() and BIO_get_bind_mode() set and retrieve
83the current bind mode. If BIO_BIND_NORMAL (the default) is set
84then another socket cannot be bound to the same port. If
85BIO_BIND_REUSEADDR is set then other sockets can bind to the
86same port. If BIO_BIND_REUSEADDR_IF_UNUSED is set then and
87attempt is first made to use BIO_BIN_NORMAL, if this fails
88and the port is not in use then a second attempt is made
89using BIO_BIND_REUSEADDR.
90
91BIO_do_accept() serves two functions. When it is first
92called, after the accept BIO has been setup, it will attempt
93to create the accept socket and bind an address to it. Second
94and subsequent calls to BIO_do_accept() will await an incoming
95connection, or request a retry in non blocking mode.
96
97=head1 NOTES
98
99When an accept BIO is at the end of a chain it will await an
100incoming connection before processing I/O calls. When an accept
101BIO is not at then end of a chain it passes I/O calls to the next
102BIO in the chain.
103
104When a connection is established a new socket BIO is created for
105the connection and appended to the chain. That is the chain is now
106accept->socket. This effectively means that attempting I/O on
107an initial accept socket will await an incoming connection then
108perform I/O on it.
109
110If any additional BIOs have been set using BIO_set_accept_bios()
111then they are placed between the socket and the accept BIO,
112that is the chain will be accept->otherbios->socket.
113
114If a server wishes to process multiple connections (as is normally
115the case) then the accept BIO must be made available for further
116incoming connections. This can be done by waiting for a connection and
117then calling:
118
119 connection = BIO_pop(accept);
120
121After this call B<connection> will contain a BIO for the recently
122established connection and B<accept> will now be a single BIO
123again which can be used to await further incoming connections.
124If no further connections will be accepted the B<accept> can
125be freed using BIO_free().
126
127If only a single connection will be processed it is possible to
128perform I/O using the accept BIO itself. This is often undesirable
129however because the accept BIO will still accept additional incoming
130connections. This can be resolved by using BIO_pop() (see above)
131and freeing up the accept BIO after the initial connection.
132
133If the underlying accept socket is non-blocking and BIO_do_accept() is
134called to await an incoming connection it is possible for
135BIO_should_io_special() with the reason BIO_RR_ACCEPT. If this happens
136then it is an indication that an accept attempt would block: the application
137should take appropriate action to wait until the underlying socket has
138accepted a connection and retry the call.
139
140BIO_set_accept_port(), BIO_get_accept_port(), BIO_set_nbio_accept(),
141BIO_set_accept_bios(), BIO_set_bind_mode(), BIO_get_bind_mode() and
142BIO_do_accept() are macros.
143
144=head1 EXAMPLE
145
146This example accepts two connections on port 4444, sends messages
147down each and finally closes both down.
148
149 BIO *abio, *cbio, *cbio2;
150 ERR_load_crypto_strings();
151 abio = BIO_new_accept("4444");
152
153 /* First call to BIO_accept() sets up accept BIO */
154 if (BIO_do_accept(abio) <= 0) {
155 fprintf(stderr, "Error setting up accept\n");
156 ERR_print_errors_fp(stderr);
157 exit(0);
158 }
159
160 /* Wait for incoming connection */
161 if (BIO_do_accept(abio) <= 0) {
162 fprintf(stderr, "Error accepting connection\n");
163 ERR_print_errors_fp(stderr);
164 exit(0);
165 }
166 fprintf(stderr, "Connection 1 established\n");
167 /* Retrieve BIO for connection */
168 cbio = BIO_pop(abio);
169 BIO_puts(cbio, "Connection 1: Sending out Data on initial connection\n");
170 fprintf(stderr, "Sent out data on connection 1\n");
171 /* Wait for another connection */
172 if (BIO_do_accept(abio) <= 0) {
173 fprintf(stderr, "Error accepting connection\n");
174 ERR_print_errors_fp(stderr);
175 exit(0);
176 }
177 fprintf(stderr, "Connection 2 established\n");
178 /* Close accept BIO to refuse further connections */
179 cbio2 = BIO_pop(abio);
180 BIO_free(abio);
181 BIO_puts(cbio2, "Connection 2: Sending out Data on second\n");
182 fprintf(stderr, "Sent out data on connection 2\n");
183
184 BIO_puts(cbio, "Connection 1: Second connection established\n");
185 /* Close the two established connections */
186 BIO_free(cbio);
187 BIO_free(cbio2);
188
189=cut
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_bio.pod b/src/lib/libssl/src/doc/crypto/BIO_s_bio.pod
deleted file mode 100644
index 61ded32a02..0000000000
--- a/src/lib/libssl/src/doc/crypto/BIO_s_bio.pod
+++ /dev/null
@@ -1,185 +0,0 @@
1=pod
2
3=head1 NAME
4
5BIO_s_bio, BIO_make_bio_pair, BIO_destroy_bio_pair, BIO_shutdown_wr,
6BIO_set_write_buf_size, BIO_get_write_buf_size, BIO_new_bio_pair,
7BIO_get_write_guarantee, BIO_ctrl_get_write_guarantee, BIO_get_read_request,
8BIO_ctrl_get_read_request, BIO_ctrl_reset_read_request - BIO pair BIO
9
10=head1 SYNOPSIS
11
12 #include <openssl/bio.h>
13
14 BIO_METHOD *BIO_s_bio(void);
15
16 #define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
17 #define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
18
19 #define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
20
21 #define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
22 #define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
23
24 int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, BIO **bio2, size_t writebuf2);
25
26 #define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
27 size_t BIO_ctrl_get_write_guarantee(BIO *b);
28
29 #define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
30 size_t BIO_ctrl_get_read_request(BIO *b);
31
32 int BIO_ctrl_reset_read_request(BIO *b);
33
34=head1 DESCRIPTION
35
36BIO_s_bio() returns the method for a BIO pair. A BIO pair is a pair of
37source/sink BIOs where data written to either half of the pair is buffered and
38can be read from the other half. Both halves must usually by handled by the
39same application thread since no locking is done on the internal data
40structures.
41
42Since BIO chains typically end in a source/sink BIO it is possible to make this
43one half of a BIO pair and have all the data processed by the chain under
44application control.
45
46One typical use of BIO pairs is to place TLS/SSL I/O under application control,
47this can be used when the application wishes to use a non standard transport
48for TLS/SSL or the normal socket routines are inappropriate.
49
50Calls to BIO_read() will read data from the buffer or request a retry if no
51data is available.
52
53Calls to BIO_write() will place data in the buffer or request a retry if the
54buffer is full.
55
56The standard calls BIO_ctrl_pending() and BIO_ctrl_wpending() can be used to
57determine the amount of pending data in the read or write buffer.
58
59BIO_reset() clears any data in the write buffer.
60
61BIO_make_bio_pair() joins two separate BIOs into a connected pair.
62
63BIO_destroy_pair() destroys the association between two connected BIOs. Freeing
64up any half of the pair will automatically destroy the association.
65
66BIO_shutdown_wr() is used to close down a BIO B<b>. After this call no further
67writes on BIO B<b> are allowed (they will return an error). Reads on the other
68half of the pair will return any pending data or EOF when all pending data has
69been read.
70
71BIO_set_write_buf_size() sets the write buffer size of BIO B<b> to B<size>.
72If the size is not initialized a default value is used. This is currently
7317K, sufficient for a maximum size TLS record.
74
75BIO_get_write_buf_size() returns the size of the write buffer.
76
77BIO_new_bio_pair() combines the calls to BIO_new(), BIO_make_bio_pair() and
78BIO_set_write_buf_size() to create a connected pair of BIOs B<bio1>, B<bio2>
79with write buffer sizes B<writebuf1> and B<writebuf2>. If either size is
80zero then the default size is used. BIO_new_bio_pair() does not check whether
81B<bio1> or B<bio2> do point to some other BIO, the values are overwritten,
82BIO_free() is not called.
83
84BIO_get_write_guarantee() and BIO_ctrl_get_write_guarantee() return the maximum
85length of data that can be currently written to the BIO. Writes larger than
86this value will return a value from BIO_write() less than the amount requested
87or if the buffer is full request a retry. BIO_ctrl_get_write_guarantee() is a
88function whereas BIO_get_write_guarantee() is a macro.
89
90BIO_get_read_request() and BIO_ctrl_get_read_request() return the
91amount of data requested, or the buffer size if it is less, if the
92last read attempt at the other half of the BIO pair failed due to an
93empty buffer. This can be used to determine how much data should be
94written to the BIO so the next read will succeed: this is most useful
95in TLS/SSL applications where the amount of data read is usually
96meaningful rather than just a buffer size. After a successful read
97this call will return zero. It also will return zero once new data
98has been written satisfying the read request or part of it.
99Note that BIO_get_read_request() never returns an amount larger
100than that returned by BIO_get_write_guarantee().
101
102BIO_ctrl_reset_read_request() can also be used to reset the value returned by
103BIO_get_read_request() to zero.
104
105=head1 NOTES
106
107Both halves of a BIO pair should be freed. That is even if one half is implicit
108freed due to a BIO_free_all() or SSL_free() call the other half needs to be
109freed.
110
111When used in bidirectional applications (such as TLS/SSL) care should be taken
112to flush any data in the write buffer. This can be done by calling
113BIO_pending() on the other half of the pair and, if any data is pending,
114reading it and sending it to the underlying transport. This must be done before
115any normal processing (such as calling select() ) due to a request and
116BIO_should_read() being true.
117
118To see why this is important consider a case where a request is sent using
119BIO_write() and a response read with BIO_read(), this can occur during an
120TLS/SSL handshake for example. BIO_write() will succeed and place data in the
121write buffer. BIO_read() will initially fail and BIO_should_read() will be
122true. If the application then waits for data to be available on the underlying
123transport before flushing the write buffer it will never succeed because the
124request was never sent!
125
126=head1 RETURN VALUES
127
128BIO_new_bio_pair() returns 1 on success, with the new BIOs available in
129B<bio1> and B<bio2>, or 0 on failure, with NULL pointers stored into the
130locations for B<bio1> and B<bio2>. Check the error stack for more information.
131
132[TODO: More return values need to be added here]
133
134=head1 EXAMPLE
135
136The BIO pair can be used to have full control over the network access of an
137application. The application can call select() on the socket as required
138without having to go through the SSL-interface.
139
140 BIO *internal_bio, *network_bio;
141 ...
142 BIO_new_bio_pair(internal_bio, 0, network_bio, 0);
143 SSL_set_bio(ssl, internal_bio, internal_bio);
144 SSL_operations();
145 ...
146
147 application | TLS-engine
148 | |
149 +----------> SSL_operations()
150 | /\ ||
151 | || \/
152 | BIO-pair (internal_bio)
153 +----------< BIO-pair (network_bio)
154 | |
155 socket |
156
157 ...
158 SSL_free(ssl); /* implicitly frees internal_bio */
159 BIO_free(network_bio);
160 ...
161
162As the BIO pair will only buffer the data and never directly access the
163connection, it behaves non-blocking and will return as soon as the write
164buffer is full or the read buffer is drained. Then the application has to
165flush the write buffer and/or fill the read buffer.
166
167Use the BIO_ctrl_pending(), to find out whether data is buffered in the BIO
168and must be transfered to the network. Use BIO_ctrl_get_read_request() to
169find out, how many bytes must be written into the buffer before the
170SSL_operation() can successfully be continued.
171
172=head1 WARNING
173
174As the data is buffered, SSL_operation() may return with a ERROR_SSL_WANT_READ
175condition, but there is still data in the write buffer. An application must
176not rely on the error value of SSL_operation() but must assure that the
177write buffer is always flushed first. Otherwise a deadlock may occur as
178the peer might be waiting for the data before being able to continue.
179
180=head1 SEE ALSO
181
182L<SSL_set_bio(3)|SSL_set_bio(3)>, L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>,
183L<BIO_should_retry(3)|BIO_should_retry(3)>, L<BIO_read(3)|BIO_read(3)>
184
185=cut
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_connect.pod b/src/lib/libssl/src/doc/crypto/BIO_s_connect.pod
deleted file mode 100644
index 45832e52f3..0000000000
--- a/src/lib/libssl/src/doc/crypto/BIO_s_connect.pod
+++ /dev/null
@@ -1,191 +0,0 @@
1=pod
2
3=head1 NAME
4
5BIO_s_connect, BIO_new_connect, BIO_set_conn_hostname, BIO_set_conn_port,
6BIO_set_conn_ip, BIO_set_conn_int_port, BIO_get_conn_hostname,
7BIO_get_conn_port, BIO_get_conn_ip, BIO_get_conn_int_port,
8BIO_set_nbio, BIO_do_connect - connect BIO
9
10=head1 SYNOPSIS
11
12 #include <openssl/bio.h>
13
14 BIO_METHOD * BIO_s_connect(void);
15
16 BIO *BIO_new_connect(char *name);
17
18 long BIO_set_conn_hostname(BIO *b, char *name);
19 long BIO_set_conn_port(BIO *b, char *port);
20 long BIO_set_conn_ip(BIO *b, char *ip);
21 long BIO_set_conn_int_port(BIO *b, char *port);
22 char *BIO_get_conn_hostname(BIO *b);
23 char *BIO_get_conn_port(BIO *b);
24 char *BIO_get_conn_ip(BIO *b, dummy);
25 long BIO_get_conn_int_port(BIO *b, int port);
26
27 long BIO_set_nbio(BIO *b, long n);
28
29 int BIO_do_connect(BIO *b);
30
31=head1 DESCRIPTION
32
33BIO_s_connect() returns the connect BIO method. This is a wrapper
34round the platform's TCP/IP socket connection routines.
35
36Using connect BIOs, TCP/IP connections can be made and data
37transferred using only BIO routines. In this way any platform
38specific operations are hidden by the BIO abstraction.
39
40Read and write operations on a connect BIO will perform I/O
41on the underlying connection. If no connection is established
42and the port and hostname (see below) is set up properly then
43a connection is established first.
44
45Connect BIOs support BIO_puts() but not BIO_gets().
46
47If the close flag is set on a connect BIO then any active
48connection is shutdown and the socket closed when the BIO
49is freed.
50
51Calling BIO_reset() on a connect BIO will close any active
52connection and reset the BIO into a state where it can connect
53to the same host again.
54
55BIO_get_fd() places the underlying socket in B<c> if it is not NULL,
56it also returns the socket . If B<c> is not NULL it should be of
57type (int *).
58
59BIO_set_conn_hostname() uses the string B<name> to set the hostname.
60The hostname can be an IP address. The hostname can also include the
61port in the form hostname:port . It is also acceptable to use the
62form "hostname/any/other/path" or "hostname:port/any/other/path".
63
64BIO_set_conn_port() sets the port to B<port>. B<port> can be the
65numerical form or a string such as "http". A string will be looked
66up first using getservbyname() on the host platform but if that
67fails a standard table of port names will be used. Currently the
68list is http, telnet, socks, https, ssl, ftp, gopher and wais.
69
70BIO_set_conn_ip() sets the IP address to B<ip> using binary form,
71that is four bytes specifying the IP address in big-endian form.
72
73BIO_set_conn_int_port() sets the port using B<port>. B<port> should
74be of type (int *).
75
76BIO_get_conn_hostname() returns the hostname of the connect BIO or
77NULL if the BIO is initialized but no hostname is set.
78This return value is an internal pointer which should not be modified.
79
80BIO_get_conn_port() returns the port as a string.
81
82BIO_get_conn_ip() returns the IP address in binary form.
83
84BIO_get_conn_int_port() returns the port as an int.
85
86BIO_set_nbio() sets the non blocking I/O flag to B<n>. If B<n> is
87zero then blocking I/O is set. If B<n> is 1 then non blocking I/O
88is set. Blocking I/O is the default. The call to BIO_set_nbio()
89should be made before the connection is established because
90non blocking I/O is set during the connect process.
91
92BIO_new_connect() combines BIO_new() and BIO_set_conn_hostname() into
93a single call: that is it creates a new connect BIO with B<name>.
94
95BIO_do_connect() attempts to connect the supplied BIO. It returns 1
96if the connection was established successfully. A zero or negative
97value is returned if the connection could not be established, the
98call BIO_should_retry() should be used for non blocking connect BIOs
99to determine if the call should be retried.
100
101=head1 NOTES
102
103If blocking I/O is set then a non positive return value from any
104I/O call is caused by an error condition, although a zero return
105will normally mean that the connection was closed.
106
107If the port name is supplied as part of the host name then this will
108override any value set with BIO_set_conn_port(). This may be undesirable
109if the application does not wish to allow connection to arbitrary
110ports. This can be avoided by checking for the presence of the ':'
111character in the passed hostname and either indicating an error or
112truncating the string at that point.
113
114The values returned by BIO_get_conn_hostname(), BIO_get_conn_port(),
115BIO_get_conn_ip() and BIO_get_conn_int_port() are updated when a
116connection attempt is made. Before any connection attempt the values
117returned are those set by the application itself.
118
119Applications do not have to call BIO_do_connect() but may wish to do
120so to separate the connection process from other I/O processing.
121
122If non blocking I/O is set then retries will be requested as appropriate.
123
124It addition to BIO_should_read() and BIO_should_write() it is also
125possible for BIO_should_io_special() to be true during the initial
126connection process with the reason BIO_RR_CONNECT. If this is returned
127then this is an indication that a connection attempt would block,
128the application should then take appropriate action to wait until
129the underlying socket has connected and retry the call.
130
131BIO_set_conn_hostname(), BIO_set_conn_port(), BIO_set_conn_ip(),
132BIO_set_conn_int_port(), BIO_get_conn_hostname(), BIO_get_conn_port(),
133BIO_get_conn_ip(), BIO_get_conn_int_port(), BIO_set_nbio() and
134BIO_do_connect() are macros.
135
136=head1 RETURN VALUES
137
138BIO_s_connect() returns the connect BIO method.
139
140BIO_get_fd() returns the socket or -1 if the BIO has not
141been initialized.
142
143BIO_set_conn_hostname(), BIO_set_conn_port(), BIO_set_conn_ip() and
144BIO_set_conn_int_port() always return 1.
145
146BIO_get_conn_hostname() returns the connected hostname or NULL is
147none was set.
148
149BIO_get_conn_port() returns a string representing the connected
150port or NULL if not set.
151
152BIO_get_conn_ip() returns a pointer to the connected IP address in
153binary form or all zeros if not set.
154
155BIO_get_conn_int_port() returns the connected port or 0 if none was
156set.
157
158BIO_set_nbio() always returns 1.
159
160BIO_do_connect() returns 1 if the connection was successfully
161established and 0 or -1 if the connection failed.
162
163=head1 EXAMPLE
164
165This is example connects to a webserver on the local host and attempts
166to retrieve a page and copy the result to standard output.
167
168
169 BIO *cbio, *out;
170 int len;
171 char tmpbuf[1024];
172
173 ERR_load_crypto_strings();
174 cbio = BIO_new_connect("localhost:http");
175 out = BIO_new_fp(stdout, BIO_NOCLOSE);
176 if (BIO_do_connect(cbio) <= 0) {
177 fprintf(stderr, "Error connecting to server\n");
178 ERR_print_errors_fp(stderr);
179 /* whatever ... */
180 }
181 BIO_puts(cbio, "GET / HTTP/1.0\n\n");
182 for(;;) {
183 len = BIO_read(cbio, tmpbuf, 1024);
184 if (len <= 0)
185 break;
186 BIO_write(out, tmpbuf, len);
187 }
188 BIO_free(cbio);
189 BIO_free(out);
190
191=cut
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_fd.pod b/src/lib/libssl/src/doc/crypto/BIO_s_fd.pod
deleted file mode 100644
index 22b7575ba0..0000000000
--- a/src/lib/libssl/src/doc/crypto/BIO_s_fd.pod
+++ /dev/null
@@ -1,91 +0,0 @@
1=pod
2
3=head1 NAME
4
5BIO_s_fd, BIO_set_fd, BIO_get_fd, BIO_new_fd - file descriptor BIO
6
7=head1 SYNOPSIS
8
9 #include <openssl/bio.h>
10
11 BIO_METHOD * BIO_s_fd(void);
12
13 #define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
14 #define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)
15
16 BIO *BIO_new_fd(int fd, int close_flag);
17
18=head1 DESCRIPTION
19
20BIO_s_fd() returns the file descriptor BIO method. This is a wrapper
21round the platforms file descriptor routines such as read() and write().
22
23BIO_read() and BIO_write() read or write the underlying descriptor.
24BIO_puts() is supported but BIO_gets() is not.
25
26If the close flag is set then then close() is called on the underlying
27file descriptor when the BIO is freed.
28
29BIO_reset() attempts to change the file pointer to the start of file
30using lseek(fd, 0, 0).
31
32BIO_seek() sets the file pointer to position B<ofs> from start of file
33using lseek(fd, ofs, 0).
34
35BIO_tell() returns the current file position by calling lseek(fd, 0, 1).
36
37BIO_set_fd() sets the file descriptor of BIO B<b> to B<fd> and the close
38flag to B<c>.
39
40BIO_get_fd() places the file descriptor in B<c> if it is not NULL, it also
41returns the file descriptor. If B<c> is not NULL it should be of type
42(int *).
43
44BIO_new_fd() returns a file descriptor BIO using B<fd> and B<close_flag>.
45
46=head1 NOTES
47
48The behaviour of BIO_read() and BIO_write() depends on the behavior of the
49platforms read() and write() calls on the descriptor. If the underlying file
50descriptor is in a non blocking mode then the BIO will behave in the manner
51described in the L<BIO_read(3)|BIO_read(3)> and
52L<BIO_should_retry(3)|BIO_should_retry(3)> manual pages.
53
54File descriptor BIOs should not be used for socket I/O. Use socket BIOs
55instead.
56
57=head1 RETURN VALUES
58
59BIO_s_fd() returns the file descriptor BIO method.
60
61BIO_reset() returns zero for success and -1 if an error occurred.
62BIO_seek() and BIO_tell() return the current file position or -1
63is an error occurred. These values reflect the underlying lseek()
64behaviour.
65
66BIO_set_fd() always returns 1.
67
68BIO_get_fd() returns the file descriptor or -1 if the BIO has not
69been initialized.
70
71BIO_new_fd() returns the newly allocated BIO or NULL is an error
72occurred.
73
74=head1 EXAMPLE
75
76This is a file descriptor BIO version of "Hello World":
77
78 BIO *out;
79 out = BIO_new_fd(fileno(stdout), BIO_NOCLOSE);
80 BIO_printf(out, "Hello World\n");
81 BIO_free(out);
82
83=head1 SEE ALSO
84
85L<BIO_seek(3)|BIO_seek(3)>, L<BIO_tell(3)|BIO_tell(3)>,
86L<BIO_reset(3)|BIO_reset(3)>, L<BIO_read(3)|BIO_read(3)>,
87L<BIO_write(3)|BIO_write(3)>, L<BIO_puts(3)|BIO_puts(3)>,
88L<BIO_gets(3)|BIO_gets(3)>, L<BIO_printf(3)|BIO_printf(3)>,
89L<BIO_set_close(3)|BIO_set_close(3)>, L<BIO_get_close(3)|BIO_get_close(3)>
90
91=cut
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_file.pod b/src/lib/libssl/src/doc/crypto/BIO_s_file.pod
deleted file mode 100644
index 0c9cb824da..0000000000
--- a/src/lib/libssl/src/doc/crypto/BIO_s_file.pod
+++ /dev/null
@@ -1,150 +0,0 @@
1=pod
2
3=head1 NAME
4
5BIO_s_file, BIO_new_file, BIO_new_fp, BIO_set_fp, BIO_get_fp,
6BIO_read_filename, BIO_write_filename, BIO_append_filename,
7BIO_rw_filename - FILE bio
8
9=head1 SYNOPSIS
10
11 #include <openssl/bio.h>
12
13 BIO_METHOD * BIO_s_file(void);
14 BIO *BIO_new_file(const char *filename, const char *mode);
15 BIO *BIO_new_fp(FILE *stream, int flags);
16
17 BIO_set_fp(BIO *b,FILE *fp, int flags);
18 BIO_get_fp(BIO *b,FILE **fpp);
19
20 int BIO_read_filename(BIO *b, char *name)
21 int BIO_write_filename(BIO *b, char *name)
22 int BIO_append_filename(BIO *b, char *name)
23 int BIO_rw_filename(BIO *b, char *name)
24
25=head1 DESCRIPTION
26
27BIO_s_file() returns the BIO file method. As its name implies it
28is a wrapper round the stdio FILE structure and it is a
29source/sink BIO.
30
31Calls to BIO_read() and BIO_write() read and write data to the
32underlying stream. BIO_gets() and BIO_puts() are supported on file BIOs.
33
34BIO_flush() on a file BIO calls the fflush() function on the wrapped
35stream.
36
37BIO_reset() attempts to change the file pointer to the start of file
38using fseek(stream, 0, 0).
39
40BIO_seek() sets the file pointer to position B<ofs> from start of file
41using fseek(stream, ofs, 0).
42
43BIO_eof() calls feof().
44
45Setting the BIO_CLOSE flag calls fclose() on the stream when the BIO
46is freed.
47
48BIO_new_file() creates a new file BIO with mode B<mode> the meaning
49of B<mode> is the same as the stdio function fopen(). The BIO_CLOSE
50flag is set on the returned BIO.
51
52BIO_new_fp() creates a file BIO wrapping B<stream>. Flags can be:
53BIO_CLOSE, BIO_NOCLOSE (the close flag) BIO_FP_TEXT (sets the underlying
54stream to text mode, default is binary: this only has any effect under
55Win32).
56
57BIO_set_fp() set the fp of a file BIO to B<fp>. B<flags> has the same
58meaning as in BIO_new_fp(), it is a macro.
59
60BIO_get_fp() retrieves the fp of a file BIO, it is a macro.
61
62BIO_seek() is a macro that sets the position pointer to B<offset> bytes
63from the start of file.
64
65BIO_tell() returns the value of the position pointer.
66
67BIO_read_filename(), BIO_write_filename(), BIO_append_filename() and
68BIO_rw_filename() set the file BIO B<b> to use file B<name> for
69reading, writing, append or read write respectively.
70
71=head1 NOTES
72
73When wrapping stdout, stdin or stderr the underlying stream should not
74normally be closed so the BIO_NOCLOSE flag should be set.
75
76Because the file BIO calls the underlying stdio functions any quirks
77in stdio behaviour will be mirrored by the corresponding BIO.
78
79On Windows BIO_new_files reserves for the filename argument to be
80UTF-8 encoded. In other words if you have to make it work in multi-
81lingual environment, encode file names in UTF-8.
82
83=head1 EXAMPLES
84
85File BIO "hello world":
86
87 BIO *bio_out;
88 bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
89 BIO_printf(bio_out, "Hello World\n");
90
91Alternative technique:
92
93 BIO *bio_out;
94 bio_out = BIO_new(BIO_s_file());
95 if(bio_out == NULL) /* Error ... */
96 if(!BIO_set_fp(bio_out, stdout, BIO_NOCLOSE)) /* Error ... */
97 BIO_printf(bio_out, "Hello World\n");
98
99Write to a file:
100
101 BIO *out;
102 out = BIO_new_file("filename.txt", "w");
103 if(!out) /* Error occurred */
104 BIO_printf(out, "Hello World\n");
105 BIO_free(out);
106
107Alternative technique:
108
109 BIO *out;
110 out = BIO_new(BIO_s_file());
111 if(out == NULL) /* Error ... */
112 if(!BIO_write_filename(out, "filename.txt")) /* Error ... */
113 BIO_printf(out, "Hello World\n");
114 BIO_free(out);
115
116=head1 RETURN VALUES
117
118BIO_s_file() returns the file BIO method.
119
120BIO_new_file() and BIO_new_fp() return a file BIO or NULL if an error
121occurred.
122
123BIO_set_fp() and BIO_get_fp() return 1 for success or 0 for failure
124(although the current implementation never return 0).
125
126BIO_seek() returns the same value as the underlying fseek() function:
1270 for success or -1 for failure.
128
129BIO_tell() returns the current file position.
130
131BIO_read_filename(), BIO_write_filename(), BIO_append_filename() and
132BIO_rw_filename() return 1 for success or 0 for failure.
133
134=head1 BUGS
135
136BIO_reset() and BIO_seek() are implemented using fseek() on the underlying
137stream. The return value for fseek() is 0 for success or -1 if an error
138occurred this differs from other types of BIO which will typically return
1391 for success and a non positive value if an error occurred.
140
141=head1 SEE ALSO
142
143L<BIO_seek(3)|BIO_seek(3)>, L<BIO_tell(3)|BIO_tell(3)>,
144L<BIO_reset(3)|BIO_reset(3)>, L<BIO_flush(3)|BIO_flush(3)>,
145L<BIO_read(3)|BIO_read(3)>,
146L<BIO_write(3)|BIO_write(3)>, L<BIO_puts(3)|BIO_puts(3)>,
147L<BIO_gets(3)|BIO_gets(3)>, L<BIO_printf(3)|BIO_printf(3)>,
148L<BIO_set_close(3)|BIO_set_close(3)>, L<BIO_get_close(3)|BIO_get_close(3)>
149
150=cut
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_mem.pod b/src/lib/libssl/src/doc/crypto/BIO_s_mem.pod
deleted file mode 100644
index 4541b3fc55..0000000000
--- a/src/lib/libssl/src/doc/crypto/BIO_s_mem.pod
+++ /dev/null
@@ -1,112 +0,0 @@
1=pod
2
3=head1 NAME
4
5BIO_s_mem, BIO_set_mem_eof_return, BIO_get_mem_data, BIO_set_mem_buf,
6BIO_get_mem_ptr, BIO_new_mem_buf - memory BIO
7
8=head1 SYNOPSIS
9
10 #include <openssl/bio.h>
11
12 BIO_METHOD * BIO_s_mem(void);
13
14 BIO_set_mem_eof_return(BIO *b,int v)
15 long BIO_get_mem_data(BIO *b, char **pp)
16 BIO_set_mem_buf(BIO *b,BUF_MEM *bm,int c)
17 BIO_get_mem_ptr(BIO *b,BUF_MEM **pp)
18
19 BIO *BIO_new_mem_buf(void *buf, int len);
20
21=head1 DESCRIPTION
22
23BIO_s_mem() return the memory BIO method function.
24
25A memory BIO is a source/sink BIO which uses memory for its I/O. Data
26written to a memory BIO is stored in a BUF_MEM structure which is extended
27as appropriate to accommodate the stored data.
28
29Any data written to a memory BIO can be recalled by reading from it.
30Unless the memory BIO is read only any data read from it is deleted from
31the BIO.
32
33Memory BIOs support BIO_gets() and BIO_puts().
34
35If the BIO_CLOSE flag is set when a memory BIO is freed then the underlying
36BUF_MEM structure is also freed.
37
38Calling BIO_reset() on a read write memory BIO clears any data in it. On a
39read only BIO it restores the BIO to its original state and the read only
40data can be read again.
41
42BIO_eof() is true if no data is in the BIO.
43
44BIO_ctrl_pending() returns the number of bytes currently stored.
45
46BIO_set_mem_eof_return() sets the behaviour of memory BIO B<b> when it is
47empty. If the B<v> is zero then an empty memory BIO will return EOF (that is
48it will return zero and BIO_should_retry(b) will be false. If B<v> is non
49zero then it will return B<v> when it is empty and it will set the read retry
50flag (that is BIO_read_retry(b) is true). To avoid ambiguity with a normal
51positive return value B<v> should be set to a negative value, typically -1.
52
53BIO_get_mem_data() sets B<pp> to a pointer to the start of the memory BIOs data
54and returns the total amount of data available. It is implemented as a macro.
55
56BIO_set_mem_buf() sets the internal BUF_MEM structure to B<bm> and sets the
57close flag to B<c>, that is B<c> should be either BIO_CLOSE or BIO_NOCLOSE.
58It is a macro.
59
60BIO_get_mem_ptr() places the underlying BUF_MEM structure in B<pp>. It is
61a macro.
62
63BIO_new_mem_buf() creates a memory BIO using B<len> bytes of data at B<buf>,
64if B<len> is -1 then the B<buf> is assumed to be null terminated and its
65length is determined by B<strlen>. The BIO is set to a read only state and
66as a result cannot be written to. This is useful when some data needs to be
67made available from a static area of memory in the form of a BIO. The
68supplied data is read directly from the supplied buffer: it is B<not> copied
69first, so the supplied area of memory must be unchanged until the BIO is freed.
70
71=head1 NOTES
72
73Writes to memory BIOs will always succeed if memory is available: that is
74their size can grow indefinitely.
75
76Every read from a read write memory BIO will remove the data just read with
77an internal copy operation, if a BIO contains a lot of data and it is
78read in small chunks the operation can be very slow. The use of a read only
79memory BIO avoids this problem. If the BIO must be read write then adding
80a buffering BIO to the chain will speed up the process.
81
82=head1 BUGS
83
84There should be an option to set the maximum size of a memory BIO.
85
86There should be a way to "rewind" a read write BIO without destroying
87its contents.
88
89The copying operation should not occur after every small read of a large BIO
90to improve efficiency.
91
92=head1 EXAMPLE
93
94Create a memory BIO and write some data to it:
95
96 BIO *mem = BIO_new(BIO_s_mem());
97 BIO_puts(mem, "Hello World\n");
98
99Create a read only memory BIO:
100
101 char data[] = "Hello World";
102 BIO *mem;
103 mem = BIO_new_mem_buf(data, -1);
104
105Extract the BUF_MEM structure from a memory BIO and then free up the BIO:
106
107 BUF_MEM *bptr;
108 BIO_get_mem_ptr(mem, &bptr);
109 BIO_set_close(mem, BIO_NOCLOSE); /* So BIO_free() leaves BUF_MEM alone */
110 BIO_free(mem);
111
112=cut
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_null.pod b/src/lib/libssl/src/doc/crypto/BIO_s_null.pod
deleted file mode 100644
index 9f7d4ac46a..0000000000
--- a/src/lib/libssl/src/doc/crypto/BIO_s_null.pod
+++ /dev/null
@@ -1,35 +0,0 @@
1=pod
2
3=head1 NAME
4
5BIO_s_null - null data sink
6
7=head1 SYNOPSIS
8
9 #include <openssl/bio.h>
10
11 BIO_METHOD * BIO_s_null(void);
12
13=head1 DESCRIPTION
14
15BIO_s_null() returns the null sink BIO method. Data written to
16the null sink is discarded, reads return EOF.
17
18=head1 NOTES
19
20A null sink BIO behaves in a similar manner to the Unix /dev/null
21device.
22
23A null bio can be placed on the end of a chain to discard any data
24passed through it.
25
26A null sink is useful if, for example, an application wishes to digest some
27data by writing through a digest bio but not send the digested data anywhere.
28Since a BIO chain must normally include a source/sink BIO this can be achieved
29by adding a null sink BIO to the end of the chain
30
31=head1 RETURN VALUES
32
33BIO_s_null() returns the null sink BIO method.
34
35=cut
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_socket.pod b/src/lib/libssl/src/doc/crypto/BIO_s_socket.pod
deleted file mode 100644
index 402aff26e2..0000000000
--- a/src/lib/libssl/src/doc/crypto/BIO_s_socket.pod
+++ /dev/null
@@ -1,61 +0,0 @@
1=pod
2
3=head1 NAME
4
5BIO_s_socket, BIO_new_socket - socket BIO
6
7=head1 SYNOPSIS
8
9 #include <openssl/bio.h>
10
11 BIO_METHOD *BIO_s_socket(void);
12
13 long BIO_set_fd(BIO *b, int fd, long close_flag);
14 long BIO_get_fd(BIO *b, int *c);
15
16 BIO *BIO_new_socket(int sock, int close_flag);
17
18=head1 DESCRIPTION
19
20BIO_s_socket() returns the socket BIO method. This is a wrapper
21round the platform's socket routines.
22
23BIO_read() and BIO_write() read or write the underlying socket.
24BIO_puts() is supported but BIO_gets() is not.
25
26If the close flag is set then the socket is shut down and closed
27when the BIO is freed.
28
29BIO_set_fd() sets the socket of BIO B<b> to B<fd> and the close
30flag to B<close_flag>.
31
32BIO_get_fd() places the socket in B<c> if it is not NULL, it also
33returns the socket. If B<c> is not NULL it should be of type (int *).
34
35BIO_new_socket() returns a socket BIO using B<sock> and B<close_flag>.
36
37=head1 NOTES
38
39Socket BIOs also support any relevant functionality of file descriptor
40BIOs.
41
42The reason for having separate file descriptor and socket BIOs is that on some
43platforms sockets are not file descriptors and use distinct I/O routines,
44Windows is one such platform. Any code mixing the two will not work on
45all platforms.
46
47BIO_set_fd() and BIO_get_fd() are macros.
48
49=head1 RETURN VALUES
50
51BIO_s_socket() returns the socket BIO method.
52
53BIO_set_fd() always returns 1.
54
55BIO_get_fd() returns the socket or -1 if the BIO has not been
56initialized.
57
58BIO_new_socket() returns the newly allocated BIO or NULL is an error
59occurred.
60
61=cut
diff --git a/src/lib/libssl/src/doc/crypto/BIO_set_callback.pod b/src/lib/libssl/src/doc/crypto/BIO_set_callback.pod
deleted file mode 100644
index 8e4e5900d9..0000000000
--- a/src/lib/libssl/src/doc/crypto/BIO_set_callback.pod
+++ /dev/null
@@ -1,105 +0,0 @@
1=pod
2
3=head1 NAME
4
5BIO_set_callback, BIO_get_callback, BIO_set_callback_arg, BIO_get_callback_arg,
6BIO_debug_callback - BIO callback functions
7
8=head1 SYNOPSIS
9
10 #include <openssl/bio.h>
11
12 #define BIO_set_callback(b,cb) ((b)->callback=(cb))
13 #define BIO_get_callback(b) ((b)->callback)
14 #define BIO_set_callback_arg(b,arg) ((b)->cb_arg=(char *)(arg))
15 #define BIO_get_callback_arg(b) ((b)->cb_arg)
16
17 long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
18 long argl,long ret);
19
20 typedef long (*callback)(BIO *b, int oper, const char *argp,
21 int argi, long argl, long retvalue);
22
23=head1 DESCRIPTION
24
25BIO_set_callback() and BIO_get_callback() set and retrieve the BIO callback,
26they are both macros. The callback is called during most high level BIO
27operations. It can be used for debugging purposes to trace operations on
28a BIO or to modify its operation.
29
30BIO_set_callback_arg() and BIO_get_callback_arg() are macros which can be
31used to set and retrieve an argument for use in the callback.
32
33BIO_debug_callback() is a standard debugging callback which prints
34out information relating to each BIO operation. If the callback
35argument is set if is interpreted as a BIO to send the information
36to, otherwise stderr is used.
37
38callback() is the callback function itself. The meaning of each
39argument is described below.
40
41The BIO the callback is attached to is passed in B<b>.
42
43B<oper> is set to the operation being performed. For some operations
44the callback is called twice, once before and once after the actual
45operation, the latter case has B<oper> or'ed with BIO_CB_RETURN.
46
47The meaning of the arguments B<argp>, B<argi> and B<argl> depends on
48the value of B<oper>, that is the operation being performed.
49
50B<retvalue> is the return value that would be returned to the
51application if no callback were present. The actual value returned
52is the return value of the callback itself. In the case of callbacks
53called before the actual BIO operation 1 is placed in retvalue, if
54the return value is not positive it will be immediately returned to
55the application and the BIO operation will not be performed.
56
57The callback should normally simply return B<retvalue> when it has
58finished processing, unless if specifically wishes to modify the
59value returned to the application.
60
61=head1 CALLBACK OPERATIONS
62
63=over 4
64
65=item B<BIO_free(b)>
66
67callback(b, BIO_CB_FREE, NULL, 0L, 0L, 1L) is called before the
68free operation.
69
70=item B<BIO_read(b, out, outl)>
71
72callback(b, BIO_CB_READ, out, outl, 0L, 1L) is called before
73the read and callback(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0L, retvalue)
74after.
75
76=item B<BIO_write(b, in, inl)>
77
78callback(b, BIO_CB_WRITE, in, inl, 0L, 1L) is called before
79the write and callback(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0L, retvalue)
80after.
81
82=item B<BIO_gets(b, out, outl)>
83
84callback(b, BIO_CB_GETS, out, outl, 0L, 1L) is called before the operation and
85callback(b, BIO_CB_GETS|BIO_CB_RETURN, out, outl, 0L, retvalue) after.
86
87=item B<BIO_puts(b, in)>
88
89callback(b, BIO_CB_WRITE, in, 0, 0L, 1L) is called before
90the operation and callback(b, BIO_CB_WRITE|BIO_CB_RETURN, in, 0, 0L, retvalue)
91after.
92
93=item B<BIO_ctrl(BIO *b, int cmd, long larg, void *parg)>
94
95callback(b,BIO_CB_CTRL,parg,cmd,larg,1L) is called before the call and
96callback(b,BIO_CB_CTRL|BIO_CB_RETURN,parg,cmd, larg,ret) after.
97
98=back
99
100=head1 EXAMPLE
101
102The BIO_debug_callback() function is a good example, its source is
103in crypto/bio/bio_cb.c
104
105=cut
diff --git a/src/lib/libssl/src/doc/crypto/BIO_should_retry.pod b/src/lib/libssl/src/doc/crypto/BIO_should_retry.pod
deleted file mode 100644
index 3b7fc39997..0000000000
--- a/src/lib/libssl/src/doc/crypto/BIO_should_retry.pod
+++ /dev/null
@@ -1,112 +0,0 @@
1=pod
2
3=head1 NAME
4
5BIO_should_retry, BIO_should_read, BIO_should_write,
6BIO_should_io_special, BIO_retry_type,
7BIO_get_retry_BIO, BIO_get_retry_reason - BIO retry functions
8
9=head1 SYNOPSIS
10
11 #include <openssl/bio.h>
12
13 #define BIO_should_read(a) ((a)->flags & BIO_FLAGS_READ)
14 #define BIO_should_write(a) ((a)->flags & BIO_FLAGS_WRITE)
15 #define BIO_should_io_special(a) ((a)->flags & BIO_FLAGS_IO_SPECIAL)
16 #define BIO_retry_type(a) ((a)->flags & BIO_FLAGS_RWS)
17 #define BIO_should_retry(a) ((a)->flags & BIO_FLAGS_SHOULD_RETRY)
18
19 #define BIO_FLAGS_READ 0x01
20 #define BIO_FLAGS_WRITE 0x02
21 #define BIO_FLAGS_IO_SPECIAL 0x04
22 #define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
23 #define BIO_FLAGS_SHOULD_RETRY 0x08
24
25 BIO * BIO_get_retry_BIO(BIO *bio, int *reason);
26 int BIO_get_retry_reason(BIO *bio);
27
28=head1 DESCRIPTION
29
30These functions determine why a BIO is not able to read or write data.
31They will typically be called after a failed BIO_read() or BIO_write()
32call.
33
34BIO_should_retry() is true if the call that produced this condition
35should then be retried at a later time.
36
37If BIO_should_retry() is false then the cause is an error condition.
38
39BIO_should_read() is true if the cause of the condition is that a BIO
40needs to read data.
41
42BIO_should_write() is true if the cause of the condition is that a BIO
43needs to read data.
44
45BIO_should_io_special() is true if some "special" condition, that is a
46reason other than reading or writing is the cause of the condition.
47
48BIO_retry_type() returns a mask of the cause of a retry condition
49consisting of the values B<BIO_FLAGS_READ>, B<BIO_FLAGS_WRITE>,
50B<BIO_FLAGS_IO_SPECIAL> though current BIO types will only set one of
51these.
52
53BIO_get_retry_BIO() determines the precise reason for the special
54condition, it returns the BIO that caused this condition and if
55B<reason> is not NULL it contains the reason code. The meaning of
56the reason code and the action that should be taken depends on
57the type of BIO that resulted in this condition.
58
59BIO_get_retry_reason() returns the reason for a special condition if
60passed the relevant BIO, for example as returned by BIO_get_retry_BIO().
61
62=head1 NOTES
63
64If BIO_should_retry() returns false then the precise "error condition"
65depends on the BIO type that caused it and the return code of the BIO
66operation. For example if a call to BIO_read() on a socket BIO returns
670 and BIO_should_retry() is false then the cause will be that the
68connection closed. A similar condition on a file BIO will mean that it
69has reached EOF. Some BIO types may place additional information on
70the error queue. For more details see the individual BIO type manual
71pages.
72
73If the underlying I/O structure is in a blocking mode almost all current
74BIO types will not request a retry, because the underlying I/O
75calls will not. If the application knows that the BIO type will never
76signal a retry then it need not call BIO_should_retry() after a failed
77BIO I/O call. This is typically done with file BIOs.
78
79SSL BIOs are the only current exception to this rule: they can request a
80retry even if the underlying I/O structure is blocking, if a handshake
81occurs during a call to BIO_read(). An application can retry the failed
82call immediately or avoid this situation by setting SSL_MODE_AUTO_RETRY
83on the underlying SSL structure.
84
85While an application may retry a failed non blocking call immediately
86this is likely to be very inefficient because the call will fail
87repeatedly until data can be processed or is available. An application
88will normally wait until the necessary condition is satisfied. How
89this is done depends on the underlying I/O structure.
90
91For example if the cause is ultimately a socket and BIO_should_read()
92is true then a call to select() may be made to wait until data is
93available and then retry the BIO operation. By combining the retry
94conditions of several non blocking BIOs in a single select() call
95it is possible to service several BIOs in a single thread, though
96the performance may be poor if SSL BIOs are present because long delays
97can occur during the initial handshake process.
98
99It is possible for a BIO to block indefinitely if the underlying I/O
100structure cannot process or return any data. This depends on the behaviour of
101the platforms I/O functions. This is often not desirable: one solution
102is to use non blocking I/O and use a timeout on the select() (or
103equivalent) call.
104
105=head1 BUGS
106
107The OpenSSL ASN1 functions cannot gracefully deal with non blocking I/O:
108that is they cannot retry after a partial read or write. This is usually
109worked around by only passing the relevant data to ASN1 functions when
110the entire structure can be read or written.
111
112=cut