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