summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2021-10-24 15:10:13 +0000
committerschwarze <>2021-10-24 15:10:13 +0000
commit86484520bb9fdf67e7e47b29f0fed6ff22b63378 (patch)
treeab6e4a6859e452d35eeb3e6b83e50360a070a7e0
parent05ad4b612f5c1f984f5d2f34e62751408dfaea72 (diff)
downloadopenbsd-86484520bb9fdf67e7e47b29f0fed6ff22b63378.tar.gz
openbsd-86484520bb9fdf67e7e47b29f0fed6ff22b63378.tar.bz2
openbsd-86484520bb9fdf67e7e47b29f0fed6ff22b63378.zip
merge documentation for SSL_read_ex(3), SSL_peek_ex(3), and SSL_write_ex(3)
from the OpenSSL 1.1.1 branch, which is still under a free license
-rw-r--r--src/lib/libssl/man/SSL_read.366
-rw-r--r--src/lib/libssl/man/SSL_write.3125
2 files changed, 130 insertions, 61 deletions
diff --git a/src/lib/libssl/man/SSL_read.3 b/src/lib/libssl/man/SSL_read.3
index ea181ce15c..bb72a8ed82 100644
--- a/src/lib/libssl/man/SSL_read.3
+++ b/src/lib/libssl/man/SSL_read.3
@@ -1,6 +1,6 @@
1.\" $OpenBSD: SSL_read.3,v 1.7 2020/05/26 19:45:58 schwarze Exp $ 1.\" $OpenBSD: SSL_read.3,v 1.8 2021/10/24 15:10:13 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 5a2443ae Nov 14 11:37:36 2016 +0000
3.\" partial merge up to: OpenSSL 18bad535 Apr 9 15:13:55 2019 +0100 3.\" partial merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
5.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org> and 5.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org> and
6.\" Matt Caswell <matt@openssl.org>. 6.\" Matt Caswell <matt@openssl.org>.
@@ -51,38 +51,59 @@
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE. 52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\" 53.\"
54.Dd $Mdocdate: May 26 2020 $ 54.Dd $Mdocdate: October 24 2021 $
55.Dt SSL_READ 3 55.Dt SSL_READ 3
56.Os 56.Os
57.Sh NAME 57.Sh NAME
58.Nm SSL_read_ex ,
58.Nm SSL_read , 59.Nm SSL_read ,
60.Nm SSL_peek_ex ,
59.Nm SSL_peek 61.Nm SSL_peek
60.Nd read bytes from a TLS connection 62.Nd read bytes from a TLS connection
61.Sh SYNOPSIS 63.Sh SYNOPSIS
62.In openssl/ssl.h 64.In openssl/ssl.h
63.Ft int 65.Ft int
66.Fn SSL_read_ex "SSL *ssl" "void *buf" "size_t num" "size_t *readbytes"
67.Ft int
64.Fn SSL_read "SSL *ssl" "void *buf" "int num" 68.Fn SSL_read "SSL *ssl" "void *buf" "int num"
65.Ft int 69.Ft int
70.Fn SSL_peek_ex "SSL *ssl" "void *buf" "size_t num" "size_t *readbytes"
71.Ft int
66.Fn SSL_peek "SSL *ssl" "void *buf" "int num" 72.Fn SSL_peek "SSL *ssl" "void *buf" "int num"
67.Sh DESCRIPTION 73.Sh DESCRIPTION
74.Fn SSL_read_ex
75and
68.Fn SSL_read 76.Fn SSL_read
69tries to read 77try to read
70.Fa num 78.Fa num
71bytes from the specified 79bytes from the specified
72.Fa ssl 80.Fa ssl
73into the buffer 81into the buffer
74.Fa buf . 82.Fa buf .
83On success
84.Fn SSL_read_ex
85stores the number of bytes actually read in
86.Pf * Fa readbytes .
75.Pp 87.Pp
88.Fn SSL_peek_ex
89and
76.Fn SSL_peek 90.Fn SSL_peek
77is identical to 91are identical to
78.Fn SSL_read 92.Fn SSL_read_ex
93and
94.Fn SSL_read ,
95respectively,
79except that no bytes are removed from the underlying BIO during 96except that no bytes are removed from the underlying BIO during
80the read, such that a subsequent call to 97the read, such that a subsequent call to
98.Fn SSL_read_ex
99or
81.Fn SSL_read 100.Fn SSL_read
82will yield at least the same bytes once again. 101will yield at least the same bytes once again.
83.Pp 102.Pp
84In the following, 103In the following,
85.Fn SSL_read 104.Fn SSL_read_ex ,
105.Fn SSL_read ,
106.Fn SSL_peek_ex ,
86and 107and
87.Fn SSL_peek 108.Fn SSL_peek
88are called 109are called
@@ -107,11 +128,11 @@ or
107.Xr SSL_set_accept_state 3 128.Xr SSL_set_accept_state 3
108before the first call to a read function. 129before the first call to a read function.
109.Pp 130.Pp
110The read functions works based on the TLS records. 131The read functions work based on the TLS records.
111The data are received in records (with a maximum record size of 16kB). 132The data are received in records (with a maximum record size of 16kB).
112Only when a record has been completely received, it can be processed 133Only when a record has been completely received, it can be processed
113(decrypted and checked for integrity). 134(decrypted and checked for integrity).
114Therefore data that was not retrieved at the last read call can 135Therefore, data that was not retrieved at the last read call can
115still be buffered inside the TLS layer and will be retrieved on the 136still be buffered inside the TLS layer and will be retrieved on the
116next read call. 137next read call.
117If 138If
@@ -182,7 +203,24 @@ or
182.Dv SSL_ERROR_WANT_WRITE , 203.Dv SSL_ERROR_WANT_WRITE ,
183it must be repeated with the same arguments. 204it must be repeated with the same arguments.
184.Sh RETURN VALUES 205.Sh RETURN VALUES
185The following return values can occur: 206.Fn SSL_read_ex
207and
208.Fn SSL_peek_ex
209return 1 for success or 0 for failure.
210Success means that one or more application data bytes
211have been read from the SSL connection.
212Failure means that no bytes could be read from the SSL connection.
213Failures can be retryable (e.g. we are waiting for more bytes to be
214delivered by the network) or non-retryable (e.g. a fatal network error).
215In the event of a failure, call
216.Xr SSL_get_error 3
217to find out the reason which indicates whether the call is retryable or not.
218.Pp
219For
220.Fn SSL_read
221and
222.Fn SSL_peek ,
223the following return values can occur:
186.Bl -tag -width Ds 224.Bl -tag -width Ds
187.It >0 225.It >0
188The read operation was successful. 226The read operation was successful.
@@ -232,3 +270,9 @@ appeared in SSLeay 0.4 or earlier.
232first appeared in SSLeay 0.6.6. 270first appeared in SSLeay 0.6.6.
233Both functions have been available since 271Both functions have been available since
234.Ox 2.4 . 272.Ox 2.4 .
273.Pp
274.Fn SSL_read_ex
275and
276.Fn SSL_peek_ex
277first appeared in OpenSSL 1.1.1 and have been available since
278.Ox 7.1 .
diff --git a/src/lib/libssl/man/SSL_write.3 b/src/lib/libssl/man/SSL_write.3
index 16be55f259..2c6fbcef08 100644
--- a/src/lib/libssl/man/SSL_write.3
+++ b/src/lib/libssl/man/SSL_write.3
@@ -1,8 +1,11 @@
1.\" $OpenBSD: SSL_write.3,v 1.6 2020/10/08 16:02:38 tb Exp $ 1.\" $OpenBSD: SSL_write.3,v 1.7 2021/10/24 15:10:13 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" partial merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
3.\" 4.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 5.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>
5.\" Copyright (c) 2000, 2001, 2002 The OpenSSL Project. All rights reserved. 6.\" and Matt Caswell <matt@openssl.org>.
7.\" Copyright (c) 2000, 2001, 2002, 2016 The OpenSSL Project.
8.\" All rights reserved.
6.\" 9.\"
7.\" Redistribution and use in source and binary forms, with or without 10.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions 11.\" modification, are permitted provided that the following conditions
@@ -48,59 +51,67 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 53.\"
51.Dd $Mdocdate: October 8 2020 $ 54.Dd $Mdocdate: October 24 2021 $
52.Dt SSL_WRITE 3 55.Dt SSL_WRITE 3
53.Os 56.Os
54.Sh NAME 57.Sh NAME
58.Nm SSL_write_ex ,
55.Nm SSL_write 59.Nm SSL_write
56.Nd write bytes to a TLS/SSL connection 60.Nd write bytes to a TLS connection
57.Sh SYNOPSIS 61.Sh SYNOPSIS
58.In openssl/ssl.h 62.In openssl/ssl.h
59.Ft int 63.Ft int
64.Fn SSL_write_ex "SSL *ssl" "const void *buf" "size_t num" "size_t *written"
65.Ft int
60.Fn SSL_write "SSL *ssl" "const void *buf" "int num" 66.Fn SSL_write "SSL *ssl" "const void *buf" "int num"
61.Sh DESCRIPTION 67.Sh DESCRIPTION
68.Fn SSL_write_ex
69and
62.Fn SSL_write 70.Fn SSL_write
63writes 71write
64.Fa num 72.Fa num
65bytes from the buffer 73bytes from the buffer
66.Fa buf 74.Fa buf
67into the specified 75into the specified
68.Fa ssl 76.Fa ssl
69connection. 77connection.
78On success
79.Fn SSL_write_ex
80stores the number of bytes written in
81.Pf * Fa written .
70.Pp 82.Pp
71If necessary, 83In the following,
84.Fn SSL_write_ex
85and
72.Fn SSL_write 86.Fn SSL_write
73will negotiate a TLS/SSL session, if not already explicitly performed by 87are called
88.Dq write functions .
89.Pp
90If necessary, a write function negotiates a TLS session,
91if not already explicitly performed by
74.Xr SSL_connect 3 92.Xr SSL_connect 3
75or 93or
76.Xr SSL_accept 3 . 94.Xr SSL_accept 3 .
77If the peer requests a re-negotiation, 95If the peer requests a re-negotiation,
78it will be performed transparently during the 96it will be performed transparently during the
79.Fn SSL_write 97write function operation.
80operation. 98The behaviour of the write functions depends on the underlying
81The behaviour of
82.Fn SSL_write
83depends on the underlying
84.Vt BIO . 99.Vt BIO .
85.Pp 100.Pp
86For the transparent negotiation to succeed, the 101For the transparent negotiation to succeed, the
87.Fa ssl 102.Fa ssl
88must have been initialized to client or server mode. 103must have been initialized to client or server mode.
89This is being done by calling 104This is done by calling
90.Xr SSL_set_connect_state 3 105.Xr SSL_set_connect_state 3
91or 106or
92.Xr SSL_set_accept_state 3 107.Xr SSL_set_accept_state 3
93before the first call to an 108before the first call to a write function.
94.Xr SSL_read 3
95or
96.Fn SSL_write
97function.
98.Pp 109.Pp
99If the underlying 110If the underlying
100.Vt BIO 111.Vt BIO
101is 112is
102.Em blocking , 113.Em blocking ,
103.Fn SSL_write 114the write function
104will only return once the write operation has been finished or an error 115will only return once the write operation has been finished or an error
105occurred, except when a renegotiation takes place, in which case a 116occurred, except when a renegotiation takes place, in which case a
106.Dv SSL_ERROR_WANT_READ 117.Dv SSL_ERROR_WANT_READ
@@ -115,26 +126,19 @@ If the underlying
115.Vt BIO 126.Vt BIO
116is 127is
117.Em non-blocking , 128.Em non-blocking ,
118.Fn SSL_write 129the write function will also return when the underlying
119will also return when the underlying
120.Vt BIO 130.Vt BIO
121could not satisfy the needs of 131could not satisfy the needs of the function to continue the operation.
122.Fn SSL_write
123to continue the operation.
124In this case a call to 132In this case a call to
125.Xr SSL_get_error 3 133.Xr SSL_get_error 3
126with the return value of 134with the return value of the write function will yield
127.Fn SSL_write
128will yield
129.Dv SSL_ERROR_WANT_READ 135.Dv SSL_ERROR_WANT_READ
130or 136or
131.Dv SSL_ERROR_WANT_WRITE . 137.Dv SSL_ERROR_WANT_WRITE .
132As at any time a re-negotiation is possible, a call to 138As at any time a re-negotiation is possible, a call to
133.Fn SSL_write 139a write function can also cause read operations.
134can also cause read operations!
135The calling process then must repeat the call after taking appropriate action 140The calling process then must repeat the call after taking appropriate action
136to satisfy the needs of 141to satisfy the needs of the write function.
137.Fn SSL_write .
138The action depends on the underlying 142The action depends on the underlying
139.Vt BIO . 143.Vt BIO .
140When using a non-blocking socket, nothing is to be done, but 144When using a non-blocking socket, nothing is to be done, but
@@ -147,7 +151,7 @@ like a
147pair, data must be written into or retrieved out of the BIO before being able 151pair, data must be written into or retrieved out of the BIO before being able
148to continue. 152to continue.
149.Pp 153.Pp
150.Fn SSL_write 154The write functions
151will only return with success when the complete contents of 155will only return with success when the complete contents of
152.Fa buf 156.Fa buf
153of length 157of length
@@ -157,23 +161,15 @@ This default behaviour can be changed with the
157.Dv SSL_MODE_ENABLE_PARTIAL_WRITE 161.Dv SSL_MODE_ENABLE_PARTIAL_WRITE
158option of 162option of
159.Xr SSL_CTX_set_mode 3 . 163.Xr SSL_CTX_set_mode 3 .
160When this flag is set, 164When this flag is set, the write functions will also return with
161.Fn SSL_write 165success when a partial write has been successfully completed.
162will also return with success when a partial write has been successfully 166In this case the write function operation is considered completed.
163completed. 167The bytes are sent and a new write call with a new buffer (with the
164In this case the 168already sent bytes removed) must be started.
165.Fn SSL_write
166operation is considered completed.
167The bytes are sent and a new
168.Fn SSL_write
169operation with a new buffer (with the already sent bytes removed) must be
170started.
171A partial write is performed with the size of a message block, 169A partial write is performed with the size of a message block,
172which is 16kB. 170which is 16kB.
173.Pp 171.Pp
174When an 172When a write function call has to be repeated because
175.Fn SSL_write
176operation has to be repeated because
177.Xr SSL_get_error 3 173.Xr SSL_get_error 3
178returned 174returned
179.Dv SSL_ERROR_WANT_READ 175.Dv SSL_ERROR_WANT_READ
@@ -186,12 +182,37 @@ When calling
186with 182with
187.Fa num Ns =0 183.Fa num Ns =0
188bytes to be sent, the behaviour is undefined. 184bytes to be sent, the behaviour is undefined.
185.Fn SSL_write_ex
186can be called with
187.Fa num Ns =0 ,
188but will not send application data to the peer.
189.Sh RETURN VALUES 189.Sh RETURN VALUES
190The following return values can occur: 190.Fn SSL_write_ex
191returns 1 for success or 0 for failure.
192Success means that all requested application data bytes have been
193written to the TLS connection or, if
194.Dv SSL_MODE_ENABLE_PARTIAL_WRITE
195is in use, at least one application data byte has been written
196to the TLS connection.
197Failure means that not all the requested bytes have been written yet (if
198.Dv SSL_MODE_ENABLE_PARTIAL_WRITE
199is not in use) or no bytes could be written to the TLS connection (if
200.Dv SSL_MODE_ENABLE_PARTIAL_WRITE
201is in use).
202Failures can be retryable (e.g. the network write buffer has temporarily
203filled up) or non-retryable (e.g. a fatal network error).
204In the event of a failure, call
205.Xr SSL_get_error 3
206to find out the reason
207which indicates whether the call is retryable or not.
208.Pp
209For
210.Fn SSL_write ,
211the following return values can occur:
191.Bl -tag -width Ds 212.Bl -tag -width Ds
192.It >0 213.It >0
193The write operation was successful. 214The write operation was successful.
194The return value is the number of bytes actually written to the TLS/SSL 215The return value is the number of bytes actually written to the TLS
195connection. 216connection.
196.It 0 217.It 0
197The write operation was not successful. 218The write operation was not successful.
@@ -222,3 +243,7 @@ with the return value to find out the reason.
222.Fn SSL_write 243.Fn SSL_write
223appeared in SSLeay 0.4 or earlier and has been available since 244appeared in SSLeay 0.4 or earlier and has been available since
224.Ox 2.4 . 245.Ox 2.4 .
246.Pp
247.Fn SSL_write_ex
248first appeared in OpenSSL 1.1.1 and has been available since
249.Ox 7.1 .