summaryrefslogtreecommitdiff
path: root/src/lib/libssl/man/SSL_write.3
diff options
context:
space:
mode:
authorschwarze <>2021-10-24 15:10:13 +0000
committerschwarze <>2021-10-24 15:10:13 +0000
commit86484520bb9fdf67e7e47b29f0fed6ff22b63378 (patch)
treeab6e4a6859e452d35eeb3e6b83e50360a070a7e0 /src/lib/libssl/man/SSL_write.3
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
Diffstat (limited to 'src/lib/libssl/man/SSL_write.3')
-rw-r--r--src/lib/libssl/man/SSL_write.3125
1 files changed, 75 insertions, 50 deletions
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 .