New Russian TLS 1.2 implementation
[openssl.git] / ssl / statem / statem_local.h
1 /*
2  * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 /*****************************************************************************
11  *                                                                           *
12  * The following definitions are PRIVATE to the state machine. They should   *
13  * NOT be used outside of the state machine.                                 *
14  *                                                                           *
15  *****************************************************************************/
16
17 /* Max message length definitions */
18
19 /* The spec allows for a longer length than this, but we limit it */
20 #define HELLO_VERIFY_REQUEST_MAX_LENGTH 258
21 #define END_OF_EARLY_DATA_MAX_LENGTH    0
22 #define SERVER_HELLO_MAX_LENGTH         20000
23 #define HELLO_RETRY_REQUEST_MAX_LENGTH  20000
24 #define ENCRYPTED_EXTENSIONS_MAX_LENGTH 20000
25 #define SERVER_KEY_EXCH_MAX_LENGTH      102400
26 #define SERVER_HELLO_DONE_MAX_LENGTH    0
27 #define KEY_UPDATE_MAX_LENGTH           1
28 #define CCS_MAX_LENGTH                  1
29 /* Max should actually be 36 but we are generous */
30 #define FINISHED_MAX_LENGTH             64
31
32 /* Dummy message type */
33 #define SSL3_MT_DUMMY   -1
34
35 extern const unsigned char hrrrandom[];
36
37 /* Message processing return codes */
38 typedef enum {
39     /* Something bad happened */
40     MSG_PROCESS_ERROR,
41     /* We've finished reading - swap to writing */
42     MSG_PROCESS_FINISHED_READING,
43     /*
44      * We've completed the main processing of this message but there is some
45      * post processing to be done.
46      */
47     MSG_PROCESS_CONTINUE_PROCESSING,
48     /* We've finished this message - read the next message */
49     MSG_PROCESS_CONTINUE_READING
50 } MSG_PROCESS_RETURN;
51
52 typedef int (*confunc_f) (SSL *s, WPACKET *pkt);
53
54 int ssl3_take_mac(SSL *s);
55 int check_in_list(SSL *s, uint16_t group_id, const uint16_t *groups,
56                   size_t num_groups, int checkallow);
57 int create_synthetic_message_hash(SSL *s, const unsigned char *hashval,
58                                   size_t hashlen, const unsigned char *hrr,
59                                   size_t hrrlen);
60 int parse_ca_names(SSL *s, PACKET *pkt);
61 const STACK_OF(X509_NAME) *get_ca_names(SSL *s);
62 int construct_ca_names(SSL *s, const STACK_OF(X509_NAME) *ca_sk, WPACKET *pkt);
63 size_t construct_key_exchange_tbs(SSL *s, unsigned char **ptbs,
64                                   const void *param, size_t paramlen);
65
66 /*
67  * TLS/DTLS client state machine functions
68  */
69 int ossl_statem_client_read_transition(SSL *s, int mt);
70 WRITE_TRAN ossl_statem_client_write_transition(SSL *s);
71 WORK_STATE ossl_statem_client_pre_work(SSL *s, WORK_STATE wst);
72 WORK_STATE ossl_statem_client_post_work(SSL *s, WORK_STATE wst);
73 int ossl_statem_client_construct_message(SSL *s, WPACKET *pkt,
74                                          confunc_f *confunc, int *mt);
75 size_t ossl_statem_client_max_message_size(SSL *s);
76 MSG_PROCESS_RETURN ossl_statem_client_process_message(SSL *s, PACKET *pkt);
77 WORK_STATE ossl_statem_client_post_process_message(SSL *s, WORK_STATE wst);
78
79 /*
80  * TLS/DTLS server state machine functions
81  */
82 int ossl_statem_server_read_transition(SSL *s, int mt);
83 WRITE_TRAN ossl_statem_server_write_transition(SSL *s);
84 WORK_STATE ossl_statem_server_pre_work(SSL *s, WORK_STATE wst);
85 WORK_STATE ossl_statem_server_post_work(SSL *s, WORK_STATE wst);
86 int ossl_statem_server_construct_message(SSL *s, WPACKET *pkt,
87                                          confunc_f *confunc,int *mt);
88 size_t ossl_statem_server_max_message_size(SSL *s);
89 MSG_PROCESS_RETURN ossl_statem_server_process_message(SSL *s, PACKET *pkt);
90 WORK_STATE ossl_statem_server_post_process_message(SSL *s, WORK_STATE wst);
91
92 /* Functions for getting new message data */
93 __owur int tls_get_message_header(SSL *s, int *mt);
94 __owur int tls_get_message_body(SSL *s, size_t *len);
95 __owur int dtls_get_message(SSL *s, int *mt, size_t *len);
96
97 /* Message construction and processing functions */
98 __owur int tls_process_initial_server_flight(SSL *s);
99 __owur MSG_PROCESS_RETURN tls_process_change_cipher_spec(SSL *s, PACKET *pkt);
100 __owur MSG_PROCESS_RETURN tls_process_finished(SSL *s, PACKET *pkt);
101 __owur int tls_construct_change_cipher_spec(SSL *s, WPACKET *pkt);
102 __owur int dtls_construct_change_cipher_spec(SSL *s, WPACKET *pkt);
103
104 __owur int tls_construct_finished(SSL *s, WPACKET *pkt);
105 __owur int tls_construct_key_update(SSL *s, WPACKET *pkt);
106 __owur MSG_PROCESS_RETURN tls_process_key_update(SSL *s, PACKET *pkt);
107 __owur WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst, int clearbufs,
108                                        int stop);
109 __owur WORK_STATE dtls_wait_for_dry(SSL *s);
110
111 /* some client-only functions */
112 __owur int tls_construct_client_hello(SSL *s, WPACKET *pkt);
113 __owur MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt);
114 __owur MSG_PROCESS_RETURN tls_process_certificate_request(SSL *s, PACKET *pkt);
115 __owur MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt);
116 __owur int tls_process_cert_status_body(SSL *s, PACKET *pkt);
117 __owur MSG_PROCESS_RETURN tls_process_cert_status(SSL *s, PACKET *pkt);
118 __owur MSG_PROCESS_RETURN tls_process_server_done(SSL *s, PACKET *pkt);
119 __owur int tls_construct_cert_verify(SSL *s, WPACKET *pkt);
120 __owur WORK_STATE tls_prepare_client_certificate(SSL *s, WORK_STATE wst);
121 __owur int tls_construct_client_certificate(SSL *s, WPACKET *pkt);
122 __owur int ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey);
123 __owur int tls_construct_client_key_exchange(SSL *s, WPACKET *pkt);
124 __owur int tls_client_key_exchange_post_work(SSL *s);
125 __owur int tls_construct_cert_status_body(SSL *s, WPACKET *pkt);
126 __owur int tls_construct_cert_status(SSL *s, WPACKET *pkt);
127 __owur MSG_PROCESS_RETURN tls_process_key_exchange(SSL *s, PACKET *pkt);
128 __owur MSG_PROCESS_RETURN tls_process_server_certificate(SSL *s, PACKET *pkt);
129 __owur int ssl3_check_cert_and_algorithm(SSL *s);
130 #ifndef OPENSSL_NO_NEXTPROTONEG
131 __owur int tls_construct_next_proto(SSL *s, WPACKET *pkt);
132 #endif
133 __owur MSG_PROCESS_RETURN tls_process_hello_req(SSL *s, PACKET *pkt);
134 __owur MSG_PROCESS_RETURN dtls_process_hello_verify(SSL *s, PACKET *pkt);
135 __owur int tls_construct_end_of_early_data(SSL *s, WPACKET *pkt);
136
137 /* some server-only functions */
138 __owur MSG_PROCESS_RETURN tls_process_client_hello(SSL *s, PACKET *pkt);
139 __owur WORK_STATE tls_post_process_client_hello(SSL *s, WORK_STATE wst);
140 __owur int tls_construct_server_hello(SSL *s, WPACKET *pkt);
141 __owur int dtls_construct_hello_verify_request(SSL *s, WPACKET *pkt);
142 __owur int tls_construct_server_certificate(SSL *s, WPACKET *pkt);
143 __owur int tls_construct_server_key_exchange(SSL *s, WPACKET *pkt);
144 __owur int tls_construct_certificate_request(SSL *s, WPACKET *pkt);
145 __owur int tls_construct_server_done(SSL *s, WPACKET *pkt);
146 __owur MSG_PROCESS_RETURN tls_process_client_certificate(SSL *s, PACKET *pkt);
147 __owur MSG_PROCESS_RETURN tls_process_client_key_exchange(SSL *s, PACKET *pkt);
148 __owur WORK_STATE tls_post_process_client_key_exchange(SSL *s, WORK_STATE wst);
149 __owur MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt);
150 #ifndef OPENSSL_NO_NEXTPROTONEG
151 __owur MSG_PROCESS_RETURN tls_process_next_proto(SSL *s, PACKET *pkt);
152 #endif
153 __owur int tls_construct_new_session_ticket(SSL *s, WPACKET *pkt);
154 MSG_PROCESS_RETURN tls_process_end_of_early_data(SSL *s, PACKET *pkt);
155
156 #ifndef OPENSSL_NO_GOST
157 /* These functions are used in GOST18 CKE, both for client and server */
158 int gost18_cke_cipher_nid(const SSL *s);
159 int gost_ukm(const SSL *s, unsigned char *dgst_buf);
160 #endif
161
162 /* Extension processing */
163
164 typedef enum ext_return_en {
165     EXT_RETURN_FAIL,
166     EXT_RETURN_SENT,
167     EXT_RETURN_NOT_SENT
168 } EXT_RETURN;
169
170 __owur int tls_validate_all_contexts(SSL *s, unsigned int thisctx,
171                                      RAW_EXTENSION *exts);
172 __owur int extension_is_relevant(SSL *s, unsigned int extctx,
173                                  unsigned int thisctx);
174 __owur int tls_collect_extensions(SSL *s, PACKET *packet, unsigned int context,
175                                   RAW_EXTENSION **res, size_t *len, int init);
176 __owur int tls_parse_extension(SSL *s, TLSEXT_INDEX idx, int context,
177                                RAW_EXTENSION *exts,  X509 *x, size_t chainidx);
178 __owur int tls_parse_all_extensions(SSL *s, int context, RAW_EXTENSION *exts,
179                                     X509 *x, size_t chainidx, int fin);
180 __owur int should_add_extension(SSL *s, unsigned int extctx,
181                                 unsigned int thisctx, int max_version);
182 __owur int tls_construct_extensions(SSL *s, WPACKET *pkt, unsigned int context,
183                                     X509 *x, size_t chainidx);
184
185 __owur int tls_psk_do_binder(SSL *s, const EVP_MD *md,
186                              const unsigned char *msgstart,
187                              size_t binderoffset, const unsigned char *binderin,
188                              unsigned char *binderout,
189                              SSL_SESSION *sess, int sign, int external);
190
191 /* Server Extension processing */
192 int tls_parse_ctos_renegotiate(SSL *s, PACKET *pkt, unsigned int context,
193                                X509 *x, size_t chainidx);
194 int tls_parse_ctos_server_name(SSL *s, PACKET *pkt, unsigned int context,
195                                X509 *x, size_t chainidx);
196 int tls_parse_ctos_maxfragmentlen(SSL *s, PACKET *pkt, unsigned int context,
197                                   X509 *x, size_t chainidx);
198 #ifndef OPENSSL_NO_SRP
199 int tls_parse_ctos_srp(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
200                        size_t chainidx);
201 #endif
202 int tls_parse_ctos_early_data(SSL *s, PACKET *pkt, unsigned int context,
203                               X509 *x, size_t chainidx);
204 #ifndef OPENSSL_NO_EC
205 int tls_parse_ctos_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context,
206                                  X509 *x, size_t chainidx);
207 #endif
208 int tls_parse_ctos_supported_groups(SSL *s, PACKET *pkt, unsigned int context,
209                                     X509 *x, size_t chainidxl);
210 int tls_parse_ctos_session_ticket(SSL *s, PACKET *pkt, unsigned int context,
211                                   X509 *x, size_t chainidx);
212 int tls_parse_ctos_sig_algs_cert(SSL *s, PACKET *pkt, unsigned int context,
213                                  X509 *x, size_t chainidx);
214 int tls_parse_ctos_sig_algs(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
215                             size_t chainidx);
216 #ifndef OPENSSL_NO_OCSP
217 int tls_parse_ctos_status_request(SSL *s, PACKET *pkt, unsigned int context,
218                                   X509 *x, size_t chainidx);
219 #endif
220 #ifndef OPENSSL_NO_NEXTPROTONEG
221 int tls_parse_ctos_npn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
222                        size_t chainidx);
223 #endif
224 int tls_parse_ctos_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
225                         size_t chainidx);
226 #ifndef OPENSSL_NO_SRTP
227 int tls_parse_ctos_use_srtp(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
228                             size_t chainidx);
229 #endif
230 int tls_parse_ctos_etm(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
231                        size_t chainidx);
232 int tls_parse_ctos_key_share(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
233                              size_t chainidx);
234 int tls_parse_ctos_cookie(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
235                           size_t chainidx);
236 int tls_parse_ctos_ems(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
237                        size_t chainidx);
238 int tls_parse_ctos_psk_kex_modes(SSL *s, PACKET *pkt, unsigned int context,
239                                  X509 *x, size_t chainidx);
240 int tls_parse_ctos_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
241                        size_t chainidx);
242 int tls_parse_ctos_post_handshake_auth(SSL *, PACKET *pkt, unsigned int context,
243                                        X509 *x, size_t chainidx);
244
245 EXT_RETURN tls_construct_stoc_renegotiate(SSL *s, WPACKET *pkt,
246                                           unsigned int context, X509 *x,
247                                           size_t chainidx);
248 EXT_RETURN tls_construct_stoc_server_name(SSL *s, WPACKET *pkt,
249                                           unsigned int context, X509 *x,
250                                           size_t chainidx);
251 EXT_RETURN tls_construct_stoc_early_data(SSL *s, WPACKET *pkt,
252                                          unsigned int context, X509 *x,
253                                          size_t chainidx);
254 EXT_RETURN tls_construct_stoc_maxfragmentlen(SSL *s, WPACKET *pkt,
255                                              unsigned int context, X509 *x,
256                                              size_t chainidx);
257 #ifndef OPENSSL_NO_EC
258 EXT_RETURN tls_construct_stoc_ec_pt_formats(SSL *s, WPACKET *pkt,
259                                             unsigned int context, X509 *x,
260                                             size_t chainidx);
261 #endif
262 EXT_RETURN tls_construct_stoc_supported_groups(SSL *s, WPACKET *pkt,
263                                                unsigned int context, X509 *x,
264                                                size_t chainidx);
265 EXT_RETURN tls_construct_stoc_session_ticket(SSL *s, WPACKET *pkt,
266                                              unsigned int context, X509 *x,
267                                              size_t chainidx);
268 #ifndef OPENSSL_NO_OCSP
269 EXT_RETURN tls_construct_stoc_status_request(SSL *s, WPACKET *pkt,
270                                              unsigned int context, X509 *x,
271                                              size_t chainidx);
272 #endif
273 #ifndef OPENSSL_NO_NEXTPROTONEG
274 EXT_RETURN tls_construct_stoc_next_proto_neg(SSL *s, WPACKET *pkt,
275                                              unsigned int context, X509 *x,
276                                              size_t chainidx);
277 #endif
278 EXT_RETURN tls_construct_stoc_alpn(SSL *s, WPACKET *pkt, unsigned int context,
279                                    X509 *x, size_t chainidx);
280 #ifndef OPENSSL_NO_SRTP
281 EXT_RETURN tls_construct_stoc_use_srtp(SSL *s, WPACKET *pkt, unsigned int context,
282                                 X509 *x, size_t chainidx);
283 #endif
284 EXT_RETURN tls_construct_stoc_etm(SSL *s, WPACKET *pkt, unsigned int context,
285                                   X509 *x, size_t chainidx);
286 EXT_RETURN tls_construct_stoc_ems(SSL *s, WPACKET *pkt, unsigned int context,
287                                   X509 *x, size_t chainidx);
288 EXT_RETURN tls_construct_stoc_supported_versions(SSL *s, WPACKET *pkt,
289                                                  unsigned int context, X509 *x,
290                                                  size_t chainidx);
291 EXT_RETURN tls_construct_stoc_key_share(SSL *s, WPACKET *pkt,
292                                         unsigned int context, X509 *x,
293                                         size_t chainidx);
294 EXT_RETURN tls_construct_stoc_cookie(SSL *s, WPACKET *pkt, unsigned int context,
295                                      X509 *x, size_t chainidx);
296 /*
297  * Not in public headers as this is not an official extension. Only used when
298  * SSL_OP_CRYPTOPRO_TLSEXT_BUG is set.
299  */
300 #define TLSEXT_TYPE_cryptopro_bug      0xfde8
301 EXT_RETURN tls_construct_stoc_cryptopro_bug(SSL *s, WPACKET *pkt,
302                                             unsigned int context, X509 *x,
303                                             size_t chainidx);
304 EXT_RETURN tls_construct_stoc_psk(SSL *s, WPACKET *pkt, unsigned int context,
305                                   X509 *x, size_t chainidx);
306
307 /* Client Extension processing */
308 EXT_RETURN tls_construct_ctos_renegotiate(SSL *s, WPACKET *pkt, unsigned int context,
309                                    X509 *x, size_t chainidx);
310 EXT_RETURN tls_construct_ctos_server_name(SSL *s, WPACKET *pkt, unsigned int context,
311                                    X509 *x, size_t chainidx);
312 EXT_RETURN tls_construct_ctos_maxfragmentlen(SSL *s, WPACKET *pkt, unsigned int context,
313                                              X509 *x, size_t chainidx);
314 #ifndef OPENSSL_NO_SRP
315 EXT_RETURN tls_construct_ctos_srp(SSL *s, WPACKET *pkt, unsigned int context, X509 *x,
316                            size_t chainidx);
317 #endif
318 #ifndef OPENSSL_NO_EC
319 EXT_RETURN tls_construct_ctos_ec_pt_formats(SSL *s, WPACKET *pkt,
320                                             unsigned int context, X509 *x,
321                                             size_t chainidx);
322 #endif
323 EXT_RETURN tls_construct_ctos_supported_groups(SSL *s, WPACKET *pkt,
324                                                unsigned int context, X509 *x,
325                                                size_t chainidx);
326
327 EXT_RETURN tls_construct_ctos_early_data(SSL *s, WPACKET *pkt,
328                                          unsigned int context, X509 *x,
329                                          size_t chainidx);
330 EXT_RETURN tls_construct_ctos_session_ticket(SSL *s, WPACKET *pkt,
331                                              unsigned int context, X509 *x,
332                                              size_t chainidx);
333 EXT_RETURN tls_construct_ctos_sig_algs(SSL *s, WPACKET *pkt,
334                                        unsigned int context, X509 *x,
335                                        size_t chainidx);
336 #ifndef OPENSSL_NO_OCSP
337 EXT_RETURN tls_construct_ctos_status_request(SSL *s, WPACKET *pkt,
338                                              unsigned int context, X509 *x,
339                                              size_t chainidx);
340 #endif
341 #ifndef OPENSSL_NO_NEXTPROTONEG
342 EXT_RETURN tls_construct_ctos_npn(SSL *s, WPACKET *pkt, unsigned int context,
343                                   X509 *x, size_t chainidx);
344 #endif
345 EXT_RETURN tls_construct_ctos_alpn(SSL *s, WPACKET *pkt, unsigned int context,
346                                    X509 *x, size_t chainidx);
347 #ifndef OPENSSL_NO_SRTP
348 EXT_RETURN tls_construct_ctos_use_srtp(SSL *s, WPACKET *pkt, unsigned int context,
349                                        X509 *x, size_t chainidx);
350 #endif
351 EXT_RETURN tls_construct_ctos_etm(SSL *s, WPACKET *pkt, unsigned int context,
352                                   X509 *x, size_t chainidx);
353 #ifndef OPENSSL_NO_CT
354 EXT_RETURN tls_construct_ctos_sct(SSL *s, WPACKET *pkt, unsigned int context,
355                                   X509 *x, size_t chainidx);
356 #endif
357 EXT_RETURN tls_construct_ctos_ems(SSL *s, WPACKET *pkt, unsigned int context,
358                                   X509 *x, size_t chainidx);
359 EXT_RETURN tls_construct_ctos_supported_versions(SSL *s, WPACKET *pkt,
360                                                  unsigned int context, X509 *x,
361                                                  size_t chainidx);
362 EXT_RETURN tls_construct_ctos_key_share(SSL *s, WPACKET *pkt,
363                                         unsigned int context, X509 *x,
364                                         size_t chainidx);
365 EXT_RETURN tls_construct_ctos_psk_kex_modes(SSL *s, WPACKET *pkt,
366                                             unsigned int context, X509 *x,
367                                             size_t chainidx);
368 EXT_RETURN tls_construct_ctos_cookie(SSL *s, WPACKET *pkt, unsigned int context,
369                                      X509 *x, size_t chainidx);
370 EXT_RETURN tls_construct_ctos_padding(SSL *s, WPACKET *pkt,
371                                       unsigned int context, X509 *x,
372                                       size_t chainidx);
373 EXT_RETURN tls_construct_ctos_psk(SSL *s, WPACKET *pkt, unsigned int context,
374                                   X509 *x, size_t chainidx);
375 EXT_RETURN tls_construct_ctos_post_handshake_auth(SSL *s, WPACKET *pkt, unsigned int context,
376                                                   X509 *x, size_t chainidx);
377
378 int tls_parse_stoc_renegotiate(SSL *s, PACKET *pkt, unsigned int context,
379                                X509 *x, size_t chainidx);
380 int tls_parse_stoc_server_name(SSL *s, PACKET *pkt, unsigned int context,
381                                X509 *x, size_t chainidx);
382 int tls_parse_stoc_early_data(SSL *s, PACKET *pkt, unsigned int context,
383                               X509 *x, size_t chainidx);
384 int tls_parse_stoc_maxfragmentlen(SSL *s, PACKET *pkt, unsigned int context,
385                                   X509 *x, size_t chainidx);
386 #ifndef OPENSSL_NO_EC
387 int tls_parse_stoc_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context,
388                                  X509 *x, size_t chainidx);
389 #endif
390 int tls_parse_stoc_session_ticket(SSL *s, PACKET *pkt, unsigned int context,
391                                   X509 *x, size_t chainidx);
392 #ifndef OPENSSL_NO_OCSP
393 int tls_parse_stoc_status_request(SSL *s, PACKET *pkt, unsigned int context,
394                                   X509 *x, size_t chainidx);
395 #endif
396 #ifndef OPENSSL_NO_CT
397 int tls_parse_stoc_sct(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
398                        size_t chainidx);
399 #endif
400 #ifndef OPENSSL_NO_NEXTPROTONEG
401 int tls_parse_stoc_npn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
402                        size_t chainidx);
403 #endif
404 int tls_parse_stoc_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
405                         size_t chainidx);
406 #ifndef OPENSSL_NO_SRTP
407 int tls_parse_stoc_use_srtp(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
408                             size_t chainidx);
409 #endif
410 int tls_parse_stoc_etm(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
411                        size_t chainidx);
412 int tls_parse_stoc_ems(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
413                        size_t chainidx);
414 int tls_parse_stoc_supported_versions(SSL *s, PACKET *pkt, unsigned int context,
415                                       X509 *x, size_t chainidx);
416 int tls_parse_stoc_key_share(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
417                              size_t chainidx);
418 int tls_parse_stoc_cookie(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
419                        size_t chainidx);
420 int tls_parse_stoc_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
421                        size_t chainidx);
422
423 int tls_handle_alpn(SSL *s);
424
425 int tls13_save_handshake_digest_for_pha(SSL *s);
426 int tls13_restore_handshake_digest_for_pha(SSL *s);