summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2016-12-04 12:17:34 +0000
committerschwarze <>2016-12-04 12:17:34 +0000
commita9c2a9fc0155b518edbd41a398ffa986e0d855eb (patch)
treef1d000bfbd2bac32e23b1c8fe40b1d58698bec47
parentf1b205b1ec58dd831d2441c270bdcb371fec9665 (diff)
downloadopenbsd-a9c2a9fc0155b518edbd41a398ffa986e0d855eb.tar.gz
openbsd-a9c2a9fc0155b518edbd41a398ffa986e0d855eb.tar.bz2
openbsd-a9c2a9fc0155b518edbd41a398ffa986e0d855eb.zip
Add Copyright and license.
Merge documentation of SSL_peek(3) from OpenSSL. Stop taking about SSLv2. Many wording improvements, most from OpenSSL.
-rw-r--r--src/lib/libssl/man/SSL_read.3183
1 files changed, 107 insertions, 76 deletions
diff --git a/src/lib/libssl/man/SSL_read.3 b/src/lib/libssl/man/SSL_read.3
index 662aed4daa..eb598a63b4 100644
--- a/src/lib/libssl/man/SSL_read.3
+++ b/src/lib/libssl/man/SSL_read.3
@@ -1,7 +1,55 @@
1.\" $OpenBSD: SSL_read.3,v 1.2 2016/12/04 12:17:34 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
1.\" 3.\"
2.\" $OpenBSD: SSL_read.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $ 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org> and
5.\" Matt Caswell <matt@openssl.org>.
6.\" Copyright (c) 2000, 2001, 2008, 2016 The OpenSSL Project. All rights reserved.
3.\" 7.\"
4.Dd $Mdocdate: November 5 2016 $ 8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: December 4 2016 $
5.Dt SSL_READ 3 53.Dt SSL_READ 3
6.Os 54.Os
7.Sh NAME 55.Sh NAME
@@ -11,6 +59,8 @@
11.In openssl/ssl.h 59.In openssl/ssl.h
12.Ft int 60.Ft int
13.Fn SSL_read "SSL *ssl" "void *buf" "int num" 61.Fn SSL_read "SSL *ssl" "void *buf" "int num"
62.Ft int
63.Fn SSL_peek "SSL *ssl" "void *buf" "int num"
14.Sh DESCRIPTION 64.Sh DESCRIPTION
15.Fn SSL_read 65.Fn SSL_read
16tries to read 66tries to read
@@ -19,70 +69,68 @@ bytes from the specified
19.Fa ssl 69.Fa ssl
20into the buffer 70into the buffer
21.Fa buf . 71.Fa buf .
22.Sh NOTES 72.Pp
23If necessary, 73.Fn SSL_peek
74is identical to
75.Fn SSL_read
76except that no bytes are removed from the underlying BIO during
77the read, such that a subsequent call to
78.Fn SSL_read
79will yield at least the same bytes once again.
80.Pp
81In the following,
24.Fn SSL_read 82.Fn SSL_read
25will negotiate a TLS/SSL session, if not already explicitly performed by 83and
84.Fn SSL_peek
85are called
86.Dq read functions .
87.Pp
88If necessary, a read function will negotiate a TLS/SSL session, if
89not already explicitly performed by
26.Xr SSL_connect 3 90.Xr SSL_connect 3
27or 91or
28.Xr SSL_accept 3 . 92.Xr SSL_accept 3 .
29If the peer requests a re-negotiation, 93If the peer requests a re-negotiation, it will be performed
30it will be performed transparently during the 94transparently during the read function operation.
31.Fn SSL_read 95The behaviour of the read functions depends on the underlying
32operation.
33The behaviour of
34.Fn SSL_read
35depends on the underlying
36.Vt BIO . 96.Vt BIO .
37.Pp 97.Pp
38For the transparent negotiation to succeed, the 98For the transparent negotiation to succeed, the
39.Fa ssl 99.Fa ssl
40must have been initialized to client or server mode. 100must have been initialized to client or server mode.
41This is being done by calling 101This is done by calling
42.Xr SSL_set_connect_state 3 102.Xr SSL_set_connect_state 3
43or 103or
44.Xr SSL_set_accept_state 3 104.Xr SSL_set_accept_state 3
45before the first call to 105before the first call to a read function.
46.Fn SSL_read
47or
48.Xr SSL_write 3 .
49.Pp 106.Pp
50.Fn SSL_read 107The read functions works based on the SSL/TLS records.
51works based on the SSL/TLS records. 108The data are received in records (with a maximum record size of 16kB).
52The data are received in records (with a maximum record size of 16kB for 109Only when a record has been completely received, it can be processed
53SSLv3/TLSv1).
54Only after a record has been completely received can it be processed
55(decrypted and checked for integrity). 110(decrypted and checked for integrity).
56Therefore data not retrieved at the last call of 111Therefore data that was not retrieved at the last read call can
57.Fn SSL_read 112still be buffered inside the SSL layer and will be retrieved on the
58can still be buffered inside the SSL layer and will be retrieved on the next 113next read call.
59call to
60.Fn SSL_read .
61If 114If
62.Fa num 115.Fa num
63is higher than the number of bytes buffered, 116is higher than the number of bytes buffered, the read functions
64.Fn SSL_read
65will return with the bytes buffered. 117will return with the bytes buffered.
66If no more bytes are in the buffer, 118If no more bytes are in the buffer, the read functions will trigger
67.Fn SSL_read 119the processing of the next record.
68will trigger the processing of the next record. 120Only when the record has been received and processed completely
69Only when the record has been received and processed completely will 121will the read functions return reporting success.
70.Fn SSL_read
71return reporting success.
72At most the contents of the record will be returned. 122At most the contents of the record will be returned.
73As the size of an SSL/TLS record may exceed the maximum packet size of the 123As the size of an SSL/TLS record may exceed the maximum packet size
74underlying transport (e.g., TCP), it may be necessary to read several packets 124of the underlying transport (e.g., TCP), it may be necessary to
75from the transport layer before the record is complete and 125read several packets from the transport layer before the record is
76.Fn SSL_read 126complete and the read call can succeed.
77can succeed.
78.Pp 127.Pp
79If the underlying 128If the underlying
80.Vt BIO 129.Vt BIO
81is 130is blocking,
82.Em blocking , 131a read function will only return once the read operation has been
83.Fn SSL_read 132finished or an error occurred, except when a renegotiation takes
84will only return once the read operation has been finished or an error 133place, in which case an
85has occurred, except when a renegotiation take place, in which case a
86.Dv SSL_ERROR_WANT_READ 134.Dv SSL_ERROR_WANT_READ
87may occur. 135may occur.
88This behavior can be controlled with the 136This behavior can be controlled with the
@@ -93,28 +141,19 @@ call.
93.Pp 141.Pp
94If the underlying 142If the underlying
95.Vt BIO 143.Vt BIO
96is 144is non-blocking, a read function will also return when the underlying
97.Em non-blocking ,
98.Fn SSL_read
99will also return when the underlying
100.Vt BIO 145.Vt BIO
101could not satisfy the needs of 146could not satisfy the needs of the function to continue the operation.
102.Fn SSL_read
103to continue the operation.
104In this case a call to 147In this case a call to
105.Xr SSL_get_error 3 148.Xr SSL_get_error 3
106with the return value of 149with the return value of the read function will yield
107.Fn SSL_read
108will yield
109.Dv SSL_ERROR_WANT_READ 150.Dv SSL_ERROR_WANT_READ
110or 151or
111.Dv SSL_ERROR_WANT_WRITE . 152.Dv SSL_ERROR_WANT_WRITE .
112As at any time a re-negotiation is possible, a call to 153As at any time a re-negotiation is possible, a read function may
113.Fn SSL_read 154also cause write operations.
114can also cause write operations! 155The calling process must then repeat the call after taking appropriate
115The calling process then must repeat the call after taking appropriate action 156action to satisfy the needs of the read function.
116to satisfy the needs of
117.Fn SSL_read .
118The action depends on the underlying 157The action depends on the underlying
119.Vt BIO . 158.Vt BIO .
120When using a non-blocking socket, nothing is to be done, but 159When using a non-blocking socket, nothing is to be done, but
@@ -131,14 +170,10 @@ before being able to continue.
131.Xr SSL_pending 3 170.Xr SSL_pending 3
132can be used to find out whether there are buffered bytes available for 171can be used to find out whether there are buffered bytes available for
133immediate retrieval. 172immediate retrieval.
134In this case 173In this case a read function can be called without blocking or
135.Fn SSL_read 174actually receiving new data from the underlying socket.
136can be called without blocking or actually receiving new data from the 175.Pp
137underlying socket. 176When a read function operation has to be repeated because of
138.Sh WARNING
139When an
140.Fn SSL_read
141operation has to be repeated because of
142.Dv SSL_ERROR_WANT_READ 177.Dv SSL_ERROR_WANT_READ
143or 178or
144.Dv SSL_ERROR_WANT_WRITE , 179.Dv SSL_ERROR_WANT_WRITE ,
@@ -147,8 +182,9 @@ it must be repeated with the same arguments.
147The following return values can occur: 182The following return values can occur:
148.Bl -tag -width Ds 183.Bl -tag -width Ds
149.It >0 184.It >0
150The read operation was successful; the return value is the number of bytes 185The read operation was successful.
151actually read from the TLS/SSL connection. 186The return value is the number of bytes actually read from the
187TLS/SSL connection.
152.It 0 188.It 0
153The read operation was not successful. 189The read operation was not successful.
154The reason may either be a clean shutdown due to a 190The reason may either be a clean shutdown due to a
@@ -166,11 +202,6 @@ Call
166with the return value to find out whether an error occurred or the connection 202with the return value to find out whether an error occurred or the connection
167was shut down cleanly 203was shut down cleanly
168.Pq Dv SSL_ERROR_ZERO_RETURN . 204.Pq Dv SSL_ERROR_ZERO_RETURN .
169.Pp
170SSLv2 (deprecated) does not support a shutdown alert protocol, so it can only
171be detected whether the underlying connection was closed.
172It cannot be checked whether the closure was initiated by the peer or by
173something else.
174.It <0 205.It <0
175The read operation was not successful, because either an error occurred or 206The read operation was not successful, because either an error occurred or
176action must be taken by the calling process. 207action must be taken by the calling process.