wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
server.h
Go to the documentation of this file.
1#ifndef WIRED_SERVER_SERVER_H
2#define WIRED_SERVER_SERVER_H
3
8#include "tls/keys/kuswitch/twogen.h"
11
23
25#define WIRED_SERVER_FLIGHT_MAX 2048
32#define WIRED_SERVER_TRANSCRIPT_MAX 16384
34#define WIRED_SERVER_DATAGRAM_MAX 1500
35
37enum {
42};
43
87
113
119
129
141 wired_server* s,
142 u64 max_data,
143 u64 max_streams_bidi,
144 u64 max_streams_uni,
145 u64 max_datagram_frame_size);
146
155
164
174int wired_server_recv_initial(wired_server* s, const u8* ch_msg, usz ch_len);
175
186
196 wired_server* s, const u8* server_random, const sdrv_flight_out* out);
197
207int wired_server_feed(wired_server* s, const u8* crypto_payload, usz len);
208
216
222
230
241
254
260
265
271int wired_server_run_handshake(wired_server* s, int max_iterations);
272
277
278#endif
RFC 9000 19.6 / 7.5: reassemble CRYPTO frames received in a Handshake (or Initial) packet payload int...
RFC 9001 4.1.2: after the client Finished verifies, the server completes the handshake: derive the ap...
RFC 8446 4 / RFC 9001 4: server-side handshake driver.
int wired_server_recv_initial(wired_server *s, const u8 *ch_msg, usz ch_len)
RFC 8446 4.4.1: fold a received ClientHello (TLS handshake message bytes) into the transcript,...
int wired_server_pump(wired_server *s)
One receive iteration: pull a datagram off the socket and feed it.
int wired_server_build_hrr(wired_server *s, wired_obuf *out)
RFC 8446 4.1.4: emit the HelloRetryRequest a just-received ClientHello1 without a usable (x25519) key...
int wired_server_feed(wired_server *s, const u8 *crypto_payload, usz len)
RFC 8446 4.4.4 / RFC 9001 4.1.2: drive the handshake with one received Handshake-packet CRYPTO payloa...
void wired_server_set_reset_token(wired_server *s, const u8 token[16])
Advertise this 16-byte stateless_reset_token (RFC 9000 10.3.1/18.2) for the server's handshake SCID i...
int wired_server_resumption_secret(const wired_server *s, u8 *out)
RFC 8446 4.6.1/7.1: resumption_master_secret = Derive-Secret(Master Secret, "res master",...
@ WIRED_SERVER_HS_CONFIRMED
client Finished verified, 1-RTT armed
Definition server.h:41
@ WIRED_SERVER_HS_CH_RECVD
ClientHello folded, flight not sent.
Definition server.h:39
@ WIRED_SERVER_HS_INITIAL
awaiting the ClientHello
Definition server.h:38
@ WIRED_SERVER_HS_FLIGHT_SENT
server flight sent, Handshake key ready
Definition server.h:40
int wired_server_is_confirmed(const wired_server *s)
1 once the client Finished verified and the handshake is confirmed.
void wired_server_set_keylog_path(wired_server *s, const char *path)
Set the NSS key log file path (SSLKEYLOGFILE format); 0 disables (the default).
int wired_server_listen(wired_server *s, u16 port)
Open a UDP socket bound to port and wait for the ClientHello.
int wired_server_build_flight(wired_server *s, const u8 *server_random, const sdrv_flight_out *out)
RFC 8446 4.4 / RFC 9001 4: build the server flight (ServerHello into out->sh, EncryptedExtensions||Ce...
void wired_server_init(wired_server *s, const wired_server_init_in *in)
Initialize the orchestrator with the server key material.
int wired_server_run_handshake(wired_server *s, int max_iterations)
Pump until confirmed or max_iterations is reached (bounded so a silent or hostile peer cannot wedge t...
void wired_server_close(wired_server *s)
Close the UDP socket and wipe the key schedule's retained secrets (RFC 8446 E.1.4: the exporter_maste...
int wired_server_early_send_keys(wired_server *s)
Derive and install the server's 1-RTT send keys before the client Finished arrives (0....
void wired_server_set_limits(wired_server *s, u64 max_data, u64 max_streams_bidi, u64 max_streams_uni, u64 max_datagram_frame_size)
Override the advertised transport-parameter limits (RFC 9000 18.2); a zero field keeps its built-in d...
int wired_server_early_data_used(const wired_server *s)
RFC 9001 4.6.1 / 9.2: whether the client's 0-RTT early data was accepted on this connection (the tick...
int wired_server_handshake_done(wired_server *s, wired_obuf *out)
RFC 9001 4.1.2 / RFC 9000 19.20: write the HANDSHAKE_DONE frame, at most once and only after confirma...
#define WIRED_SERVER_TRANSCRIPT_MAX
Capacity of the raw handshake transcript buffer in octets: ClientHello + ServerHello + the server Han...
Definition server.h:32
int wired_server_set_cids(wired_server *s, wired_span odcid, wired_span iscid)
RFC 9000 7.3: record the DCID of the client's first Initial (the ODCID the server echoes) and the ser...
Value-type views that fold the SDK's recurring argument shapes into single parameters,...
Key schedule state: the current stage, the Master Secret once reached, and the four traffic key sets ...
Definition keyschedule.h:30
Per-protection-level key store: one AES-128-GCM key set per level plus an installed flag.
Definition keyset.h:23
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
Destination for sdrv_build_server_flight: sh receives the ServerHello, hs the EncryptedExtensions || ...
Definition sdrv.h:457
A sockaddr_in6 laid out for the kernel (big-endian port; a 16-byte address that is either native IPv6...
Definition udp.h:22
Server handshake-completion state.
Definition complete.h:14
Growing output buffer view for variable-length results.
Definition span.h:54
server_priv_x25519/server_pub_x25519 are the static ECDHE pair; cert_seed is the ECDSA P-256 signing ...
Definition server.h:95
const u8 * ticket_key
RFC 8446 4.6.1: this server's session-ticket encryption key (TICKET_KEY_LEN bytes),...
Definition server.h:111
const u8 * server_pub_x25519
X25519 public, 32 bytes.
Definition server.h:97
const u8 * server_priv_x25519
X25519 private, 32 bytes.
Definition server.h:96
u64 now_secs
RFC 5280 4.1.2.5.1: see wired_srvboot_id.now_secs's doc – threaded here to sdrv's self-signed certifi...
Definition server.h:107
const u8 * cert_seed
ECDSA P-256 signing scalar, big-endian.
Definition server.h:98
usz chain_count
entries in chain; 0 = self-signed
Definition server.h:100
const u8 * san_ipv4
RFC 5280 4.2.1.6: see wired_srvboot_id.san_ipv4's doc – threaded here to sdrv's self-signed certifica...
Definition server.h:103
const wired_span * chain
optional: external chain, leaf first
Definition server.h:99
Server-side handshake orchestrator state, initialized by wired_server_init.
Definition server.h:46
u8 ku_secret[TLS_HASH_MAX]
current generation's client_ap secret, needed to derive the next generation
Definition server.h:71
u8 client_random[32]
ClientHello.random (RFC 8446 4.1.2), recorded by wired_server_recv_initial for keylog lines.
Definition server.h:66
usz tr_through_sh
transcript length through ServerHello
Definition server.h:59
keysched sched
RFC 8446 7.1 order-driven key schedule.
Definition server.h:50
srvfin_state fin
client-Finished verification state
Definition server.h:52
usz tr_through_flight
transcript length through server Finished
Definition server.h:60
u8 server_priv[32]
RFC 7748 x25519 private (owns the ECDHE).
Definition server.h:56
int phase
WIRED_SERVER_HS_*.
Definition server.h:54
sockaddr peer
the client's UDP address (set by pump)
Definition server.h:48
i64 fd
UDP socket; <0 until a socket is opened.
Definition server.h:47
int hs_done_sent
HANDSHAKE_DONE emitted (at most once).
Definition server.h:55
usz tr_through_client_fin
RFC 8446 4.6.1/7.1: transcript length through the verified client Finished – ClientHello....
Definition server.h:61
u64 ku_send_count
RFC 9001 6.6: 1-RTT packets sealed under ku_send's current generation; reset on every rotation,...
Definition server.h:82
const char * keylog_path
NSS key log file path, or 0 to disable.
Definition server.h:68
u8 tr[WIRED_SERVER_TRANSCRIPT_MAX]
raw handshake transcript bytes
Definition server.h:57
u64 ku_auth_fail
RFC 9001 6.6: received 1-RTT packets that failed to open under any retained generation,...
Definition server.h:85
usz tr_len
bytes through the latest folded message
Definition server.h:58
kuswitch_state ku
RFC 9001 6: CLIENT_AP (peer-driven, recv-side) 1-RTT key generations.
Definition server.h:69
crecv crecv
CRYPTO stream reassembly buffer.
Definition server.h:53
sdrv sdrv
server-side TLS handshake driver
Definition server.h:49
kuswitch_state ku_send
RFC 9001 6.2: SERVER_AP (send-side) generations, kept in lockstep with ku so a confirmed peer update ...
Definition server.h:73
keyset keys
per-protection-level QUIC key sets
Definition server.h:51
u8 ku_send_secret[TLS_HASH_MAX]
current generation's server_ap secret
Definition server.h:77
int ku_seeded
1 once ku/ku_send hold real generation-0 keys
Definition server.h:79
Read-only view of a byte range.
Definition span.h:30
#define TLS_HASH_MAX
Largest Hash.length of any supported suite (SHA-384).
Definition suitehash.h:12
Linux direct syscalls.
long i64
signed 64-bit integer
Definition types.h:14
u64 usz
unsigned size (size_t equivalent)
Definition types.h:20
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
UDP via direct x86_64 syscalls, dual-stack (one AF_INET6 socket serves IPv6 natively and IPv4 as v4-m...