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