diff options
author | schwarze <> | 2016-12-04 12:17:34 +0000 |
---|---|---|
committer | schwarze <> | 2016-12-04 12:17:34 +0000 |
commit | a9c2a9fc0155b518edbd41a398ffa986e0d855eb (patch) | |
tree | f1d000bfbd2bac32e23b1c8fe40b1d58698bec47 | |
parent | f1b205b1ec58dd831d2441c270bdcb371fec9665 (diff) | |
download | openbsd-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.3 | 183 |
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 |
16 | tries to read | 66 | tries to read |
@@ -19,70 +69,68 @@ bytes from the specified | |||
19 | .Fa ssl | 69 | .Fa ssl |
20 | into the buffer | 70 | into the buffer |
21 | .Fa buf . | 71 | .Fa buf . |
22 | .Sh NOTES | 72 | .Pp |
23 | If necessary, | 73 | .Fn SSL_peek |
74 | is identical to | ||
75 | .Fn SSL_read | ||
76 | except that no bytes are removed from the underlying BIO during | ||
77 | the read, such that a subsequent call to | ||
78 | .Fn SSL_read | ||
79 | will yield at least the same bytes once again. | ||
80 | .Pp | ||
81 | In the following, | ||
24 | .Fn SSL_read | 82 | .Fn SSL_read |
25 | will negotiate a TLS/SSL session, if not already explicitly performed by | 83 | and |
84 | .Fn SSL_peek | ||
85 | are called | ||
86 | .Dq read functions . | ||
87 | .Pp | ||
88 | If necessary, a read function will negotiate a TLS/SSL session, if | ||
89 | not already explicitly performed by | ||
26 | .Xr SSL_connect 3 | 90 | .Xr SSL_connect 3 |
27 | or | 91 | or |
28 | .Xr SSL_accept 3 . | 92 | .Xr SSL_accept 3 . |
29 | If the peer requests a re-negotiation, | 93 | If the peer requests a re-negotiation, it will be performed |
30 | it will be performed transparently during the | 94 | transparently during the read function operation. |
31 | .Fn SSL_read | 95 | The behaviour of the read functions depends on the underlying |
32 | operation. | ||
33 | The behaviour of | ||
34 | .Fn SSL_read | ||
35 | depends on the underlying | ||
36 | .Vt BIO . | 96 | .Vt BIO . |
37 | .Pp | 97 | .Pp |
38 | For the transparent negotiation to succeed, the | 98 | For the transparent negotiation to succeed, the |
39 | .Fa ssl | 99 | .Fa ssl |
40 | must have been initialized to client or server mode. | 100 | must have been initialized to client or server mode. |
41 | This is being done by calling | 101 | This is done by calling |
42 | .Xr SSL_set_connect_state 3 | 102 | .Xr SSL_set_connect_state 3 |
43 | or | 103 | or |
44 | .Xr SSL_set_accept_state 3 | 104 | .Xr SSL_set_accept_state 3 |
45 | before the first call to | 105 | before the first call to a read function. |
46 | .Fn SSL_read | ||
47 | or | ||
48 | .Xr SSL_write 3 . | ||
49 | .Pp | 106 | .Pp |
50 | .Fn SSL_read | 107 | The read functions works based on the SSL/TLS records. |
51 | works based on the SSL/TLS records. | 108 | The data are received in records (with a maximum record size of 16kB). |
52 | The data are received in records (with a maximum record size of 16kB for | 109 | Only when a record has been completely received, it can be processed |
53 | SSLv3/TLSv1). | ||
54 | Only after a record has been completely received can it be processed | ||
55 | (decrypted and checked for integrity). | 110 | (decrypted and checked for integrity). |
56 | Therefore data not retrieved at the last call of | 111 | Therefore data that was not retrieved at the last read call can |
57 | .Fn SSL_read | 112 | still be buffered inside the SSL layer and will be retrieved on the |
58 | can still be buffered inside the SSL layer and will be retrieved on the next | 113 | next read call. |
59 | call to | ||
60 | .Fn SSL_read . | ||
61 | If | 114 | If |
62 | .Fa num | 115 | .Fa num |
63 | is higher than the number of bytes buffered, | 116 | is higher than the number of bytes buffered, the read functions |
64 | .Fn SSL_read | ||
65 | will return with the bytes buffered. | 117 | will return with the bytes buffered. |
66 | If no more bytes are in the buffer, | 118 | If no more bytes are in the buffer, the read functions will trigger |
67 | .Fn SSL_read | 119 | the processing of the next record. |
68 | will trigger the processing of the next record. | 120 | Only when the record has been received and processed completely |
69 | Only when the record has been received and processed completely will | 121 | will the read functions return reporting success. |
70 | .Fn SSL_read | ||
71 | return reporting success. | ||
72 | At most the contents of the record will be returned. | 122 | At most the contents of the record will be returned. |
73 | As the size of an SSL/TLS record may exceed the maximum packet size of the | 123 | As the size of an SSL/TLS record may exceed the maximum packet size |
74 | underlying transport (e.g., TCP), it may be necessary to read several packets | 124 | of the underlying transport (e.g., TCP), it may be necessary to |
75 | from the transport layer before the record is complete and | 125 | read several packets from the transport layer before the record is |
76 | .Fn SSL_read | 126 | complete and the read call can succeed. |
77 | can succeed. | ||
78 | .Pp | 127 | .Pp |
79 | If the underlying | 128 | If the underlying |
80 | .Vt BIO | 129 | .Vt BIO |
81 | is | 130 | is blocking, |
82 | .Em blocking , | 131 | a read function will only return once the read operation has been |
83 | .Fn SSL_read | 132 | finished or an error occurred, except when a renegotiation takes |
84 | will only return once the read operation has been finished or an error | 133 | place, in which case an |
85 | has occurred, except when a renegotiation take place, in which case a | ||
86 | .Dv SSL_ERROR_WANT_READ | 134 | .Dv SSL_ERROR_WANT_READ |
87 | may occur. | 135 | may occur. |
88 | This behavior can be controlled with the | 136 | This behavior can be controlled with the |
@@ -93,28 +141,19 @@ call. | |||
93 | .Pp | 141 | .Pp |
94 | If the underlying | 142 | If the underlying |
95 | .Vt BIO | 143 | .Vt BIO |
96 | is | 144 | is non-blocking, a read function will also return when the underlying |
97 | .Em non-blocking , | ||
98 | .Fn SSL_read | ||
99 | will also return when the underlying | ||
100 | .Vt BIO | 145 | .Vt BIO |
101 | could not satisfy the needs of | 146 | could not satisfy the needs of the function to continue the operation. |
102 | .Fn SSL_read | ||
103 | to continue the operation. | ||
104 | In this case a call to | 147 | In this case a call to |
105 | .Xr SSL_get_error 3 | 148 | .Xr SSL_get_error 3 |
106 | with the return value of | 149 | with the return value of the read function will yield |
107 | .Fn SSL_read | ||
108 | will yield | ||
109 | .Dv SSL_ERROR_WANT_READ | 150 | .Dv SSL_ERROR_WANT_READ |
110 | or | 151 | or |
111 | .Dv SSL_ERROR_WANT_WRITE . | 152 | .Dv SSL_ERROR_WANT_WRITE . |
112 | As at any time a re-negotiation is possible, a call to | 153 | As at any time a re-negotiation is possible, a read function may |
113 | .Fn SSL_read | 154 | also cause write operations. |
114 | can also cause write operations! | 155 | The calling process must then repeat the call after taking appropriate |
115 | The calling process then must repeat the call after taking appropriate action | 156 | action to satisfy the needs of the read function. |
116 | to satisfy the needs of | ||
117 | .Fn SSL_read . | ||
118 | The action depends on the underlying | 157 | The action depends on the underlying |
119 | .Vt BIO . | 158 | .Vt BIO . |
120 | When using a non-blocking socket, nothing is to be done, but | 159 | When 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 |
132 | can be used to find out whether there are buffered bytes available for | 171 | can be used to find out whether there are buffered bytes available for |
133 | immediate retrieval. | 172 | immediate retrieval. |
134 | In this case | 173 | In this case a read function can be called without blocking or |
135 | .Fn SSL_read | 174 | actually receiving new data from the underlying socket. |
136 | can be called without blocking or actually receiving new data from the | 175 | .Pp |
137 | underlying socket. | 176 | When a read function operation has to be repeated because of |
138 | .Sh WARNING | ||
139 | When an | ||
140 | .Fn SSL_read | ||
141 | operation has to be repeated because of | ||
142 | .Dv SSL_ERROR_WANT_READ | 177 | .Dv SSL_ERROR_WANT_READ |
143 | or | 178 | or |
144 | .Dv SSL_ERROR_WANT_WRITE , | 179 | .Dv SSL_ERROR_WANT_WRITE , |
@@ -147,8 +182,9 @@ it must be repeated with the same arguments. | |||
147 | The following return values can occur: | 182 | The following return values can occur: |
148 | .Bl -tag -width Ds | 183 | .Bl -tag -width Ds |
149 | .It >0 | 184 | .It >0 |
150 | The read operation was successful; the return value is the number of bytes | 185 | The read operation was successful. |
151 | actually read from the TLS/SSL connection. | 186 | The return value is the number of bytes actually read from the |
187 | TLS/SSL connection. | ||
152 | .It 0 | 188 | .It 0 |
153 | The read operation was not successful. | 189 | The read operation was not successful. |
154 | The reason may either be a clean shutdown due to a | 190 | The reason may either be a clean shutdown due to a |
@@ -166,11 +202,6 @@ Call | |||
166 | with the return value to find out whether an error occurred or the connection | 202 | with the return value to find out whether an error occurred or the connection |
167 | was shut down cleanly | 203 | was shut down cleanly |
168 | .Pq Dv SSL_ERROR_ZERO_RETURN . | 204 | .Pq Dv SSL_ERROR_ZERO_RETURN . |
169 | .Pp | ||
170 | SSLv2 (deprecated) does not support a shutdown alert protocol, so it can only | ||
171 | be detected whether the underlying connection was closed. | ||
172 | It cannot be checked whether the closure was initiated by the peer or by | ||
173 | something else. | ||
174 | .It <0 | 205 | .It <0 |
175 | The read operation was not successful, because either an error occurred or | 206 | The read operation was not successful, because either an error occurred or |
176 | action must be taken by the calling process. | 207 | action must be taken by the calling process. |