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