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