xref: /freebsd-src/crypto/openssl/doc/man3/SSL_CTX_set_split_send_fragment.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5e71b7053SJung-uk KimSSL_CTX_set_max_send_fragment, SSL_set_max_send_fragment,
6e71b7053SJung-uk KimSSL_CTX_set_split_send_fragment, SSL_set_split_send_fragment,
7e71b7053SJung-uk KimSSL_CTX_set_max_pipelines, SSL_set_max_pipelines,
8e71b7053SJung-uk KimSSL_CTX_set_default_read_buffer_len, SSL_set_default_read_buffer_len,
9e71b7053SJung-uk KimSSL_CTX_set_tlsext_max_fragment_length,
10e71b7053SJung-uk KimSSL_set_tlsext_max_fragment_length,
11e71b7053SJung-uk KimSSL_SESSION_get_max_fragment_length - Control fragment size settings and pipelining operations
12e71b7053SJung-uk Kim
13e71b7053SJung-uk Kim=head1 SYNOPSIS
14e71b7053SJung-uk Kim
15e71b7053SJung-uk Kim #include <openssl/ssl.h>
16e71b7053SJung-uk Kim
17e71b7053SJung-uk Kim long SSL_CTX_set_max_send_fragment(SSL_CTX *ctx, long);
18e71b7053SJung-uk Kim long SSL_set_max_send_fragment(SSL *ssl, long m);
19e71b7053SJung-uk Kim
20e71b7053SJung-uk Kim long SSL_CTX_set_max_pipelines(SSL_CTX *ctx, long m);
21e71b7053SJung-uk Kim long SSL_set_max_pipelines(SSL_CTX *ssl, long m);
22e71b7053SJung-uk Kim
23e71b7053SJung-uk Kim long SSL_CTX_set_split_send_fragment(SSL_CTX *ctx, long m);
24e71b7053SJung-uk Kim long SSL_set_split_send_fragment(SSL *ssl, long m);
25e71b7053SJung-uk Kim
26e71b7053SJung-uk Kim void SSL_CTX_set_default_read_buffer_len(SSL_CTX *ctx, size_t len);
27e71b7053SJung-uk Kim void SSL_set_default_read_buffer_len(SSL *s, size_t len);
28e71b7053SJung-uk Kim
29e71b7053SJung-uk Kim int SSL_CTX_set_tlsext_max_fragment_length(SSL_CTX *ctx, uint8_t mode);
30e71b7053SJung-uk Kim int SSL_set_tlsext_max_fragment_length(SSL *ssl, uint8_t mode);
31*b077aed3SPierre Pronchery uint8_t SSL_SESSION_get_max_fragment_length(const SSL_SESSION *session);
32e71b7053SJung-uk Kim
33e71b7053SJung-uk Kim=head1 DESCRIPTION
34e71b7053SJung-uk Kim
35e71b7053SJung-uk KimSome engines are able to process multiple simultaneous crypto operations. This
36e71b7053SJung-uk Kimcapability could be utilised to parallelise the processing of a single
37e71b7053SJung-uk Kimconnection. For example a single write can be split into multiple records and
38e71b7053SJung-uk Kimeach one encrypted independently and in parallel. Note: this will only work in
39e71b7053SJung-uk KimTLS1.1+. There is no support in SSLv3, TLSv1.0 or DTLS (any version). This
40e71b7053SJung-uk Kimcapability is known as "pipelining" within OpenSSL.
41e71b7053SJung-uk Kim
42e71b7053SJung-uk KimIn order to benefit from the pipelining capability. You need to have an engine
43e71b7053SJung-uk Kimthat provides ciphers that support this. The OpenSSL "dasync" engine provides
4458f35182SJung-uk KimAES128-SHA based ciphers that have this capability. However, these are for
45e71b7053SJung-uk Kimdevelopment and test purposes only.
46e71b7053SJung-uk Kim
47e71b7053SJung-uk KimSSL_CTX_set_max_send_fragment() and SSL_set_max_send_fragment() set the
48e71b7053SJung-uk KimB<max_send_fragment> parameter for SSL_CTX and SSL objects respectively. This
49e71b7053SJung-uk Kimvalue restricts the amount of plaintext bytes that will be sent in any one
50e71b7053SJung-uk KimSSL/TLS record. By default its value is SSL3_RT_MAX_PLAIN_LENGTH (16384). These
51e71b7053SJung-uk Kimfunctions will only accept a value in the range 512 - SSL3_RT_MAX_PLAIN_LENGTH.
52e71b7053SJung-uk Kim
53e71b7053SJung-uk KimSSL_CTX_set_max_pipelines() and SSL_set_max_pipelines() set the maximum number
54e71b7053SJung-uk Kimof pipelines that will be used at any one time. This value applies to both
55e71b7053SJung-uk Kim"read" pipelining and "write" pipelining. By default only one pipeline will be
56e71b7053SJung-uk Kimused (i.e. normal non-parallel operation). The number of pipelines set must be
57e71b7053SJung-uk Kimin the range 1 - SSL_MAX_PIPELINES (32). Setting this to a value > 1 will also
58e71b7053SJung-uk Kimautomatically turn on "read_ahead" (see L<SSL_CTX_set_read_ahead(3)>). This is
59*b077aed3SPierre Proncheryexplained further below. OpenSSL will only ever use more than one pipeline if
60e71b7053SJung-uk Kima cipher suite is negotiated that uses a pipeline capable cipher provided by an
61e71b7053SJung-uk Kimengine.
62e71b7053SJung-uk Kim
63e71b7053SJung-uk KimPipelining operates slightly differently for reading encrypted data compared to
64e71b7053SJung-uk Kimwriting encrypted data. SSL_CTX_set_split_send_fragment() and
65e71b7053SJung-uk KimSSL_set_split_send_fragment() define how data is split up into pipelines when
66e71b7053SJung-uk Kimwriting encrypted data. The number of pipelines used will be determined by the
67e71b7053SJung-uk Kimamount of data provided to the SSL_write_ex() or SSL_write() call divided by
68e71b7053SJung-uk KimB<split_send_fragment>.
69e71b7053SJung-uk Kim
70e71b7053SJung-uk KimFor example if B<split_send_fragment> is set to 2000 and B<max_pipelines> is 4
71e71b7053SJung-uk Kimthen:
72e71b7053SJung-uk Kim
73e71b7053SJung-uk KimSSL_write/SSL_write_ex called with 0-2000 bytes == 1 pipeline used
74e71b7053SJung-uk Kim
75e71b7053SJung-uk KimSSL_write/SSL_write_ex called with 2001-4000 bytes == 2 pipelines used
76e71b7053SJung-uk Kim
77e71b7053SJung-uk KimSSL_write/SSL_write_ex called with 4001-6000 bytes == 3 pipelines used
78e71b7053SJung-uk Kim
79e71b7053SJung-uk KimSSL_write/SSL_write_ex called with 6001+ bytes == 4 pipelines used
80e71b7053SJung-uk Kim
81e71b7053SJung-uk KimB<split_send_fragment> must always be less than or equal to
82e71b7053SJung-uk KimB<max_send_fragment>. By default it is set to be equal to B<max_send_fragment>.
83e71b7053SJung-uk KimThis will mean that the same number of records will always be created as would
84e71b7053SJung-uk Kimhave been created in the non-parallel case, although the data will be
85e71b7053SJung-uk Kimapportioned differently. In the parallel case data will be spread equally
86e71b7053SJung-uk Kimbetween the pipelines.
87e71b7053SJung-uk Kim
88e71b7053SJung-uk KimRead pipelining is controlled in a slightly different way than with write
89e71b7053SJung-uk Kimpipelining. While reading we are constrained by the number of records that the
90e71b7053SJung-uk Kimpeer (and the network) can provide to us in one go. The more records we can get
91e71b7053SJung-uk Kimin one go the more opportunity we have to parallelise the processing. As noted
92e71b7053SJung-uk Kimabove when setting B<max_pipelines> to a value greater than one, B<read_ahead>
93e71b7053SJung-uk Kimis automatically set. The B<read_ahead> parameter causes OpenSSL to attempt to
94e71b7053SJung-uk Kimread as much data into the read buffer as the network can provide and will fit
95e71b7053SJung-uk Kiminto the buffer. Without this set data is read into the read buffer one record
96e71b7053SJung-uk Kimat a time. The more data that can be read, the more opportunity there is for
97e71b7053SJung-uk Kimparallelising the processing at the cost of increased memory overhead per
98e71b7053SJung-uk Kimconnection. Setting B<read_ahead> can impact the behaviour of the SSL_pending()
99*b077aed3SPierre Proncheryfunction (see L<SSL_pending(3)>). In addition the default size of the internal
100*b077aed3SPierre Proncheryread buffer is multiplied by the number of pipelines available to ensure that we
101*b077aed3SPierre Proncherycan read multiple records in one go. This can therefore have a significant
102*b077aed3SPierre Proncheryimpact on memory usage.
103e71b7053SJung-uk Kim
104e71b7053SJung-uk KimThe SSL_CTX_set_default_read_buffer_len() and SSL_set_default_read_buffer_len()
105e71b7053SJung-uk Kimfunctions control the size of the read buffer that will be used. The B<len>
106e71b7053SJung-uk Kimparameter sets the size of the buffer. The value will only be used if it is
107e71b7053SJung-uk Kimgreater than the default that would have been used anyway. The normal default
108e71b7053SJung-uk Kimvalue depends on a number of factors but it will be at least
109e71b7053SJung-uk KimSSL3_RT_MAX_PLAIN_LENGTH + SSL3_RT_MAX_ENCRYPTED_OVERHEAD (16704) bytes.
110e71b7053SJung-uk Kim
111e71b7053SJung-uk KimSSL_CTX_set_tlsext_max_fragment_length() sets the default maximum fragment
112e71b7053SJung-uk Kimlength negotiation mode via value B<mode> to B<ctx>.
113e71b7053SJung-uk KimThis setting affects only SSL instances created after this function is called.
114e71b7053SJung-uk KimIt affects the client-side as only its side may initiate this extension use.
115e71b7053SJung-uk Kim
116e71b7053SJung-uk KimSSL_set_tlsext_max_fragment_length() sets the maximum fragment length
117e71b7053SJung-uk Kimnegotiation mode via value B<mode> to B<ssl>.
118e71b7053SJung-uk KimThis setting will be used during a handshake when extensions are exchanged
119e71b7053SJung-uk Kimbetween client and server.
120e71b7053SJung-uk KimSo it only affects SSL sessions created after this function is called.
121e71b7053SJung-uk KimIt affects the client-side as only its side may initiate this extension use.
122e71b7053SJung-uk Kim
123e71b7053SJung-uk KimSSL_SESSION_get_max_fragment_length() gets the maximum fragment length
124e71b7053SJung-uk Kimnegotiated in B<session>.
125e71b7053SJung-uk Kim
126e71b7053SJung-uk Kim=head1 RETURN VALUES
127e71b7053SJung-uk Kim
128e71b7053SJung-uk KimAll non-void functions return 1 on success and 0 on failure.
129e71b7053SJung-uk Kim
130e71b7053SJung-uk Kim=head1 NOTES
131e71b7053SJung-uk Kim
132e71b7053SJung-uk KimThe Maximum Fragment Length extension support is optional on the server side.
133e71b7053SJung-uk KimIf the server does not support this extension then
134e71b7053SJung-uk KimSSL_SESSION_get_max_fragment_length() will return:
135e71b7053SJung-uk KimTLSEXT_max_fragment_length_DISABLED.
136e71b7053SJung-uk Kim
137e71b7053SJung-uk KimThe following modes are available:
138e71b7053SJung-uk Kim
139e71b7053SJung-uk Kim=over 4
140e71b7053SJung-uk Kim
141e71b7053SJung-uk Kim=item TLSEXT_max_fragment_length_DISABLED
142e71b7053SJung-uk Kim
143e71b7053SJung-uk KimDisables Maximum Fragment Length Negotiation (default).
144e71b7053SJung-uk Kim
145e71b7053SJung-uk Kim=item TLSEXT_max_fragment_length_512
146e71b7053SJung-uk Kim
147e71b7053SJung-uk KimSets Maximum Fragment Length to 512 bytes.
148e71b7053SJung-uk Kim
149e71b7053SJung-uk Kim=item TLSEXT_max_fragment_length_1024
150e71b7053SJung-uk Kim
151e71b7053SJung-uk KimSets Maximum Fragment Length to 1024.
152e71b7053SJung-uk Kim
153e71b7053SJung-uk Kim=item TLSEXT_max_fragment_length_2048
154e71b7053SJung-uk Kim
155e71b7053SJung-uk KimSets Maximum Fragment Length to 2048.
156e71b7053SJung-uk Kim
157e71b7053SJung-uk Kim=item TLSEXT_max_fragment_length_4096
158e71b7053SJung-uk Kim
159e71b7053SJung-uk KimSets Maximum Fragment Length to 4096.
160e71b7053SJung-uk Kim
161e71b7053SJung-uk Kim=back
162e71b7053SJung-uk Kim
163e71b7053SJung-uk KimWith the exception of SSL_CTX_set_default_read_buffer_len()
164e71b7053SJung-uk KimSSL_set_default_read_buffer_len(), SSL_CTX_set_tlsext_max_fragment_length(),
165e71b7053SJung-uk KimSSL_set_tlsext_max_fragment_length() and SSL_SESSION_get_max_fragment_length()
166e71b7053SJung-uk Kimall these functions are implemented using macros.
167e71b7053SJung-uk Kim
168610a21fdSJung-uk Kim=head1 SEE ALSO
169610a21fdSJung-uk Kim
170*b077aed3SPierre ProncheryL<ssl(7)>,
171610a21fdSJung-uk KimL<SSL_CTX_set_read_ahead(3)>, L<SSL_pending(3)>
172610a21fdSJung-uk Kim
173e71b7053SJung-uk Kim=head1 HISTORY
174e71b7053SJung-uk Kim
175e71b7053SJung-uk KimThe SSL_CTX_set_max_pipelines(), SSL_set_max_pipelines(),
176e71b7053SJung-uk KimSSL_CTX_set_split_send_fragment(), SSL_set_split_send_fragment(),
177e71b7053SJung-uk KimSSL_CTX_set_default_read_buffer_len() and  SSL_set_default_read_buffer_len()
178e71b7053SJung-uk Kimfunctions were added in OpenSSL 1.1.0.
179e71b7053SJung-uk Kim
1806935a639SJung-uk KimThe SSL_CTX_set_tlsext_max_fragment_length(), SSL_set_tlsext_max_fragment_length()
1816935a639SJung-uk Kimand SSL_SESSION_get_max_fragment_length() functions were added in OpenSSL 1.1.1.
182e71b7053SJung-uk Kim
183e71b7053SJung-uk Kim=head1 COPYRIGHT
184e71b7053SJung-uk Kim
185*b077aed3SPierre ProncheryCopyright 2016-2023 The OpenSSL Project Authors. All Rights Reserved.
186e71b7053SJung-uk Kim
187*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
188e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
189e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
190e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
191e71b7053SJung-uk Kim
192e71b7053SJung-uk Kim=cut
193