wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
ticket.h
1#ifndef QUIC_TICKET_TICKET_H
2#define QUIC_TICKET_TICKET_H
3
5
6/* TLS 1.3 NewSessionTicket payload (RFC 8446 4.6.1), the part this SDK
7 * persists for session resumption: the resumption secret plus the fields
8 * needed to judge whether the ticket is still usable. Sealed opaque to the
9 * client; only the server ever parses this struct. */
10
11#define QUIC_TICKET_SECRET_LEN 32
12#define QUIC_TICKET_KEY_LEN 32 /* ChaCha20-Poly1305 key (RFC 8439 2.8) */
13
14/* Sealed-ticket framing: nonce || ciphertext || tag. */
15#define QUIC_TICKET_NONCE_LEN 12
16#define QUIC_TICKET_TAG_LEN 16
17#define QUIC_TICKET_PLAIN_LEN (QUIC_TICKET_SECRET_LEN + 8 + 4 + 4)
18#define QUIC_TICKET_SEALED_LEN \
19 (QUIC_TICKET_NONCE_LEN + QUIC_TICKET_PLAIN_LEN + QUIC_TICKET_TAG_LEN)
20
22typedef struct {
23 u8 secret[QUIC_TICKET_SECRET_LEN];
28
29/* Seal a ticket under the server's fixed key: out receives
30 * QUIC_TICKET_SEALED_LEN bytes (a fresh random nonce, then the encrypted
31 * ticket, then the auth tag). The nonce is drawn fresh per call so the same
32 * key never reuses a nonce. */
33void quic_ticket_seal(
34 const quic_ticket* t, const u8 key[QUIC_TICKET_KEY_LEN], u8* out);
35
36/* Open a sealed ticket produced by quic_ticket_seal. in must span exactly
37 * QUIC_TICKET_SEALED_LEN bytes. Returns 1 and fills *out on success; returns
38 * 0 (leaving *out untouched) if the key is wrong or the bytes were altered. */
39int quic_ticket_open(
40 quic_span in, const u8 key[QUIC_TICKET_KEY_LEN], quic_ticket* out);
41
42#endif
Value-type views that fold the SDK's recurring argument shapes into single parameters,...
Read-only view of a byte range.
Definition span.h:30
One resumption ticket's plaintext contents (RFC 8446 4.6.1).
Definition ticket.h:22
u8 secret[QUIC_TICKET_SECRET_LEN]
resumption master secret
Definition ticket.h:23
u32 lifetime_secs
ticket_lifetime (RFC 8446 4.6.1)
Definition ticket.h:25
u64 issued_at
server clock at issuance
Definition ticket.h:24
u32 age_add
ticket_age_add (RFC 8446 4.6.1), random per ticket
Definition ticket.h:26
unsigned int u32
unsigned 32-bit integer
Definition syscall.h:14
unsigned char u8
unsigned 8-bit integer / byte
Definition syscall.h:17
unsigned long u64
unsigned 64-bit integer
Definition syscall.h:12