2 * Copyright 2022-2023 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. */
22 QUIC_ENC_LEVEL_INITIAL
= 0,
23 QUIC_ENC_LEVEL_HANDSHAKE
,
26 QUIC_ENC_LEVEL_NUM
/* Must be the ultimate entry */
29 /* QUIC packet number spaces. */
31 QUIC_PN_SPACE_INITIAL
= 0,
32 QUIC_PN_SPACE_HANDSHAKE
,
33 /* New entries must go here, so that QUIC_PN_SPACE_APP is the penultimate */
35 QUIC_PN_SPACE_NUM
/* Must be the ultimate entry */
38 static ossl_unused ossl_inline
uint32_t
39 ossl_quic_enc_level_to_pn_space(uint32_t enc_level
)
42 case QUIC_ENC_LEVEL_INITIAL
:
43 return QUIC_PN_SPACE_INITIAL
;
44 case QUIC_ENC_LEVEL_HANDSHAKE
:
45 return QUIC_PN_SPACE_HANDSHAKE
;
46 case QUIC_ENC_LEVEL_0RTT
:
47 case QUIC_ENC_LEVEL_1RTT
:
48 return QUIC_PN_SPACE_APP
;
51 return QUIC_PN_SPACE_APP
;
55 /* QUIC packet number representation. */
56 typedef uint64_t QUIC_PN
;
57 # define QUIC_PN_INVALID UINT64_MAX
59 static ossl_unused ossl_inline QUIC_PN
ossl_quic_pn_max(QUIC_PN a
, QUIC_PN b
)
64 static ossl_unused ossl_inline QUIC_PN
ossl_quic_pn_min(QUIC_PN a
, QUIC_PN b
)
69 static ossl_unused ossl_inline
int ossl_quic_pn_valid(QUIC_PN pn
)
71 return pn
< (((QUIC_PN
)1) << 62);
74 /* QUIC connection ID representation. */
75 # define QUIC_MAX_CONN_ID_LEN 20
77 typedef struct quic_conn_id_st
{
78 unsigned char id_len
, id
[QUIC_MAX_CONN_ID_LEN
];
81 static ossl_unused ossl_inline
int ossl_quic_conn_id_eq(const QUIC_CONN_ID
*a
,
82 const QUIC_CONN_ID
*b
)
84 if (a
->id_len
!= b
->id_len
|| a
->id_len
> QUIC_MAX_CONN_ID_LEN
)
86 return memcmp(a
->id
, b
->id
, a
->id_len
) == 0;
89 # define QUIC_MIN_INITIAL_DGRAM_LEN 1200
91 # define QUIC_DEFAULT_ACK_DELAY_EXP 3
92 # define QUIC_MAX_ACK_DELAY_EXP 20
94 # define QUIC_DEFAULT_MAX_ACK_DELAY 25
96 # define QUIC_MIN_ACTIVE_CONN_ID_LIMIT 2
98 /* Arbitrary choice of default idle timeout (not an RFC value). */
99 # define QUIC_DEFAULT_IDLE_TIMEOUT 30000
101 # define QUIC_STATELESS_RESET_TOKEN_LEN 16
104 unsigned char token
[QUIC_STATELESS_RESET_TOKEN_LEN
];
105 } QUIC_STATELESS_RESET_TOKEN
;
108 * An encoded preferred_addr transport parameter cannot be shorter or longer
109 * than these lengths in bytes.
111 # define QUIC_MIN_ENCODED_PREFERRED_ADDR_LEN 41
112 # define QUIC_MAX_ENCODED_PREFERRED_ADDR_LEN 61