wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
twogen.h
1#ifndef QUIC_KUSWITCH_TWOGEN_H
2#define QUIC_KUSWITCH_TWOGEN_H
3
5
6/* RFC 9001 6.3/6.5: an endpoint keeps the current 1-RTT keys and, after a key
7 * update, the immediately prior keys, so packets in flight under the old key
8 * can still be decrypted until the retention period ends. A received packet's
9 * Key Phase bit selects which generation decrypts it. */
10
21
22/* Initialise at generation 0 with the first 1-RTT keys; no old key yet. */
23void quic_kuswitch_init(
24 quic_kuswitch_state* state, const quic_initial_keys* gen0);
25
26/* RFC 9001 6.3: advance to the next generation. The current keys become old
27 * (retained), and next becomes current; generation increments. */
28void quic_kuswitch_rotate(
29 quic_kuswitch_state* state, const quic_initial_keys* next);
30
31/* RFC 9001 6.3: choose the keys that decrypt a packet carrying recv_phase_bit.
32 * Returns 1 with *keys set when a matching generation is available, 0 when the
33 * bit asks for an old generation that is not (or no longer) retained. */
34int quic_kuswitch_key_for_phase(
35 const quic_kuswitch_state* state,
36 int recv_phase_bit,
37 const quic_initial_keys** keys);
38
39/* RFC 9001 6.5: drop the retained old key once its retention period ends. */
40void quic_kuswitch_discard_old(quic_kuswitch_state* state);
41
42#endif
RFC 9001 5.2: Initial packet protection keys derived from the client's Destination Connection ID.
One direction's packet protection keys (RFC 9001 5.1/5.2).
Definition initial.h:28
RFC 9001 6.3/6.5 two-generation key state: the current 1-RTT keys and, once a Key Update has happened...
Definition twogen.h:15
int have_old
1 while old is populated and retained
Definition twogen.h:19
quic_initial_keys old
prior generation's keys (valid when have_old)
Definition twogen.h:17
u64 generation
current send/receive generation, starts at 0
Definition twogen.h:18
quic_initial_keys cur
current generation's keys
Definition twogen.h:16
unsigned long u64
unsigned 64-bit integer
Definition syscall.h:12