wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
ticket.h
1#ifndef TICKET_TICKET_H
2#define 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/* Hash.length of the largest suite (SHA-384); a SHA-256 ticket uses the
12 * first 32 bytes. */
13#define TICKET_SECRET_LEN 48
14#define TICKET_KEY_LEN 32 /* ChaCha20-Poly1305 key (RFC 8439 2.8) */
15
16/* Sealed-ticket framing: nonce || ciphertext || tag. */
17#define TICKET_NONCE_LEN 12
18#define TICKET_TAG_LEN 16
19#define TICKET_PLAIN_LEN (TICKET_SECRET_LEN + 8 + 4 + 4 + 1 + 1 + 2)
20#define TICKET_SEALED_LEN (TICKET_NONCE_LEN + TICKET_PLAIN_LEN + TICKET_TAG_LEN)
21
40
41/* Seal a ticket under the server's fixed key: out receives
42 * TICKET_SEALED_LEN bytes (a fresh random nonce, then the encrypted
43 * ticket, then the auth tag). The nonce is drawn fresh per call so the same
44 * key never reuses a nonce. */
45void ticket_seal(const ticket* t, const u8 key[TICKET_KEY_LEN], u8* out);
46
47/* Open a sealed ticket produced by ticket_seal. in must span exactly
48 * TICKET_SEALED_LEN bytes. Returns 1 and fills *out on success; returns
49 * 0 (leaving *out untouched) if the key is wrong or the bytes were altered. */
50int ticket_open(wired_span in, const u8 key[TICKET_KEY_LEN], ticket* out);
51
52#endif
Value-type views that fold the SDK's recurring argument shapes into single parameters,...
One resumption ticket's plaintext contents (RFC 8446 4.6.1).
Definition ticket.h:23
u8 secret[TICKET_SECRET_LEN]
resumption master secret
Definition ticket.h:24
u32 lifetime_secs
ticket_lifetime (RFC 8446 4.6.1)
Definition ticket.h:26
u16 suite
RFC 8446 4.2.10/4.2.11: the issuing connection's cipher suite.
Definition ticket.h:38
u32 age_add
ticket_age_add (RFC 8446 4.6.1), random per ticket
Definition ticket.h:27
u64 issued_at
server clock at issuance
Definition ticket.h:25
u8 alpn
RFC 8446 4.2.10: the issuing connection's negotiated ALPN (a salpn_choice), so 0-RTT is only accepted...
Definition ticket.h:31
u8 ticket_nonce
RFC 8446 4.6.1: the ticket_nonce sent with this ticket, kept so the server derives the same PSK when ...
Definition ticket.h:34
Read-only view of a byte range.
Definition span.h:30
unsigned int u32
unsigned 32-bit integer
Definition types.h:15
unsigned short u16
unsigned 16-bit integer
Definition types.h:17
unsigned char u8
unsigned 8-bit integer / byte
Definition types.h:18
unsigned long u64
unsigned 64-bit integer
Definition types.h:13