2 * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #ifndef OSSL_QUIC_TYPES_H
11 # define OSSL_QUIC_TYPES_H
13 # include <openssl/ssl.h>
14 # include <internal/ssl.h>
18 # ifndef OPENSSL_NO_QUIC
20 /* QUIC encryption levels. */
21 # define QUIC_ENC_LEVEL_INITIAL 0
22 # define QUIC_ENC_LEVEL_HANDSHAKE 1
23 # define QUIC_ENC_LEVEL_0RTT 2
24 # define QUIC_ENC_LEVEL_1RTT 3
25 # define QUIC_ENC_LEVEL_NUM 4
27 /* QUIC packet number spaces. */
28 # define QUIC_PN_SPACE_INITIAL 0
29 # define QUIC_PN_SPACE_HANDSHAKE 1
30 # define QUIC_PN_SPACE_APP 2
31 # define QUIC_PN_SPACE_NUM 3
33 static ossl_unused ossl_inline uint32_t
34 ossl_quic_enc_level_to_pn_space(uint32_t enc_level)
37 case QUIC_ENC_LEVEL_INITIAL:
38 return QUIC_PN_SPACE_INITIAL;
39 case QUIC_ENC_LEVEL_HANDSHAKE:
40 return QUIC_PN_SPACE_HANDSHAKE;
41 case QUIC_ENC_LEVEL_0RTT:
42 case QUIC_ENC_LEVEL_1RTT:
43 return QUIC_PN_SPACE_APP;
46 return QUIC_PN_SPACE_APP;
50 /* QUIC packet number spaces. */
51 # define QUIC_PN_SPACE_INITIAL 0
52 # define QUIC_PN_SPACE_HANDSHAKE 1
53 # define QUIC_PN_SPACE_APP 2
54 # define QUIC_PN_SPACE_NUM 3
56 /* QUIC packet number representation. */
57 typedef uint64_t QUIC_PN;
58 # define QUIC_PN_INVALID UINT64_MAX
60 static ossl_unused ossl_inline QUIC_PN ossl_quic_pn_max(QUIC_PN a, QUIC_PN b)
65 static ossl_unused ossl_inline QUIC_PN ossl_quic_pn_min(QUIC_PN a, QUIC_PN b)
70 /* QUIC connection ID representation. */
71 # define QUIC_MAX_CONN_ID_LEN 20
73 typedef struct quic_conn_id_st {
74 unsigned char id_len, id[QUIC_MAX_CONN_ID_LEN];
77 static ossl_unused ossl_inline int ossl_quic_conn_id_eq(const QUIC_CONN_ID *a,
78 const QUIC_CONN_ID *b)
80 if (a->id_len != b->id_len || a->id_len > QUIC_MAX_CONN_ID_LEN)
82 return memcmp(a->id, b->id, a->id_len) == 0;
85 # define QUIC_MIN_INITIAL_DGRAM_LEN 1200
87 # define QUIC_DEFAULT_ACK_DELAY_EXP 3
88 # define QUIC_MAX_ACK_DELAY_EXP 20
90 # define QUIC_DEFAULT_MAX_ACK_DELAY 25
92 # define QUIC_MIN_ACTIVE_CONN_ID_LIMIT 2
94 /* Arbitrary choice of default idle timeout (not an RFC value). */
95 # define QUIC_DEFAULT_IDLE_TIMEOUT 30000
97 # define QUIC_STATELESS_RESET_TOKEN_LEN 16