From: Frédéric Lécaille Date: Mon, 27 Nov 2023 09:09:12 +0000 (+0100) Subject: REORG: quic: Move CRYPTO data buffer defintions to QUIC TLS module X-Git-Tag: v2.9-dev12~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae885b9b686f43d39c612ae4577877a90efa435d;p=thirdparty%2Fhaproxy.git REORG: quic: Move CRYPTO data buffer defintions to QUIC TLS module Move quic_crypto_buf struct definition from quic_conn-t.h to quic_tls-t.h. Also move its pool definition/declaration to quic_tls-t.h/quic_tls.c. --- diff --git a/include/haproxy/quic_conn-t.h b/include/haproxy/quic_conn-t.h index fb129f8b2b..b7eb7d44c8 100644 --- a/include/haproxy/quic_conn-t.h +++ b/include/haproxy/quic_conn-t.h @@ -195,8 +195,6 @@ enum quic_pkt_type { /* Size of the QUIC RX buffer for the connections */ #define QUIC_CONN_RX_BUFSZ (1UL << 16) -extern struct pool_head *pool_head_quic_crypto_buf; - struct quic_version { uint32_t num; const unsigned char *initial_salt; @@ -234,23 +232,9 @@ extern const struct quic_version *preferred_version; /* The QUIC packet numbers are 62-bits integers */ #define QUIC_MAX_PACKET_NUM ((1ULL << 62) - 1) -#define QUIC_CRYPTO_BUF_SHIFT 10 -#define QUIC_CRYPTO_BUF_MASK ((1UL << QUIC_CRYPTO_BUF_SHIFT) - 1) -/* The maximum allowed size of CRYPTO data buffer provided by the TLS stack. */ -#define QUIC_CRYPTO_BUF_SZ (1UL << QUIC_CRYPTO_BUF_SHIFT) /* 1 KB */ - /* The maximum number of bytes of CRYPTO data in flight during handshakes. */ #define QUIC_CRYPTO_IN_FLIGHT_MAX 4096 -/* - * CRYPTO buffer struct. - * Such buffers are used to send CRYPTO data. - */ -struct quic_crypto_buf { - unsigned char data[QUIC_CRYPTO_BUF_SZ]; - size_t sz; -}; - /* Crypto data stream (one by encryption level) */ struct quic_cstream { struct { diff --git a/include/haproxy/quic_tls-t.h b/include/haproxy/quic_tls-t.h index a83efe2799..edbbeeff5b 100644 --- a/include/haproxy/quic_tls-t.h +++ b/include/haproxy/quic_tls-t.h @@ -203,6 +203,22 @@ struct quic_tls_ctx { unsigned char flags; }; +#define QUIC_CRYPTO_BUF_SHIFT 10 +#define QUIC_CRYPTO_BUF_MASK ((1UL << QUIC_CRYPTO_BUF_SHIFT) - 1) +/* The maximum allowed size of CRYPTO data buffer provided by the TLS stack. */ +#define QUIC_CRYPTO_BUF_SZ (1UL << QUIC_CRYPTO_BUF_SHIFT) /* 1 KB */ + +extern struct pool_head *pool_head_quic_crypto_buf; + +/* + * CRYPTO buffer struct. + * Such buffers are used to send CRYPTO data. + */ +struct quic_crypto_buf { + unsigned char data[QUIC_CRYPTO_BUF_SZ]; + size_t sz; +}; + struct quic_enc_level { struct list list; /* Attach point to enqueue this encryption level during retransmissions */ diff --git a/src/quic_conn.c b/src/quic_conn.c index 2b175d83d5..334f7dccae 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -137,7 +137,6 @@ DECLARE_STATIC_POOL(pool_head_quic_cc_conn, "quic_cc_conn", sizeof(struct quic_c DECLARE_STATIC_POOL(pool_head_quic_cids, "quic_cids", sizeof(struct eb_root)); DECLARE_POOL(pool_head_quic_connection_id, "quic_connection_id", sizeof(struct quic_connection_id)); -DECLARE_POOL(pool_head_quic_crypto_buf, "quic_crypto_buf", sizeof(struct quic_crypto_buf)); DECLARE_STATIC_POOL(pool_head_quic_cstream, "quic_cstream", sizeof(struct quic_cstream)); struct task *quic_conn_app_io_cb(struct task *t, void *context, unsigned int state); diff --git a/src/quic_tls.c b/src/quic_tls.c index da25632e62..a75f012153 100644 --- a/src/quic_tls.c +++ b/src/quic_tls.c @@ -20,6 +20,8 @@ DECLARE_POOL(pool_head_quic_tls_secret, "quic_tls_secret", QUIC_TLS_SECRET_LEN); DECLARE_POOL(pool_head_quic_tls_iv, "quic_tls_iv", QUIC_TLS_IV_LEN); DECLARE_POOL(pool_head_quic_tls_key, "quic_tls_key", QUIC_TLS_KEY_LEN); +DECLARE_POOL(pool_head_quic_crypto_buf, "quic_crypto_buf", sizeof(struct quic_crypto_buf)); + /* Initial salt depending on QUIC version to derive client/server initial secrets. * This one is for draft-29 QUIC version. */