wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
srvdemo.h File Reference

A fixed, deterministic server identity for samples and tests: the key bytes are a counting pattern, so every run presents the same self-signed certificate. More...

Go to the source code of this file.

Data Structures

struct  wired_srvboot_demo_keys
 Storage for the demo key material; wired_srvboot_id holds views into it, so it must outlive the server run (make it static). More...

Functions

void wired_srvboot_demo (wired_srvboot_id *id, wired_srvboot_demo_keys *k, u8 base, const char *scid)
 Reset id and fill it with the demo identity: priv[i] = base + i, seed[i] = base + 0x40 + i, rnd[i] = base + 0x60 + i, pub = X25519(priv), scid = the bytes of scid (at most 20).
int wired_srvboot_cert_sha256 (const wired_srvboot_id *id, u8 out[32])
 SHA-256 of the leaf certificate id presents: chain[0] when an external chain is set, otherwise the self-signed certificate built from cert_seed.
int wired_srvboot_log_fingerprint (i64 fd, const wired_srvboot_id *id)
 Log "cert sha-256 fingerprint: aa:bb:...\n" (colon-separated, the form browsers and openssl print) for id's leaf certificate to fd.

Detailed Description

A fixed, deterministic server identity for samples and tests: the key bytes are a counting pattern, so every run presents the same self-signed certificate.

Never use it for a real deployment.

Function Documentation

◆ wired_srvboot_cert_sha256()

int wired_srvboot_cert_sha256 ( const wired_srvboot_id * id,
u8 out[32] )

SHA-256 of the leaf certificate id presents: chain[0] when an external chain is set, otherwise the self-signed certificate built from cert_seed.

This is the value a browser's WebTransport serverCertificateHashes needs. Builds the certificate in a process-wide scratch server (not reentrant).

Parameters
idserver identity
out32-byte digest
Returns
1 ok, 0 if no certificate could be built

◆ wired_srvboot_demo()

void wired_srvboot_demo ( wired_srvboot_id * id,
wired_srvboot_demo_keys * k,
u8 base,
const char * scid )

Reset id and fill it with the demo identity: priv[i] = base + i, seed[i] = base + 0x40 + i, rnd[i] = base + 0x60 + i, pub = X25519(priv), scid = the bytes of scid (at most 20).

Every other field is 0, so the certificate is self-signed; set max_datagram_frame_size etc. afterwards.

Parameters
ididentity to fill
kkey storage; must outlive every use of id
basefirst byte of the counting pattern
scidNUL-terminated server connection id; must outlive id

◆ wired_srvboot_log_fingerprint()

int wired_srvboot_log_fingerprint ( i64 fd,
const wired_srvboot_id * id )

Log "cert sha-256 fingerprint: aa:bb:...\n" (colon-separated, the form browsers and openssl print) for id's leaf certificate to fd.

Parameters
fdfile descriptor (2 = stderr)
idserver identity
Returns
1 ok, 0 if no certificate could be built (nothing is logged)