1#ifndef QUIC_SDRV_SDRV_H
2#define QUIC_SDRV_SDRV_H
6#include "tls/ext/salpn/negotiate.h"
7#include "tls/ext/salpn/sni_check.h"
8#include "tls/ext/stp/server_tp.h"
12#include "tls/keys/ticket/ticket.h"
RFC 8446 4.4.2/4.4.3: the Certificate and CertificateVerify handshake messages.
#define QUIC_TLS_CERT_CHAIN_MAX
Longest certificate_list this SDK walks (leaf + up to 9 issuers — public web chains are typically 2-3...
Definition cert.h:36
RFC 5869 HKDF over HMAC-SHA-256, plus the TLS 1.3 / QUIC HKDF-Expand-Label construction (RFC 8446 7....
#define QUIC_HKDF_PRK
pseudorandom key length
Definition hkdf.h:13
RFC 9001 5.2: Initial packet protection keys derived from the client's Destination Connection ID.
int quic_sdrv_recv_client_hello(quic_sdrv *s, const u8 *ch_msg, usz ch_len)
RFC 8446 4.4.1: fold the ClientHello into the transcript and take the client's x25519 key_share.
int quic_sdrv_set_cids_retried(quic_sdrv *s, quic_span odcid, quic_span iscid, quic_span true_odcid)
RFC 9000 7.3, post-Retry accept: odcid is the Initial-key derivation input (the Retry's own SCID – th...
int quic_sdrv_build_hrr(quic_sdrv *s, quic_obuf *out)
RFC 8446 4.1.4 / 4.4.1: build the HelloRetryRequest (requesting x25519, this driver's only supported ...
int quic_sdrv_hrr_pending(const quic_sdrv *s)
RFC 8446 4.1.4: 1 when the last quic_sdrv_recv_client_hello call found no x25519 key_share and a Hell...
int quic_sdrv_enforce_sni(quic_sdrv *s)
RFC 6066 3: opt-in enforcement of the last checked SNI outcome.
int quic_sdrv_set_retry_scid(quic_sdrv *s, quic_span rscid)
Record the Retry packet's SCID for the retry_source_connection_id transport parameter (RFC 9000 7....
int quic_sdrv_handshake_secret(const quic_sdrv *s, const u8 **secret)
Point *secret at the derived Handshake Secret (verification aid).
int quic_sdrv_set_cids(quic_sdrv *s, quic_span odcid, quic_span iscid)
RFC 9000 7.3: record the ODCID (the DCID of the client's first Initial) and the ISCID (the server's s...
quic_salpn_sni_outcome quic_sdrv_sni_outcome(const quic_sdrv *s)
RFC 6066 3: the outcome of checking the last ClientHello's server_name against this driver's own cert...
void quic_sdrv_init(quic_sdrv *s, const quic_sdrv_init_in *in)
Hold the server key material.
int quic_sdrv_early_keys(const quic_sdrv *s, quic_initial_keys *out)
RFC 8446 4.2.10 / RFC 9001 4.6.1: the 0-RTT packet-protection keys (client_early_traffic_secret's key...
int quic_sdrv_build_server_flight(quic_sdrv *s, const u8 *server_random, const quic_sdrv_flight_out *out)
RFC 8446 4.4: build the full server flight into out->sh / out->hs.
void quic_sdrv_set_group(quic_sdrv *s, u16 group)
RFC 8446 4.2.7: select the NamedGroup for the ECDHE key_share (QUIC_GROUP_X25519 or QUIC_GROUP_SECP25...
u64 quic_sdrv_last_error(const quic_sdrv *s)
RFC 9001 8.2 / RFC 9000 20.1: the CRYPTO_ERROR recorded by the last quic_sdrv_recv_client_hello call,...
Value-type views that fold the SDK's recurring argument shapes into single parameters,...
One direction's packet protection keys (RFC 9001 5.1/5.2).
Definition initial.h:28
Growing output buffer view for variable-length results.
Definition span.h:54
Destination for quic_sdrv_build_server_flight: sh receives the ServerHello, hs the EncryptedExtension...
Definition sdrv.h:327
quic_obuf * sh
receives the ServerHello
Definition sdrv.h:328
quic_obuf * hs
receives EncryptedExtensions || Certificate || CertificateVerify || Finished
Definition sdrv.h:329
Inputs to quic_sdrv_init.
Definition sdrv.h:183
u64 now_secs
RFC 5280 4.1.2.5.1: see wired_srvboot_id.now_secs's doc.
Definition sdrv.h:196
const u8 * san_ipv4
RFC 5280 4.2.1.6: see wired_srvboot_id.san_ipv4's doc.
Definition sdrv.h:192
const u8 * ticket_key
RFC 8446 4.6.1: this server's session-ticket encryption key (QUIC_TICKET_KEY_LEN bytes),...
Definition sdrv.h:200
const quic_span * chain
external chain, leaf first; NULL for self-signed mode (caller keeps the views alive through the hands...
Definition sdrv.h:187
usz chain_count
entries in chain; 0 = self-signed mode
Definition sdrv.h:190
const u8 * server_priv_x25519
ECDHE x25519 private (32 bytes).
Definition sdrv.h:184
const u8 * sign_priv
ECDSA P-256 signing scalar (32 bytes).
Definition sdrv.h:186
const u8 * server_pub_x25519
ECDHE x25519 public (32 bytes).
Definition sdrv.h:185
Server-side handshake driver state.
Definition sdrv.h:21
u8 client_sid_len
0..32
Definition sdrv.h:47
quic_salpn_choice alpn
RFC 7301 3.1/3.2: this server's negotiated ALPN protocol (h3 preferred, hq-interop fallback),...
Definition sdrv.h:125
int hrr_needed
RFC 8446 4.1.4: set by quic_sdrv_recv_client_hello when the ClientHello carried no x25519 key_share,...
Definition sdrv.h:149
int has_ticket_key
1 when ticket_key above is set; 0 disables resumption.
Definition sdrv.h:54
u8 rscid_len
bytes used in rscid; 0 = no Retry
Definition sdrv.h:95
int early_data_accepted
RFC 8446 4.2.10 / RFC 9001 4.6.1/9.2: set by quic_sdrv_recv_client_hello when the ClientHello carries...
Definition sdrv.h:69
u8 tp_odcid_len
bytes used in tp_odcid (0..20)
Definition sdrv.h:91
u16 group
RFC 8446 4.2.7 NamedGroup negotiated for the ECDHE key_share (QUIC_GROUP_X25519 or QUIC_GROUP_SECP256...
Definition sdrv.h:32
u8 ch1_hash[32]
RFC 8446 4.4.1: SHA-256(ClientHello1), computed when hrr_needed is set so quic_sdrv_build_hrr can fol...
Definition sdrv.h:161
u64 peer_initial_max_stream_data_bidi_remote
peer's initial_max_stream_data_bidi_remote (0x06, RFC 9000 18.2): the per-stream credit for bidi stre...
Definition sdrv.h:120
u8 odcid_len
bytes used in odcid (0..20)
Definition sdrv.h:83
u8 iscid_len
bytes used in iscid (0..20)
Definition sdrv.h:85
u8 client_pub[65]
RFC 8446 4.2.8 client key_share, group above.
Definition sdrv.h:45
u8 server_priv[32]
ECDHE private scalar (RFC 7748 x25519 or the P-256 SEC1 scalar, per group below); always 32 bytes for...
Definition sdrv.h:22
u8 p256_priv[32]
RFC 5480 ECDSA P-256 signing scalar; also the TBS signer for a self-built certificate.
Definition sdrv.h:33
u8 cert_buf[512]
self-signed P-256 cert DER (owned)
Definition sdrv.h:35
u8 psk_secret[QUIC_TICKET_SECRET_LEN]
The opened ticket's resumption secret; meaningful when psk_accepted.
Definition sdrv.h:61
int psk_accepted
RFC 8446 4.2.11/4.2.11.2: set by quic_sdrv_recv_client_hello when the ClientHello's pre_shared_key ti...
Definition sdrv.h:59
u64 peer_initial_max_stream_data_bidi_local
peer's initial_max_stream_data_bidi_local (0x05, RFC 9000 18.2): the TP sender's own locally-initiate...
Definition sdrv.h:108
u64 last_error
RFC 9001 8.2: the CRYPTO_ERROR (0x0100 | TLS alert) recorded when quic_sdrv_recv_client_hello rejects...
Definition sdrv.h:144
u8 odcid[20]
RFC 9001 5.2 Initial-key derivation input: the DCID of the Initial packet actually being processed ri...
Definition sdrv.h:82
u8 s_hs_traffic[QUIC_HKDF_PRK]
RFC 8446 7.1 server hs traffic secret.
Definition sdrv.h:74
u64 peer_initial_max_data
peer's initial_max_data (0x04, RFC 9000 18.2) from the ClientHello transport parameters – the connect...
Definition sdrv.h:102
u8 iscid[20]
RFC 9000 7.3 server SCID.
Definition sdrv.h:84
quic_initial_keys early_keys
RFC 8446 4.2.10 / RFC 9001 4.6.1: the 0-RTT packet-protection keys, meaningful only when early_data_a...
Definition sdrv.h:72
u8 tp_odcid[20]
RFC 9000 7.3 original_destination_connection_id transport parameter value: the true first Initial's D...
Definition sdrv.h:90
u16 cipher_suite
RFC 8446 B.4 / RFC 9001 9.3: this server's negotiated TLS 1.3 cipher suite (AES_128_GCM_ SHA256 prefe...
Definition sdrv.h:131
quic_span certs[QUIC_TLS_CERT_CHAIN_MAX]
RFC 8446 4.4.2 certificate_list, leaf first (caller-owned views in external-chain mode).
Definition sdrv.h:40
u8 ticket_key[QUIC_TICKET_KEY_LEN]
RFC 8446 4.6.1: this server's session-ticket encryption key, or has_ticket_key 0 to disable resumptio...
Definition sdrv.h:52
u8 client_sid[32]
RFC 8446 4.1.2 legacy_session_id.
Definition sdrv.h:46
u8 hs_secret[QUIC_HKDF_PRK]
RFC 8446 7.1 Handshake Secret.
Definition sdrv.h:73
u8 server_pub[65]
ECDHE public key_share: 32-byte RFC 7748 x25519, or 65-byte SEC1 uncompressed P-256 (RFC 8446 4....
Definition sdrv.h:25
usz cert_count
0 = nothing to send (flight build fails)
Definition sdrv.h:44
quic_stp_limits limits
advertised tunable limits (0 = defaults)
Definition sdrv.h:96
u16 hrr_cipher_suite
The cipher_suite negotiated from ClientHello1, recorded when hrr_sent becomes 1 so ClientHello2 can b...
Definition sdrv.h:157
u8 rscid[20]
RFC 9000 7.3 retry_source_connection_id – the Retry packet's SCID, advertised only when a Retry prece...
Definition sdrv.h:92
u8 san_ipv4[4]
RFC 5280 4.2.1.6: see wired_srvboot_id.san_ipv4's doc.
Definition sdrv.h:39
int hs_ready
hs_secret derived
Definition sdrv.h:75
quic_transcript tr
RFC 8446 4.4.1 Transcript-Hash.
Definition sdrv.h:76
quic_salpn_sni_outcome sni_outcome
RFC 6066 3: the ClientHello's server_name extension checked against this driver's own certificate (qu...
Definition sdrv.h:170
u64 peer_initial_max_stream_data_uni
peer's initial_max_stream_data_uni (0x07, RFC 9000 18.2): the per-stream credit for uni streams this ...
Definition sdrv.h:124
u64 peer_max_datagram_frame_size
peer's max_datagram_frame_size (0x20, RFC 9221 3) from the ClientHello transport parameters; 0 = not ...
Definition sdrv.h:97
int hrr_sent
1 once quic_sdrv_build_hrr has emitted a HelloRetryRequest for this connection; the next quic_sdrv_re...
Definition sdrv.h:154
Read-only view of a byte range.
Definition span.h:30
RFC 9000 18.2: the operator-tunable integer limits this server advertises; a zero field falls back to...
Definition server_tp.h:19
Cumulative Transcript-Hash state.
Definition transcript.h:10
u64 usz
unsigned size (size_t equivalent)
Definition syscall.h:19
unsigned short u16
unsigned 16-bit integer
Definition syscall.h:16
unsigned char u8
unsigned 8-bit integer / byte
Definition syscall.h:17
unsigned long u64
unsigned 64-bit integer
Definition syscall.h:12
RFC 8446 4.4.1: cumulative Transcript-Hash over handshake messages.