]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/lib/libcrypto/man/SSL_read_early_data.3
Import CK as of commit 5221ae2f3722a78c7fc41e47069ad94983d3bccb.
[FreeBSD/FreeBSD.git] / secure / lib / libcrypto / man / SSL_read_early_data.3
1 .\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is >0, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .if !\nF .nr F 0
58 .if \nF>0 \{\
59 .    de IX
60 .    tm Index:\\$1\t\\n%\t"\\$2"
61 ..
62 .    if !\nF==2 \{\
63 .        nr % 0
64 .        nr F 2
65 .    \}
66 .\}
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "SSL_READ_EARLY_DATA 3"
132 .TH SSL_READ_EARLY_DATA 3 "2018-09-11" "1.1.1" "OpenSSL"
133 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
134 .\" way too many mistakes in technical documents.
135 .if n .ad l
136 .nh
137 .SH "NAME"
138 SSL_set_max_early_data, SSL_CTX_set_max_early_data, SSL_get_max_early_data, SSL_CTX_get_max_early_data, SSL_set_recv_max_early_data, SSL_CTX_set_recv_max_early_data, SSL_get_recv_max_early_data, SSL_CTX_get_recv_max_early_data, SSL_SESSION_get_max_early_data, SSL_SESSION_set_max_early_data, SSL_write_early_data, SSL_read_early_data, SSL_get_early_data_status, SSL_allow_early_data_cb_fn, SSL_CTX_set_allow_early_data_cb, SSL_set_allow_early_data_cb \&\- functions for sending and receiving early data
139 .SH "SYNOPSIS"
140 .IX Header "SYNOPSIS"
141 .Vb 1
142 \& #include <openssl/ssl.h>
143 \&
144 \& int SSL_CTX_set_max_early_data(SSL_CTX *ctx, uint32_t max_early_data);
145 \& uint32_t SSL_CTX_get_max_early_data(const SSL_CTX *ctx);
146 \& int SSL_set_max_early_data(SSL *s, uint32_t max_early_data);
147 \& uint32_t SSL_get_max_early_data(const SSL *s);
148 \&
149 \& int SSL_CTX_set_recv_max_early_data(SSL_CTX *ctx, uint32_t recv_max_early_data);
150 \& uint32_t SSL_CTX_get_recv_max_early_data(const SSL_CTX *ctx);
151 \& int SSL_set_recv_max_early_data(SSL *s, uint32_t recv_max_early_data);
152 \& uint32_t SSL_get_recv_max_early_data(const SSL *s);
153 \&
154 \& uint32_t SSL_SESSION_get_max_early_data(const SSL_SESSION *s);
155 \& int SSL_SESSION_set_max_early_data(SSL_SESSION *s, uint32_t max_early_data);
156 \&
157 \& int SSL_write_early_data(SSL *s, const void *buf, size_t num, size_t *written);
158 \&
159 \& int SSL_read_early_data(SSL *s, void *buf, size_t num, size_t *readbytes);
160 \&
161 \& int SSL_get_early_data_status(const SSL *s);
162 \&
163 \&
164 \& typedef int (*SSL_allow_early_data_cb_fn)(SSL *s, void *arg);
165 \&
166 \& void SSL_CTX_set_allow_early_data_cb(SSL_CTX *ctx,
167 \&                                      SSL_allow_early_data_cb_fn cb,
168 \&                                      void *arg);
169 \& void SSL_set_allow_early_data_cb(SSL *s,
170 \&                                  SSL_allow_early_data_cb_fn cb,
171 \&                                  void *arg);
172 .Ve
173 .SH "DESCRIPTION"
174 .IX Header "DESCRIPTION"
175 These functions are used to send and receive early data where TLSv1.3 has been
176 negotiated. Early data can be sent by the client immediately after its initial
177 ClientHello without having to wait for the server to complete the handshake.
178 Early data can only be sent if a session has previously been established with
179 the server, and the server is known to support it. Additionally these functions
180 can be used to send data from the server to the client when the client has not
181 yet completed the authentication stage of the handshake.
182 .PP
183 Early data has weaker security properties than other data sent over an \s-1SSL/TLS\s0
184 connection. In particular the data does not have forward secrecy. There are also
185 additional considerations around replay attacks (see \*(L"\s-1REPLAY PROTECTION\*(R"\s0
186 below). For these reasons extreme care should be exercised when using early
187 data. For specific details, consult the \s-1TLS 1.3\s0 specification.
188 .PP
189 When a server receives early data it may opt to immediately respond by sending
190 application data back to the client. Data sent by the server at this stage is
191 done before the full handshake has been completed. Specifically the client's
192 authentication messages have not yet been received, i.e. the client is
193 unauthenticated at this point and care should be taken when using this
194 capability.
195 .PP
196 A server or client can determine whether the full handshake has been completed
197 or not by calling \fISSL_is_init_finished\fR\|(3).
198 .PP
199 On the client side, the function \fISSL_SESSION_get_max_early_data()\fR can be used to
200 determine if a session established with a server can be used to send early data.
201 If the session cannot be used then this function will return 0. Otherwise it
202 will return the maximum number of early data bytes that can be sent.
203 .PP
204 The function \fISSL_SESSION_set_max_early_data()\fR sets the maximum number of early
205 data bytes that can be sent for a session. This would typically be used when
206 creating a \s-1PSK\s0 session file (see \fISSL_CTX_set_psk_use_session_callback\fR\|(3)). If
207 using a ticket based \s-1PSK\s0 then this is set automatically to the value provided by
208 the server.
209 .PP
210 A client uses the function \fISSL_write_early_data()\fR to send early data. This
211 function is similar to the \fISSL_write_ex\fR\|(3) function, but with the following
212 differences. See \fISSL_write_ex\fR\|(3) for information on how to write bytes to
213 the underlying connection, and how to handle any errors that may arise. This 
214 page describes the differences between \fISSL_write_early_data()\fR and
215 \&\fISSL_write_ex\fR\|(3).
216 .PP
217 When called by a client, \fISSL_write_early_data()\fR must be the first \s-1IO\s0 function
218 called on a new connection, i.e. it must occur before any calls to
219 \&\fISSL_write_ex\fR\|(3), \fISSL_read_ex\fR\|(3), \fISSL_connect\fR\|(3), \fISSL_do_handshake\fR\|(3)
220 or other similar functions. It may be called multiple times to stream data to
221 the server, but the total number of bytes written must not exceed the value
222 returned from \fISSL_SESSION_get_max_early_data()\fR. Once the initial
223 \&\fISSL_write_early_data()\fR call has completed successfully the client may interleave
224 calls to \fISSL_read_ex\fR\|(3) and \fISSL_read\fR\|(3) with calls to
225 \&\fISSL_write_early_data()\fR as required.
226 .PP
227 If \fISSL_write_early_data()\fR fails you should call \fISSL_get_error\fR\|(3) to determine
228 the correct course of action, as for \fISSL_write_ex\fR\|(3).
229 .PP
230 When the client no longer wishes to send any more early data then it should
231 complete the handshake by calling a function such as \fISSL_connect\fR\|(3) or
232 \&\fISSL_do_handshake\fR\|(3). Alternatively you can call a standard write function
233 such as \fISSL_write_ex\fR\|(3), which will transparently complete the connection and
234 write the requested data.
235 .PP
236 A server may choose to ignore early data that has been sent to it. Once the
237 connection has been completed you can determine whether the server accepted or
238 rejected the early data by calling \fISSL_get_early_data_status()\fR. This will return
239 \&\s-1SSL_EARLY_DATA_ACCEPTED\s0 if the data was accepted, \s-1SSL_EARLY_DATA_REJECTED\s0 if it
240 was rejected or \s-1SSL_EARLY_DATA_NOT_SENT\s0 if no early data was sent. This function
241 may be called by either the client or the server.
242 .PP
243 A server uses the \fISSL_read_early_data()\fR function to receive early data on a
244 connection for which early data has been enabled using
245 \&\fISSL_CTX_set_max_early_data()\fR or \fISSL_set_max_early_data()\fR. As for
246 \&\fISSL_write_early_data()\fR, this must be the first \s-1IO\s0 function
247 called on a connection, i.e. it must occur before any calls to
248 \&\fISSL_write_ex\fR\|(3), \fISSL_read_ex\fR\|(3), \fISSL_accept\fR\|(3), \fISSL_do_handshake\fR\|(3),
249 or other similar functions.
250 .PP
251 \&\fISSL_read_early_data()\fR is similar to \fISSL_read_ex\fR\|(3) with the following
252 differences. Refer to \fISSL_read_ex\fR\|(3) for full details.
253 .PP
254 \&\fISSL_read_early_data()\fR may return 3 possible values:
255 .IP "\s-1SSL_READ_EARLY_DATA_ERROR\s0" 4
256 .IX Item "SSL_READ_EARLY_DATA_ERROR"
257 This indicates an \s-1IO\s0 or some other error occurred. This should be treated in the
258 same way as a 0 return value from \fISSL_read_ex\fR\|(3).
259 .IP "\s-1SSL_READ_EARLY_DATA_SUCCESS\s0" 4
260 .IX Item "SSL_READ_EARLY_DATA_SUCCESS"
261 This indicates that early data was successfully read. This should be treated in
262 the same way as a 1 return value from \fISSL_read_ex\fR\|(3). You should continue to
263 call \fISSL_read_early_data()\fR to read more data.
264 .IP "\s-1SSL_READ_EARLY_DATA_FINISH\s0" 4
265 .IX Item "SSL_READ_EARLY_DATA_FINISH"
266 This indicates that no more early data can be read. It may be returned on the
267 first call to \fISSL_read_early_data()\fR if the client has not sent any early data,
268 or if the early data was rejected.
269 .PP
270 Once the initial \fISSL_read_early_data()\fR call has completed successfully (i.e. it
271 has returned \s-1SSL_READ_EARLY_DATA_SUCCESS\s0 or \s-1SSL_READ_EARLY_DATA_FINISH\s0) then the
272 server may choose to write data immediately to the unauthenticated client using
273 \&\fISSL_write_early_data()\fR. If \fISSL_read_early_data()\fR returned
274 \&\s-1SSL_READ_EARLY_DATA_FINISH\s0 then in some situations (e.g. if the client only
275 supports TLSv1.2) the handshake may have already been completed and calls
276 to \fISSL_write_early_data()\fR are not allowed. Call \fISSL_is_init_finished\fR\|(3) to
277 determine whether the handshake has completed or not. If the handshake is still
278 in progress then the server may interleave calls to \fISSL_write_early_data()\fR with
279 calls to \fISSL_read_early_data()\fR as required.
280 .PP
281 Servers must not call \fISSL_read_ex\fR\|(3), \fISSL_read\fR\|(3), \fISSL_write_ex\fR\|(3) or
282 \&\fISSL_write\fR\|(3)  until \fISSL_read_early_data()\fR has returned with
283 \&\s-1SSL_READ_EARLY_DATA_FINISH.\s0 Once it has done so the connection to the client
284 still needs to be completed. Complete the connection by calling a function such
285 as \fISSL_accept\fR\|(3) or \fISSL_do_handshake\fR\|(3). Alternatively you can call a
286 standard read function such as \fISSL_read_ex\fR\|(3), which will transparently
287 complete the connection and read the requested data. Note that it is an error to
288 attempt to complete the connection before \fISSL_read_early_data()\fR has returned
289 \&\s-1SSL_READ_EARLY_DATA_FINISH.\s0
290 .PP
291 Only servers may call \fISSL_read_early_data()\fR.
292 .PP
293 Calls to \fISSL_read_early_data()\fR may, in certain circumstances, complete the
294 connection immediately without further need to call a function such as
295 \&\fISSL_accept\fR\|(3). This can happen if the client is using a protocol version less
296 than TLSv1.3. Applications can test for this by calling
297 \&\fISSL_is_init_finished\fR\|(3). Alternatively, applications may choose to call
298 \&\fISSL_accept\fR\|(3) anyway. Such a call will successfully return immediately with no
299 further action taken.
300 .PP
301 When a session is created between a server and a client the server will specify
302 the maximum amount of any early data that it will accept on any future
303 connection attempt. By default the server does not accept early data; a
304 server may indicate support for early data by calling
305 \&\fISSL_CTX_set_max_early_data()\fR or
306 \&\fISSL_set_max_early_data()\fR to set it for the whole \s-1SSL_CTX\s0 or an individual \s-1SSL\s0
307 object respectively. The \fBmax_early_data\fR parameter specifies the maximum
308 amount of early data in bytes that is permitted to be sent on a single
309 connection. Similarly the \fISSL_CTX_get_max_early_data()\fR and
310 \&\fISSL_get_max_early_data()\fR functions can be used to obtain the current maximum
311 early data settings for the \s-1SSL_CTX\s0 and \s-1SSL\s0 objects respectively. Generally a
312 server application will either use both of \fISSL_read_early_data()\fR and
313 \&\fISSL_CTX_set_max_early_data()\fR (or \fISSL_set_max_early_data()\fR), or neither of them,
314 since there is no practical benefit from using only one of them. If the maximum
315 early data setting for a server is non-zero then replay protection is
316 automatically enabled (see \*(L"\s-1REPLAY PROTECTION\*(R"\s0 below).
317 .PP
318 If the server rejects the early data sent by a client then it will skip over
319 the data that is sent. The maximum amount of received early data that is skipped
320 is controlled by the recv_max_early_data setting. If a client sends more than
321 this then the connection will abort. This value can be set by calling
322 \&\fISSL_CTX_set_recv_max_early_data()\fR or \fISSL_set_recv_max_early_data()\fR. The current
323 value for this setting can be obtained by calling
324 \&\fISSL_CTX_get_recv_max_early_data()\fR or \fISSL_get_recv_max_early_data()\fR. The default
325 value for this setting is 16,384 bytes.
326 .PP
327 The recv_max_early_data value also has an impact on early data that is accepted.
328 The amount of data that is accepted will always be the lower of the
329 max_early_data for the session and the recv_max_early_data setting for the
330 server. If a client sends more data than this then the connection will abort.
331 .PP
332 The configured value for max_early_data on a server may change over time as
333 required. However clients may have tickets containing the previously configured
334 max_early_data value. The recv_max_early_data should always be equal to or
335 higher than any recently configured max_early_data value in order to avoid
336 aborted connections. The recv_max_early_data should never be set to less than
337 the current configured max_early_data value.
338 .PP
339 Some server applications may wish to have more control over whether early data
340 is accepted or not, for example to mitigate replay risks (see \*(L"\s-1REPLAY PROTECTION\*(R"\s0
341 below) or to decline early_data when the server is heavily loaded. The functions
342 \&\fISSL_CTX_set_allow_early_data_cb()\fR and \fISSL_set_allow_early_data_cb()\fR set a
343 callback which is called at a point in the handshake immediately before a
344 decision is made to accept or reject early data. The callback is provided with a
345 pointer to the user data argument that was provided when the callback was first
346 set. Returning 1 from the callback will allow early data and returning 0 will
347 reject it. Note that the OpenSSL library may reject early data for other reasons
348 in which case this callback will not get called. Notably, the built-in replay
349 protection feature will still be used even if a callback is present unless it
350 has been explicitly disabled using the \s-1SSL_OP_NO_ANTI_REPLAY\s0 option. See
351 \&\*(L"\s-1REPLAY PROTECTION\*(R"\s0 below.
352 .SH "NOTES"
353 .IX Header "NOTES"
354 The whole purpose of early data is to enable a client to start sending data to
355 the server before a full round trip of network traffic has occurred. Application
356 developers should ensure they consider optimisation of the underlying \s-1TCP\s0 socket
357 to obtain a performant solution. For example Nagle's algorithm is commonly used
358 by operating systems in an attempt to avoid lots of small \s-1TCP\s0 packets. In many
359 scenarios this is beneficial for performance, but it does not work well with the
360 early data solution as implemented in OpenSSL. In Nagle's algorithm the \s-1OS\s0 will
361 buffer outgoing \s-1TCP\s0 data if a \s-1TCP\s0 packet has already been sent which we have not
362 yet received an \s-1ACK\s0 for from the peer. The buffered data will only be
363 transmitted if enough data to fill an entire \s-1TCP\s0 packet is accumulated, or if
364 the \s-1ACK\s0 is received from the peer. The initial ClientHello will be sent in the
365 first \s-1TCP\s0 packet along with any data from the first call to
366 \&\fISSL_write_early_data()\fR. If the amount of data written will exceed the size of a
367 single \s-1TCP\s0 packet, or if there are more calls to \fISSL_write_early_data()\fR then
368 that additional data will be sent in subsequent \s-1TCP\s0 packets which will be
369 buffered by the \s-1OS\s0 and not sent until an \s-1ACK\s0 is received for the first packet
370 containing the ClientHello. This means the early data is not actually
371 sent until a complete round trip with the server has occurred which defeats the
372 objective of early data.
373 .PP
374 In many operating systems the \s-1TCP_NODELAY\s0 socket option is available to disable
375 Nagle's algorithm. If an application opts to disable Nagle's algorithm
376 consideration should be given to turning it back on again after the handshake is
377 complete if appropriate.
378 .PP
379 In rare circumstances, it may be possible for a client to have a session that
380 reports a max early data value greater than 0, but where the server does not
381 support this. For example, this can occur if a server has had its configuration
382 changed to accept a lower max early data value such as by calling
383 \&\fISSL_CTX_set_recv_max_early_data()\fR. Another example is if a server used to
384 support TLSv1.3 but was later downgraded to TLSv1.2. Sending early data to such
385 a server will cause the connection to abort. Clients that encounter an aborted
386 connection while sending early data may want to retry the connection without
387 sending early data as this does not happen automatically. A client will have to
388 establish a new transport layer connection to the server and attempt the \s-1SSL/TLS\s0
389 connection again but without sending early data. Note that it is inadvisable to
390 retry with a lower maximum protocol version.
391 .SH "REPLAY PROTECTION"
392 .IX Header "REPLAY PROTECTION"
393 When early data is in use the \s-1TLS\s0 protocol provides no security guarantees that
394 the same early data was not replayed across multiple connections. As a
395 mitigation for this issue OpenSSL automatically enables replay protection if the
396 server is configured with a non-zero max early data value. With replay
397 protection enabled sessions are forced to be single use only. If a client
398 attempts to reuse a session ticket more than once, then the second and
399 subsequent attempts will fall back to a full handshake (and any early data that
400 was submitted will be ignored). Note that single use tickets are enforced even
401 if a client does not send any early data.
402 .PP
403 The replay protection mechanism relies on the internal OpenSSL server session
404 cache (see \fISSL_CTX_set_session_cache_mode\fR\|(3)). When replay protection is
405 being used the server will operate as if the \s-1SSL_OP_NO_TICKET\s0 option had been
406 selected (see \fISSL_CTX_set_options\fR\|(3)). Sessions will be added to the cache
407 whenever a session ticket is issued. When a client attempts to resume the
408 session, OpenSSL will check for its presence in the internal cache. If it exists
409 then the resumption is allowed and the session is removed from the cache. If it
410 does not exist then the resumption is not allowed and a full handshake will
411 occur.
412 .PP
413 Note that some applications may maintain an external cache of sessions (see
414 \&\fISSL_CTX_sess_set_new_cb\fR\|(3) and similar functions). It is the application's
415 responsibility to ensure that any sessions in the external cache are also
416 populated in the internal cache and that once removed from the internal cache
417 they are similarly removed from the external cache. Failing to do this could
418 result in an application becoming vulnerable to replay attacks. Note that
419 OpenSSL will lock the internal cache while a session is removed but that lock is
420 not held when the remove session callback (see \fISSL_CTX_sess_set_remove_cb\fR\|(3))
421 is called. This could result in a small amount of time where the session has
422 been removed from the internal cache but is still available in the external
423 cache. Applications should be designed with this in mind in order to minimise
424 the possibility of replay attacks.
425 .PP
426 The OpenSSL replay protection does not apply to external Pre Shared Keys (PSKs)
427 (e.g. see \fISSL_CTX_set_psk_find_session_callback\fR\|(3)). Therefore extreme caution
428 should be applied when combining external PSKs with early data.
429 .PP
430 Some applications may mitigate the replay risks in other ways. For those
431 applications it is possible to turn off the built-in replay protection feature
432 using the \fB\s-1SSL_OP_NO_ANTI_REPLAY\s0\fR option. See \fISSL_CTX_set_options\fR\|(3) for
433 details. Applications can also set a callback to make decisions about accepting
434 early data or not. See \fISSL_CTX_set_allow_early_data_cb()\fR above for details.
435 .SH "RETURN VALUES"
436 .IX Header "RETURN VALUES"
437 \&\fISSL_write_early_data()\fR returns 1 for success or 0 for failure. In the event of a
438 failure call \fISSL_get_error\fR\|(3) to determine the correct course of action.
439 .PP
440 \&\fISSL_read_early_data()\fR returns \s-1SSL_READ_EARLY_DATA_ERROR\s0 for failure,
441 \&\s-1SSL_READ_EARLY_DATA_SUCCESS\s0 for success with more data to read and
442 \&\s-1SSL_READ_EARLY_DATA_FINISH\s0 for success with no more to data be read. In the
443 event of a failure call \fISSL_get_error\fR\|(3) to determine the correct course of
444 action.
445 .PP
446 \&\fISSL_get_max_early_data()\fR, \fISSL_CTX_get_max_early_data()\fR and
447 \&\fISSL_SESSION_get_max_early_data()\fR return the maximum number of early data bytes
448 that may be sent.
449 .PP
450 \&\fISSL_set_max_early_data()\fR, \fISSL_CTX_set_max_early_data()\fR and
451 \&\fISSL_SESSION_set_max_early_data()\fR return 1 for success or 0 for failure.
452 .PP
453 \&\fISSL_get_early_data_status()\fR returns \s-1SSL_EARLY_DATA_ACCEPTED\s0 if early data was
454 accepted by the server, \s-1SSL_EARLY_DATA_REJECTED\s0 if early data was rejected by
455 the server, or \s-1SSL_EARLY_DATA_NOT_SENT\s0 if no early data was sent.
456 .SH "SEE ALSO"
457 .IX Header "SEE ALSO"
458 \&\fISSL_get_error\fR\|(3),
459 \&\fISSL_write_ex\fR\|(3),
460 \&\fISSL_read_ex\fR\|(3),
461 \&\fISSL_connect\fR\|(3),
462 \&\fISSL_accept\fR\|(3),
463 \&\fISSL_do_handshake\fR\|(3),
464 \&\fISSL_CTX_set_psk_use_session_callback\fR\|(3),
465 \&\fIssl\fR\|(7)
466 .SH "HISTORY"
467 .IX Header "HISTORY"
468 All of the functions described above were added in OpenSSL 1.1.1.
469 .SH "COPYRIGHT"
470 .IX Header "COPYRIGHT"
471 Copyright 2017\-2018 The OpenSSL Project Authors. All Rights Reserved.
472 .PP
473 Licensed under the OpenSSL license (the \*(L"License\*(R").  You may not use
474 this file except in compliance with the License.  You can obtain a copy
475 in the file \s-1LICENSE\s0 in the source distribution or at
476 <https://www.openssl.org/source/license.html>.