lsquic_enc_sess.h revision f07b3eae
106b2a236SDmitri Tikhonov/* Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc.  See LICENSE. */
25392f7a3SLiteSpeed Tech#ifndef LSQUIC_ENC_SESS_H
35392f7a3SLiteSpeed Tech#define LSQUIC_ENC_SESS_H 1
45392f7a3SLiteSpeed Tech
5f07b3eaeSTyler Young#include "lsquic_shared_support.h"
6f07b3eaeSTyler Young
765728dc5SDmitri Tikhonovstruct lsquic_alarmset;
85392f7a3SLiteSpeed Techstruct lsquic_engine_public;
95392f7a3SLiteSpeed Techstruct lsquic_packet_out;
105392f7a3SLiteSpeed Techstruct lsquic_packet_in;
115392f7a3SLiteSpeed Techstruct stream_wrapper;
125392f7a3SLiteSpeed Techstruct ver_neg;
135392f7a3SLiteSpeed Techstruct lsquic_conn;
145392f7a3SLiteSpeed Techstruct transport_params;
155392f7a3SLiteSpeed Techstruct lsquic_cid;
165392f7a3SLiteSpeed Techstruct ssl_stream_method_st;
175392f7a3SLiteSpeed Techstruct ssl_st;
185392f7a3SLiteSpeed Techstruct sockaddr;
195392f7a3SLiteSpeed Techstruct conn_cid_elem;
2004f8f447SDmitri Tikhonovstruct lsquic_engine_settings;
2104f8f447SDmitri Tikhonovenum lsquic_version;
225392f7a3SLiteSpeed Tech
235392f7a3SLiteSpeed Tech#define DNONC_LENGTH 32
245392f7a3SLiteSpeed Tech#define SRST_LENGTH 16
255392f7a3SLiteSpeed Tech
265392f7a3SLiteSpeed Tech/* From [draft-ietf-quic-tls-14]:
275392f7a3SLiteSpeed Tech *
285392f7a3SLiteSpeed Tech * Data is protected using a number of encryption levels:
295392f7a3SLiteSpeed Tech *
305392f7a3SLiteSpeed Tech * o  Plaintext
315392f7a3SLiteSpeed Tech *
325392f7a3SLiteSpeed Tech * o  Early Data (0-RTT) Keys
335392f7a3SLiteSpeed Tech *
345392f7a3SLiteSpeed Tech * o  Handshake Keys
355392f7a3SLiteSpeed Tech *
365392f7a3SLiteSpeed Tech * o  Application Data (1-RTT) Keys
375392f7a3SLiteSpeed Tech */
385392f7a3SLiteSpeed Tech
395392f7a3SLiteSpeed Tech/* This enum maps to the list above */
405392f7a3SLiteSpeed Techenum enc_level
415392f7a3SLiteSpeed Tech{
425392f7a3SLiteSpeed Tech    ENC_LEV_CLEAR,
435392f7a3SLiteSpeed Tech    ENC_LEV_EARLY,
445392f7a3SLiteSpeed Tech    ENC_LEV_INIT,
455392f7a3SLiteSpeed Tech    ENC_LEV_FORW,
465392f7a3SLiteSpeed Tech    N_ENC_LEVS
475392f7a3SLiteSpeed Tech};
485392f7a3SLiteSpeed Tech
495392f7a3SLiteSpeed Techenum handshake_error            /* TODO: rename this enum */
505392f7a3SLiteSpeed Tech{
515392f7a3SLiteSpeed Tech    DATA_NOT_ENOUGH = -2,
525392f7a3SLiteSpeed Tech    DATA_FORMAT_ERROR = -1,
535392f7a3SLiteSpeed Tech    HS_ERROR = -1,
545392f7a3SLiteSpeed Tech    DATA_NO_ERROR = 0,
555392f7a3SLiteSpeed Tech    HS_SHLO = 0,
565392f7a3SLiteSpeed Tech    HS_1RTT = 1,
575392f7a3SLiteSpeed Tech    HS_SREJ = 2,
585392f7a3SLiteSpeed Tech};
595392f7a3SLiteSpeed Tech
605392f7a3SLiteSpeed Tech#ifndef LSQUIC_KEEP_ENC_SESS_HISTORY
615392f7a3SLiteSpeed Tech#   ifndef NDEBUG
625392f7a3SLiteSpeed Tech#       define LSQUIC_KEEP_ENC_SESS_HISTORY 1
635392f7a3SLiteSpeed Tech#   else
645392f7a3SLiteSpeed Tech#       define LSQUIC_KEEP_ENC_SESS_HISTORY 0
655392f7a3SLiteSpeed Tech#   endif
665392f7a3SLiteSpeed Tech#endif
675392f7a3SLiteSpeed Tech
685392f7a3SLiteSpeed Tech#if LSQUIC_KEEP_ENC_SESS_HISTORY
695392f7a3SLiteSpeed Tech#define ESHIST_BITS 7
705392f7a3SLiteSpeed Tech#define ESHIST_MASK ((1 << ESHIST_BITS) - 1)
715392f7a3SLiteSpeed Tech#define ESHIST_STR_SIZE ((1 << ESHIST_BITS) + 1)
725392f7a3SLiteSpeed Tech#endif
735392f7a3SLiteSpeed Tech
745392f7a3SLiteSpeed Techenum enc_packout { ENCPA_OK, ENCPA_NOMEM, ENCPA_BADCRYPT, };
755392f7a3SLiteSpeed Tech
765392f7a3SLiteSpeed Techenum dec_packin {
775392f7a3SLiteSpeed Tech    DECPI_OK,
785392f7a3SLiteSpeed Tech    DECPI_NOMEM,
795392f7a3SLiteSpeed Tech    DECPI_TOO_SHORT,
805392f7a3SLiteSpeed Tech    DECPI_NOT_YET,
815392f7a3SLiteSpeed Tech    DECPI_BADCRYPT,
825392f7a3SLiteSpeed Tech    DECPI_VIOLATION,
835392f7a3SLiteSpeed Tech};
845392f7a3SLiteSpeed Tech
855392f7a3SLiteSpeed Techtypedef void enc_session_t;
865392f7a3SLiteSpeed Tech
875392f7a3SLiteSpeed Techstruct enc_session_funcs_common
885392f7a3SLiteSpeed Tech{
895392f7a3SLiteSpeed Tech    /* Global initialization: call once per implementation */
905392f7a3SLiteSpeed Tech    int (*esf_global_init)(int flags);
915392f7a3SLiteSpeed Tech
925392f7a3SLiteSpeed Tech    /* Global cleanup: call once per implementation */
935392f7a3SLiteSpeed Tech    void (*esf_global_cleanup) (void);
945392f7a3SLiteSpeed Tech
955392f7a3SLiteSpeed Tech    const char *
965392f7a3SLiteSpeed Tech    (*esf_cipher) (enc_session_t *);
975392f7a3SLiteSpeed Tech
985392f7a3SLiteSpeed Tech    int
995392f7a3SLiteSpeed Tech    (*esf_keysize) (enc_session_t *);
1005392f7a3SLiteSpeed Tech
1015392f7a3SLiteSpeed Tech    int
1025392f7a3SLiteSpeed Tech    (*esf_alg_keysize) (enc_session_t *);
1035392f7a3SLiteSpeed Tech
10438e83598SDmitri Tikhonov    const char *
10538e83598SDmitri Tikhonov    (*esf_get_sni) (enc_session_t *);
10638e83598SDmitri Tikhonov
107a137764bSDmitri Tikhonov    /* Need to pass lconn in encrypt and decrypt methods because enc_session
108a137764bSDmitri Tikhonov     * is allowed to be NULL for gQUIC.
109a137764bSDmitri Tikhonov     */
1105392f7a3SLiteSpeed Tech    enum enc_packout
1115392f7a3SLiteSpeed Tech    (*esf_encrypt_packet) (enc_session_t *, const struct lsquic_engine_public *,
1125392f7a3SLiteSpeed Tech        struct lsquic_conn *, struct lsquic_packet_out *);
1135392f7a3SLiteSpeed Tech
1145392f7a3SLiteSpeed Tech    enum dec_packin
1155392f7a3SLiteSpeed Tech    (*esf_decrypt_packet)(enc_session_t *, struct lsquic_engine_public *,
1165392f7a3SLiteSpeed Tech        const struct lsquic_conn *, struct lsquic_packet_in *);
1175392f7a3SLiteSpeed Tech
1185392f7a3SLiteSpeed Tech    struct stack_st_X509 *
1195392f7a3SLiteSpeed Tech    (*esf_get_server_cert_chain) (enc_session_t *);
1205392f7a3SLiteSpeed Tech
1215392f7a3SLiteSpeed Tech    int
1225392f7a3SLiteSpeed Tech    (*esf_verify_reset_token) (enc_session_t *, const unsigned char *, size_t);
1235392f7a3SLiteSpeed Tech
1245392f7a3SLiteSpeed Tech    int
1257483dee0SDmitri Tikhonov    (*esf_did_sess_resume_succeed) (enc_session_t *);
1265392f7a3SLiteSpeed Tech
1275392f7a3SLiteSpeed Tech    int
1287483dee0SDmitri Tikhonov    (*esf_is_sess_resume_enabled) (enc_session_t *);
1295392f7a3SLiteSpeed Tech
130a137764bSDmitri Tikhonov    void
131a137764bSDmitri Tikhonov    (*esf_set_conn) (enc_session_t *, struct lsquic_conn *);
132a137764bSDmitri Tikhonov
133da99665bSDmitri Tikhonov    /* Optional.  This function gets called after packets are encrypted,
134da99665bSDmitri Tikhonov     * batched, and are about to be sent.
135da99665bSDmitri Tikhonov     */
136da99665bSDmitri Tikhonov    void
137da99665bSDmitri Tikhonov    (*esf_flush_encryption) (enc_session_t *);
138da99665bSDmitri Tikhonov
1395392f7a3SLiteSpeed Tech    unsigned
1405392f7a3SLiteSpeed Tech    esf_tag_len;
1415392f7a3SLiteSpeed Tech};
1425392f7a3SLiteSpeed Tech
1435392f7a3SLiteSpeed Techstruct enc_session_funcs_gquic
1445392f7a3SLiteSpeed Tech{
1455392f7a3SLiteSpeed Tech#if LSQUIC_KEEP_ENC_SESS_HISTORY
1465392f7a3SLiteSpeed Tech    /* Grab encryption session history */
1475392f7a3SLiteSpeed Tech    void (*esf_get_hist) (enc_session_t *,
1485392f7a3SLiteSpeed Tech                                            char buf[ESHIST_STR_SIZE]);
1495392f7a3SLiteSpeed Tech#endif
1505392f7a3SLiteSpeed Tech
1515392f7a3SLiteSpeed Tech    /* Destroy enc session */
1525392f7a3SLiteSpeed Tech    void (*esf_destroy)(enc_session_t *enc_session);
1535392f7a3SLiteSpeed Tech
1545392f7a3SLiteSpeed Tech    /* Return true if handshake has been completed */
1555392f7a3SLiteSpeed Tech    int (*esf_is_hsk_done)(enc_session_t *enc_session);
1565392f7a3SLiteSpeed Tech
1575392f7a3SLiteSpeed Tech    /* Get value of setting specified by `tag' */
1585392f7a3SLiteSpeed Tech    int (*esf_get_peer_setting) (enc_session_t *, uint32_t tag,
1595392f7a3SLiteSpeed Tech                                                                uint32_t *val);
1605392f7a3SLiteSpeed Tech
1615392f7a3SLiteSpeed Tech    /* Get value of peer option (that from COPT array) */
1625392f7a3SLiteSpeed Tech    int (*esf_get_peer_option) (enc_session_t *enc_session,
1635392f7a3SLiteSpeed Tech                                                                uint32_t tag);
1645392f7a3SLiteSpeed Tech
1655392f7a3SLiteSpeed Tech    /* Create server session */
1665392f7a3SLiteSpeed Tech    enc_session_t *
167a137764bSDmitri Tikhonov    (*esf_create_server) (struct lsquic_conn *,
1682f4629f2SDmitri Tikhonov                        lsquic_cid_t cid, struct lsquic_engine_public *);
1695392f7a3SLiteSpeed Tech
1705392f7a3SLiteSpeed Tech    /* out_len should have init value as the max length of out */
1715392f7a3SLiteSpeed Tech    enum handshake_error
1725392f7a3SLiteSpeed Tech    (*esf_handle_chlo) (enc_session_t *enc_session, enum lsquic_version,
1735392f7a3SLiteSpeed Tech                const uint8_t *in, int in_len, time_t t,
1745392f7a3SLiteSpeed Tech                const struct sockaddr *ip_addr, const struct sockaddr *local,
1755392f7a3SLiteSpeed Tech                uint8_t *out, size_t *out_len,
1765392f7a3SLiteSpeed Tech                uint8_t nonce[DNONC_LENGTH], int *nonce_set);
1775392f7a3SLiteSpeed Tech
1785392f7a3SLiteSpeed Tech    void (*esf_hsk_destroy)(void *hsk_ctx);
1795392f7a3SLiteSpeed Tech
1805392f7a3SLiteSpeed Tech#ifndef NDEBUG
1815392f7a3SLiteSpeed Tech    /* Need to expose this function for testing */
1825392f7a3SLiteSpeed Tech    int (*esf_determine_diversification_key) (enc_session_t *,
1837a8b2eceSDmitri Tikhonov                              uint8_t *diversification_nonce);
1845392f7a3SLiteSpeed Tech#endif
1855392f7a3SLiteSpeed Tech
1865392f7a3SLiteSpeed Tech    const char *
1875392f7a3SLiteSpeed Tech    (*esf_get_ua) (enc_session_t *);
1885392f7a3SLiteSpeed Tech
1895392f7a3SLiteSpeed Tech    int
1905392f7a3SLiteSpeed Tech    (*esf_have_key_gt_one) (enc_session_t *enc_session);
1915392f7a3SLiteSpeed Tech
1925392f7a3SLiteSpeed Tech#ifndef NDEBUG
1935392f7a3SLiteSpeed Tech    /* Functions that are only relevant in maintest.  We may want to get rid
1945392f7a3SLiteSpeed Tech     * of them somehow and only use the public API to test.
1955392f7a3SLiteSpeed Tech     */
1965392f7a3SLiteSpeed Tech
1975392f7a3SLiteSpeed Tech    uint8_t
1985392f7a3SLiteSpeed Tech    (*esf_have_key) (enc_session_t *);
1995392f7a3SLiteSpeed Tech
2005392f7a3SLiteSpeed Tech    void
2015392f7a3SLiteSpeed Tech    (*esf_set_have_key) (enc_session_t *, uint8_t);
2025392f7a3SLiteSpeed Tech
2035392f7a3SLiteSpeed Tech    const unsigned char *
2045392f7a3SLiteSpeed Tech    (*esf_get_enc_key_i) (enc_session_t *);
2055392f7a3SLiteSpeed Tech
2065392f7a3SLiteSpeed Tech    const unsigned char *
2075392f7a3SLiteSpeed Tech    (*esf_get_dec_key_i) (enc_session_t *);
2085392f7a3SLiteSpeed Tech
2095392f7a3SLiteSpeed Tech    const unsigned char *
2105392f7a3SLiteSpeed Tech    (*esf_get_enc_key_nonce_i) (enc_session_t *);
2115392f7a3SLiteSpeed Tech
2125392f7a3SLiteSpeed Tech    const unsigned char *
2135392f7a3SLiteSpeed Tech    (*esf_get_dec_key_nonce_i) (enc_session_t *);
2145392f7a3SLiteSpeed Tech
2155392f7a3SLiteSpeed Tech    const unsigned char *
2165392f7a3SLiteSpeed Tech    (*esf_get_enc_key_nonce_f) (enc_session_t *);
2175392f7a3SLiteSpeed Tech
2185392f7a3SLiteSpeed Tech    const unsigned char *
2195392f7a3SLiteSpeed Tech    (*esf_get_dec_key_nonce_f) (enc_session_t *);
2205392f7a3SLiteSpeed Tech#endif /* !defined(NDEBUG) */
2215392f7a3SLiteSpeed Tech
2225392f7a3SLiteSpeed Tech    /* Create client session */
2235392f7a3SLiteSpeed Tech    enc_session_t *
224a137764bSDmitri Tikhonov    (*esf_create_client) (struct lsquic_conn *, const char *domain,
225a137764bSDmitri Tikhonov                            lsquic_cid_t cid,
2262f4629f2SDmitri Tikhonov                                    struct lsquic_engine_public *,
2275392f7a3SLiteSpeed Tech                                    const unsigned char *, size_t);
2285392f7a3SLiteSpeed Tech
2295392f7a3SLiteSpeed Tech    /* -1 error, 0, OK, response in `buf' */
2305392f7a3SLiteSpeed Tech    int
2315392f7a3SLiteSpeed Tech    (*esf_gen_chlo) (enc_session_t *, enum lsquic_version,
2325392f7a3SLiteSpeed Tech                                                uint8_t *buf, size_t *len);
2335392f7a3SLiteSpeed Tech
2345392f7a3SLiteSpeed Tech    int
2355392f7a3SLiteSpeed Tech    (*esf_handle_chlo_reply) (enc_session_t *,
2365392f7a3SLiteSpeed Tech                                                const uint8_t *data, int len);
2375392f7a3SLiteSpeed Tech
2385392f7a3SLiteSpeed Tech    size_t
2395392f7a3SLiteSpeed Tech    (*esf_mem_used)(enc_session_t *);
2405392f7a3SLiteSpeed Tech
2417483dee0SDmitri Tikhonov    /* Session resumption serialization needs the knowledge of the QUIC
2427483dee0SDmitri Tikhonov     * version, that's why there is a separate method for thus.  Plus, we
2437483dee0SDmitri Tikhonov     * want to be able to call it after the "handshake is done" callback
2447483dee0SDmitri Tikhonov     * is called.
2455392f7a3SLiteSpeed Tech     */
2467483dee0SDmitri Tikhonov    void (*esf_maybe_dispatch_sess_resume) (enc_session_t *,
2475392f7a3SLiteSpeed Tech            void (*cb)(struct lsquic_conn *, const unsigned char *, size_t));
2485392f7a3SLiteSpeed Tech
2495392f7a3SLiteSpeed Tech    void (*esf_reset_cid) (enc_session_t *, const lsquic_cid_t *);
2505392f7a3SLiteSpeed Tech};
2515392f7a3SLiteSpeed Tech
2525392f7a3SLiteSpeed Techstruct crypto_stream_if
2535392f7a3SLiteSpeed Tech{
2545392f7a3SLiteSpeed Tech    ssize_t     (*csi_write) (void *stream, const void *buf, size_t len);
2555392f7a3SLiteSpeed Tech    int         (*csi_flush) (void *stream);
2565392f7a3SLiteSpeed Tech    ssize_t     (*csi_readf) (void *stream,
2575392f7a3SLiteSpeed Tech        size_t (*readf)(void *, const unsigned char *, size_t, int), void *ctx);
2585392f7a3SLiteSpeed Tech    int         (*csi_wantwrite) (void *stream, int is_want);
2595392f7a3SLiteSpeed Tech    int         (*csi_wantread) (void *stream, int is_want);
2605392f7a3SLiteSpeed Tech    enum enc_level
2615392f7a3SLiteSpeed Tech                (*csi_enc_level) (void *stream);
2625392f7a3SLiteSpeed Tech};
2635392f7a3SLiteSpeed Tech
2645392f7a3SLiteSpeed Techstruct enc_session_funcs_iquic
2655392f7a3SLiteSpeed Tech{
2665392f7a3SLiteSpeed Tech    enc_session_t *
2675392f7a3SLiteSpeed Tech    (*esfi_create_client) (const char *domain, struct lsquic_engine_public *,
2685392f7a3SLiteSpeed Tech                           struct lsquic_conn *, const struct lsquic_cid *,
2695392f7a3SLiteSpeed Tech                           const struct ver_neg *, void *(crypto_streams)[4],
2705392f7a3SLiteSpeed Tech                           const struct crypto_stream_if *,
27165728dc5SDmitri Tikhonov                           const unsigned char *, size_t,
27221bcad87Ssumasrao                           struct lsquic_alarmset *, unsigned, void*);
2735392f7a3SLiteSpeed Tech
2745392f7a3SLiteSpeed Tech    void
2755392f7a3SLiteSpeed Tech    (*esfi_destroy) (enc_session_t *);
2765392f7a3SLiteSpeed Tech
2775392f7a3SLiteSpeed Tech    struct ssl_st *
2785392f7a3SLiteSpeed Tech    (*esfi_get_ssl) (enc_session_t *);
2795392f7a3SLiteSpeed Tech
2805392f7a3SLiteSpeed Tech    struct transport_params *
2815392f7a3SLiteSpeed Tech    (*esfi_get_peer_transport_params) (enc_session_t *);
2825392f7a3SLiteSpeed Tech
2835392f7a3SLiteSpeed Tech    int
2845392f7a3SLiteSpeed Tech    (*esfi_reset_dcid) (enc_session_t *, const struct lsquic_cid *,
2855392f7a3SLiteSpeed Tech                                                const struct lsquic_cid *);
2865392f7a3SLiteSpeed Tech
287fb73393fSDmitri Tikhonov    void
288fb73393fSDmitri Tikhonov    (*esfi_set_iscid) (enc_session_t *, const struct lsquic_packet_in *);
289fb73393fSDmitri Tikhonov
2905392f7a3SLiteSpeed Tech    int
2915392f7a3SLiteSpeed Tech    (*esfi_init_server) (enc_session_t *);
2925392f7a3SLiteSpeed Tech
2935392f7a3SLiteSpeed Tech    void
2945392f7a3SLiteSpeed Tech    (*esfi_set_streams) (enc_session_t *, void *(crypto_streams)[4],
2955392f7a3SLiteSpeed Tech                           const struct crypto_stream_if *);
2965392f7a3SLiteSpeed Tech
2975392f7a3SLiteSpeed Tech    enc_session_t *
2985392f7a3SLiteSpeed Tech    (*esfi_create_server) (struct lsquic_engine_public *, struct lsquic_conn *,
2995392f7a3SLiteSpeed Tech                                                    const struct lsquic_cid *,
3005392f7a3SLiteSpeed Tech                           void *(crypto_streams)[4],
3015392f7a3SLiteSpeed Tech                           const struct crypto_stream_if *,
302fb73393fSDmitri Tikhonov                           const struct lsquic_cid *odcid,
30306b2a236SDmitri Tikhonov                           const struct lsquic_cid *iscid);
3045392f7a3SLiteSpeed Tech
3055392f7a3SLiteSpeed Tech    void
3065392f7a3SLiteSpeed Tech    (*esfi_shake_stream)(enc_session_t *, struct lsquic_stream *,
3075392f7a3SLiteSpeed Tech                         const char *);
3085392f7a3SLiteSpeed Tech
3095392f7a3SLiteSpeed Tech    void
3109fc12041SDmitri Tikhonov    (*esfi_handshake_confirmed)(enc_session_t *);
311e68b0452SDmitri Tikhonov
312e68b0452SDmitri Tikhonov    int
313e68b0452SDmitri Tikhonov    (*esfi_in_init)(enc_session_t *);
314e68b0452SDmitri Tikhonov
315e68b0452SDmitri Tikhonov    int
316e68b0452SDmitri Tikhonov    (*esfi_data_in)(enc_session_t *, enum enc_level,
317e68b0452SDmitri Tikhonov                                            const unsigned char *, size_t);
3185392f7a3SLiteSpeed Tech};
3195392f7a3SLiteSpeed Tech
320f07b3eaeSTyler YoungLSQUIC_EXTERN
3215392f7a3SLiteSpeed Tech#ifdef NDEBUG
3225392f7a3SLiteSpeed Techconst
3235392f7a3SLiteSpeed Tech#endif
3245392f7a3SLiteSpeed Techstruct enc_session_funcs_common lsquic_enc_session_common_gquic_1;
3257a8b2eceSDmitri Tikhonov
326f07b3eaeSTyler YoungLSQUIC_EXTERN
3277a8b2eceSDmitri Tikhonov#ifdef NDEBUG
3287a8b2eceSDmitri Tikhonovconst
3297a8b2eceSDmitri Tikhonov#endif
3307a8b2eceSDmitri Tikhonovstruct enc_session_funcs_common lsquic_enc_session_common_gquic_2;
3317a8b2eceSDmitri Tikhonov
332f07b3eaeSTyler YoungLSQUIC_EXTERN const struct enc_session_funcs_common lsquic_enc_session_common_ietf_v1;
3335392f7a3SLiteSpeed Tech
334f07b3eaeSTyler YoungLSQUIC_EXTERN
3355392f7a3SLiteSpeed Tech#ifdef NDEBUG
3365392f7a3SLiteSpeed Techconst
3375392f7a3SLiteSpeed Tech#endif
3385392f7a3SLiteSpeed Techstruct enc_session_funcs_gquic lsquic_enc_session_gquic_gquic_1;
3395392f7a3SLiteSpeed Tech
340f07b3eaeSTyler YoungLSQUIC_EXTERN const struct enc_session_funcs_iquic lsquic_enc_session_iquic_ietf_v1;
3415392f7a3SLiteSpeed Tech
3425392f7a3SLiteSpeed Tech#define select_esf_common_by_ver(ver) ( \
343bc520ef7SDmitri Tikhonov    ver == LSQVER_ID27 ? &lsquic_enc_session_common_ietf_v1 : \
3444051ae3aSDmitri Tikhonov    ver == LSQVER_ID29 ? &lsquic_enc_session_common_ietf_v1 : \
34526e8f082SDmitri Tikhonov    ver == LSQVER_I001 ? &lsquic_enc_session_common_ietf_v1 : \
3465392f7a3SLiteSpeed Tech    ver == LSQVER_VERNEG ? &lsquic_enc_session_common_ietf_v1 : \
3477a8b2eceSDmitri Tikhonov    ver == LSQVER_050 ? &lsquic_enc_session_common_gquic_2 : \
3485392f7a3SLiteSpeed Tech    &lsquic_enc_session_common_gquic_1 )
3495392f7a3SLiteSpeed Tech
3505392f7a3SLiteSpeed Tech#define select_esf_gquic_by_ver(ver) ( \
3515392f7a3SLiteSpeed Tech    ver ? &lsquic_enc_session_gquic_gquic_1 : &lsquic_enc_session_gquic_gquic_1)
3525392f7a3SLiteSpeed Tech
3535392f7a3SLiteSpeed Tech#define select_esf_iquic_by_ver(ver) ( \
3545392f7a3SLiteSpeed Tech    ver ? &lsquic_enc_session_iquic_ietf_v1 : &lsquic_enc_session_iquic_ietf_v1)
3555392f7a3SLiteSpeed Tech
3565392f7a3SLiteSpeed Techextern const char *const lsquic_enclev2str[];
3575392f7a3SLiteSpeed Tech
358f07b3eaeSTyler YoungLSQUIC_EXTERN const struct lsquic_stream_if lsquic_cry_sm_if;
3595392f7a3SLiteSpeed Tech
360f07b3eaeSTyler YoungLSQUIC_EXTERN const struct lsquic_stream_if lsquic_mini_cry_sm_if;
3615392f7a3SLiteSpeed Tech
3625392f7a3SLiteSpeed Tech/* RFC 7301, Section 3.2 */
3635392f7a3SLiteSpeed Tech#define ALERT_NO_APPLICATION_PROTOCOL 120
3645392f7a3SLiteSpeed Tech
3655392f7a3SLiteSpeed Techenum lsquic_version
3667483dee0SDmitri Tikhonovlsquic_sess_resume_version (const unsigned char *, size_t);
3675392f7a3SLiteSpeed Tech
3685392f7a3SLiteSpeed Tech/* This is seems to be true for all of the ciphers used by IETF QUIC.
3695392f7a3SLiteSpeed Tech * XXX: Perhaps add a check?
3705392f7a3SLiteSpeed Tech */
3715392f7a3SLiteSpeed Tech#define IQUIC_TAG_LEN 16
3725392f7a3SLiteSpeed Tech
37304f8f447SDmitri Tikhonov/* Return number of bytes written to `buf' or -1 on error */
37404f8f447SDmitri Tikhonovint
37504f8f447SDmitri Tikhonovlsquic_enc_sess_ietf_gen_quic_ctx (
37604f8f447SDmitri Tikhonov                const struct lsquic_engine_settings *settings,
37704f8f447SDmitri Tikhonov                enum lsquic_version version, unsigned char *buf, size_t bufsz);
37804f8f447SDmitri Tikhonov
3795392f7a3SLiteSpeed Tech#endif
380