C99: Phase 4 eighth part (the connection runtime), WT-72 closed, WT-74 fixed
- Project Tracker: Phase 4 row to 7bab142 with the connection runtime and the
packet-level IPv4/IPv6 loopback result; WT-72 (padding) closed; WT-74 records
that a connection with no round trip sample armed no probe timeout and is fixed.
- Implementation Status: 35 test files and 75,163 checks, and the Phase 4 prose.
C99: Phase 4 seventh part (the UDP socket layer), WT-13/14/36 realised, tracker and status
- Project Tracker: Phase 4 row to d3eaacd with the socket layer; WT-13 and WT-14
(the POSIX surface and the feature-test policy) are now realised by the real
source rather than a probe; WT-36 (truncation) is implemented.
- Implementation Status: 34 test files and 74,872 checks, and the Phase 4 prose.
C99: WT-73, a failed AEAD tag is WT_ERR_AUTHENTICATION (fixed at 261c4e2)
C99: Phase 4 sixth part (the packet build/read seam), tracker row and WT-72
- Project Tracker: the Phase 4 row now names the wire seam and the latest commit
199cd2c; WT-72 records that the header protection sample sets a minimum packet
size, so the runtime must pad a tiny packet with a short packet number.
- Implementation Status: 33 test files and 74,692 checks, the Phase 4 prose and the
open-items range WT-3 to WT-72.
Record C99 Phase 4's fifth part: QUIC DATAGRAM and the close paths
RFC 9221's datagrams with their two-sided size rule and a bounded receive queue whose discard policy is
the newest, and RFC 9000 sections 10.2 and 19.19's two CONNECTION_CLOSE forms with the draining period.
32 test files, 74,544 checks.
Two things worth carrying forward. The two close forms are different messages -- the transport form
names the frame that caused the error and the application form cannot -- and the frame structure carries
a flag for that field rather than using zero, because PADDING is frame type zero and "no frame" is not
the same value. And the queue's discard policy is stated rather than implied: the newest goes, because
the application has already been told about everything in the queue and the freshest message is the one
that matters least for the traffic this carries.
Record C99 Phase 4's fourth part: the stream state machines and flow control
RFC 9000 sections 2, 3 and 4: both halves' state machines, the final size as the boundary that stops a
peer appending to a stream it has ended, RESET_STREAM and STOP_SENDING, and flow control at both
levels. 30 test files, 74,388 checks.
Two things worth carrying forward. Flow control counts offsets rather than delivered bytes -- a peer
that writes ten bytes at offset one million spends a million bytes of credit -- which is the RFC's
model and the opposite of what my first draft's documentation said, with the test catching the
contradiction. And a reset receive half had no way to become *read*, so a stream whose reset had
arrived could never be forgotten; RFC 9000 section 3.2 puts a state between the two for exactly that
reason, and the API now has it.
Record C99 Phase 4's third part: congestion control
RFC 9002 section 7's NewReno, with the recovery epoch as the idea the tests are mostly about: a burst
of losses has to cost one halving rather than one per packet, and an acknowledgement from before the
period must not grow the window during the recovery it is recovering from. 29 test files, 74,279
checks.
The finding worth carrying forward is about the increment: it is mds * acked / cwnd with integer
division, so a small acknowledgement adds nothing at all and a large one adds a fraction of a datagram
-- the "one datagram per round trip" is only true in aggregate over a window's worth of
acknowledgements, which is what the comments now say.
Record C99 Phase 4's second part: loss detection and probe timeouts
RFC 9002 section 6, with both thresholds pinned at their boundaries and the probe timeout's two easy
mistakes checked: it exists only while something ack-eliciting is in flight, and its backoff is reset
by acknowledging an ack-eliciting packet rather than by any acknowledgement. 28 test files, 74,191
checks.
The finding worth carrying forward was in the tests rather than the code: both thresholds are
inclusive comparisons, so an off-by-one in either direction is a test that passes for the wrong
reason -- which is why the boundary cases (three numbers higher and two, the threshold instant and
one microsecond inside it) are the ones written out.
Record C99 Phase 4's first part: the packet number space
The received set as a bounded range list, ACK construction, the acknowledgement debt and RFC 9002
section 5's RTT estimator, with 176 checks that include order-independence for the ranges and
hand-computed values for the arithmetic. 27 test files, 74,022 checks.
Two defects came out of that test and both were in the merging logic: a packet bridging a gap left
two ranges where the set has one, which would put a gap in an ACK frame that does not exist; and the
bound dropped the newest range instead of the oldest, because the list is kept largest-first. The
phase row now says what is done and what the runtime still owes.
Close WT-56 and point the tracker at Phase 4
WT-56 records Phase 3 in full: its seven parts, the vectors each is pinned to, and the seven
defects the tests found -- with the two that were invisible to a single half or a single platform
named, because those are the ones a reader of this tracker can learn from. Phase 4 is marked next
and the row says what it now has to work with: TLS is done, so the runtime feeds CRYPTO stream
bytes to the handshake and protects what it produces with the secrets handed back.
Record C99 Phase 3 complete: the server handshake, and the phase with it
The server mirrors the client's checks and order, the flight is two calls because QUIC has two
encryption levels, and one handshake between the two halves requires that the application secrets
each end derives are the other's in the opposite direction. 26 test files, 73,846 checks. WT-56
is closed and the phase row says so.
Two defects came out of that test and both were invisible to a single half: the ALPN extension
was written as a bare name where RFC 7301 defines a ProtocolNameList, so the client refused the
extension rather than the server; and walking a concatenation of handshake messages with the
header parser does not work, which is why a CRYPTO-stream walker now exists -- the QUIC runtime,
which is next, will need exactly that.
Record the leak the Linux leg found, and the contract that came out of fixing it
A failed or restarted C99 TLS handshake left the transcript's hash context allocated, which
LeakSanitizer on the Linux CI leg saw and the macOS configuration cannot. The fix produced a
contract worth stating: a failed machine holds nothing, beginning again is a fresh start, and
a caller-owned struct carries a marker so that 'is this live?' has one answer in every build.
The first attempt -- refusing to begin on a live machine -- was worse than the leak, because
whether an uninitialised struct counted as live depended on what the stack held.
Record C99 Phase 3's sixth part: the client handshake
The sequencing that consumes everything the earlier parts built, with the application secrets
available in no state before every security condition has been met. 25 test files, 73,756
checks. Driven end to end by RFC 8448's recorded flight, so the handshake secrets, the
application secrets and the client's Finished are the RFC's own.
What is worth carrying forward is the shape of the three defects that test found: all three
were one message out of step in the transcript. The Early Secret was never derived, the
handshake traffic secrets were read before the ServerHello was absorbed, and the client's
Finished was over a transcript that did not yet include the server's Finished. Each produces
secrets that are well formed and verify against nothing, and none of them is visible without a
recorded flight to compare against -- which is the argument for keeping the RFC's trace in the
suite rather than only fixtures this project writes itself.
Record C99 Phase 3's fifth part: peer authentication
Chain validation through OpenSSL and the CertificateVerify signature check, behind a
prompt-free policy that mirrors the Swift library's four modes -- including the development
bypass whose loopback restriction travels with the mode rather than sitting beside it as
advice. 24 test files, 73,677 checks.
The evidence worth carrying forward is that the strongest test uses one document end to end:
the transcript through RFC 8448's Certificate, the content a CertificateVerify signs built
from that hash, the public key extracted from the RFC's own certificate DER, and the RFC's
signature verified with it -- so the expected answer is a document rather than this code.
Two defects were found by running it: a failure path freed a certificate stack the caller also
freed, and the public key was written into the caller's buffer before its length was checked.
Record C99 Phase 3's fourth part: the certificate messages
Certificate, CertificateVerify and Finished as framing: a chain of DER views, a scheme
with a signature, and a body of exactly Hash.length bytes. Nothing is validated at that
layer, which is what lets the codec be pinned to RFC 8448's own certificate message byte
for byte. 23 test files, 73,601 checks.
One semantics change came out of it and is worth carrying forward: a read past the end of a
region whose length has already been validated is now a protocol error rather than
truncation. Every parser here is handed a complete message, so an inner length that
overruns is a length that lies, and that difference decides whether a receiver abandons the
connection or waits for more of it.
Record C99 Phase 3's third part: the X25519 key agreement
RFC 7748's primitive, key generation, the public key from a private key and the shared
secret, with an all-zero secret refused where it is computed. 23 test files, 73,569
checks.
Two things are worth carrying forward. The extractor implements the ladder from the same
document as an oracle and requires it to reproduce every published value before writing
one, which matters because section 6.1's Curve25519 labels are word for word the X448
labels directly below them. And the test ties two documents together: X25519(client
private, server public) must equal the ECDHE value RFC 8448's key schedule consumes, so
the key agreement and the schedule cannot disagree without a test saying so -- a property
neither document checks on its own.
Record C99 Phase 3's second part: the handshake messages and extensions
The four-byte framing, the extension list codec, the typed extensions a QUIC handshake
uses, and the ClientHello and ServerHello in both directions -- parsed into views,
re-encoded byte for byte from RFC 8448's own messages (unknown extensions included),
and built from parameters. 22 test files and 73,519 checks.
The shape worth carrying forward is the asymmetry between the two directions: a peer's
message is parsed into views because it is read once and used, while what we send is
built from parameters because those are values we chose. Both run the same body
function through the two-pass writer, so a length field cannot disagree with what
follows it, and the builders refuse rather than emit a message whose length lies. The
rest of Phase 3 -- the key share, certificate validation, the trust policy and the two
state machines -- is what the phase row still owes.
Record how Phase 3's test overflow was found: the compiler matrix, not the suite
Two refusal checks in the new key schedule test passed a 16-byte record-key buffer
where a 32-byte secret belongs. Every local run accepted it, because the functions
refuse before writing anything; ubuntu-24.04's GCC refused to compile it with
-Wstringop-overflow. Apple clang, Linux clang and both sanitizers missed it, so the
row now says which gate caught it.
Record C99 Phase 3's first part, and the derivation with no consumer
The TLS 1.3 key schedule and handshake transcript are in: RFC 8446 section 7.1's two
chains, the four traffic key sets, the Finished keys and verify data, and a running
transcript that reads its hash at each derivation without consuming it. The vectors
are RFC 8448 section 3's trace, re-derived before they are written and checked
against the handshake messages the trace prints, so the transcript is pinned to the
document as well as the schedule. The phase table says the phase is partly done and
names what remains.
WT-71 is added for the one thing the schedule derives that nothing uses: the
resumption master secret. Session tickets, PSKs and 0-RTT are not implemented, and
nothing in draft-16 requires them, so this is scope rather than a defect -- but the
derivation is tested and unconsumed, and the tracker should say so rather than leave
it to be discovered.
Also worth carrying: two of the extractor's three mistakes were the same shape as the
defects this project keeps finding, a value that could not express a distinction. A
value's hex straddles a page break, so "read until a blank line" stopped in the
middle of it; and a step kind the parser did not recognise let the step above it
swallow its values, which is how the server's abbreviated "res master" step read a
ticket nonce as its transcript hash. Both are now stated in the extractor where the
next person will read them.
Record C99 Phase 2, and the four defects in code nothing had run
The crypto provider and QUIC packet protection are complete: SHA-256, HMAC, HKDF,
AES-128-GCM and ChaCha20-Poly1305, then the Initial secret, the traffic-secret and
key-update derivations, the nonce, header protection and the payload seal and open.
The vectors are all of RFC 9001 appendix A, re-derived by the extractor before they
are written, and `C99/scripts/check-vectors.sh` now re-extracts them in CI so a
hand-edited vector fails there rather than quietly changing what a test proves.
The phase table says so, and WT-55 moves to Resolved.
What is worth carrying forward is that all four defects were in code that had never
been executed until this phase's tests called it, and that three of them were
contracts rather than arithmetic. `wt_aead_open` asked OpenSSL for a computed tag,
which its provider GCM cannot produce in decrypt mode -- so the contract became an
authenticated open that clears the plaintext, which is also the shape that cannot
be misused. HKDF-Expand passed its mode to EVP_KDF as a four-byte string, which that
parameter rejects, so every derivation in the library returned WT_ERR_UNSUPPORTED;
it is the RFC 5869 HMAC chain now. A SHA-256 context with no initialised marker
dereferenced the caller's array. And the installed package did not declare its
OpenSSL dependency, which no build inside the tree could have noticed.
Three rows are added rather than closed: the BearSSL/OpenSSL backend split the two
C99 bodies of work now meet at (WT-68), the key update lifecycle that Phase 2 named
and deliberately left to the runtime (WT-69), and the Retry integrity tag, which is
the one part of RFC 9001 section 5 neither phase covers (WT-70).
Record C99 Phase 1, and the three defects of one shape it found
The QUIC wire core is complete: varints, packet numbers, frames, packet headers,
transport parameters and connection ID retirement, with RFC vectors and a
deterministic malformed-input corpus. The tracker's phase table says so, and
WT-54 moves to Resolved.
What is worth carrying forward is the shape of three of the four defects. A range
walk reset its own count instead of accumulating it; a parameter lookup answered
with a pointer, so 'present with an empty value' and 'absent' were the same
answer; and a long header's reported size excluded the packet number it named.
Each is a value that could not express a distinction the protocol draws, and each
was found by a test that asked about the distinction rather than about the
arithmetic. The fourth -- a frame value type that was not fully initialised --
only failed at -O2, which is the argument for running all three build
configurations rather than Debug alone.
Record C99 Phase 0, and what each remaining phase owes
The C99 directory was described on four wiki pages as a plan and a skeleton. It is
now a build, a tested core, an installable package and a CI job, and the pages say
so -- with the draft-16 score left at 0%, because there is still no protocol code
and the score is about the protocol.
The tracker gains a phase table: all fourteen phases of IMPLEMENTATION_PLAN.md,
each with its status and a new reference, WT-54 to WT-67. Phase 0 is complete and
names the commit; Phase 9 and 10 are partly done and say which part; Phase 12 and
13 say what is on CI and what waits for the protocol. That is the honest reading
of 'complete' for a phase whose completion criteria include things that only make
sense once there is protocol code to test.
The check count is 1214, not 1208
Four checks were added after that number was written -- the ALPN wire-format
regression test, which is what pins the defect the independent fixture found, and
the two that drive a level outside the enum. The number on these pages is
supposed to be the number the suites report.
Write down the port's ten remaining tasks, and pause there
The handshake is done, merged and green in XAIOS CI. What is left of the port is
ten tasks, recorded here as WT-44 to WT-53, each naming the XAIOS tracker entry
that holds its detail and the exit criterion that would close it, in the order
they unblock each other.
Two of them are why this is a pause rather than a finish. Nothing on the target
drives the handshake from a socket yet, and there is no QUIC connection runtime
under it: the TLS module is handed messages that have already been reassembled
and in order, and nothing reassembles them. A handshake that works against a
fixture is not a connection, and saying so here is cheaper than implying
otherwise.
The other eight are the transport parameters still carried as opaque bytes, the
three protocol features not implemented (0-RTT and its session tickets, a
HelloRetryRequest, client certificates), and three pieces of evidence the work
does not have: no P-384 or P-521 certificate through the verifier, no RISC-V
build of the module, and two views that outlive their buffers by documented
contract rather than by construction.
Follow the XAIOS tracker's renumbering, and record that the port is on main
The port's XAIOS tracker rows were renumbered from B-61..B-70 to B-74..B-83,
because main had already taken B-61..B-73 for the RISC-V and CI work. The four
rows here that cite them now cite B-79, B-81, B-82 and B-83, and the rows no
longer say the work is unmerged: it is on XAIOS main as of 787622c.
The Implementation Status page says the same, and gains the two facts that make
the handshake checkable rather than merely present: the host suites now run in
CI, and the client completes a handshake against a server flight built by an
independent implementation.
Record the completed TLS 1.3 client handshake and what the audits found
WT-6 is answered: the client handshake is implemented in C99 on the XAIOS side
and completes against an independently generated QUIC server flight. The row now
says what is not implemented -- 0-RTT, session tickets, HelloRetryRequest and
client certificates -- rather than leaving that to the XAIOS tracker.
Four rows are added. WT-40 and WT-41 are the two memory-safety defects the work
found: a CertificateVerify digest buffer sized for SHA-256 while offering
SHA-512, and a public key that pointed into a dead decoder frame. WT-42 is the
ALPN extension read in a format RFC 7301 does not define, which would have
refused every conformant server's answer and which survived four audits because
nothing in either repository carried ALPN until an independent implementation
was made to disagree. WT-43 is that the host suites, over a thousand checks, were
run by no CI job at all.
The Implementation Status page is updated with the same three things: the trust
model is decided and implemented rather than proposed, the handshake is written
rather than outstanding, and the open-item range it names is corrected.
Record the XAIOS-side TLS 1.3 progress, and what is still missing
WT-6 is the P0 blocker for this port, so it should say what exists rather than
only that BearSSL has no TLS 1.3. The key schedule, QUIC traffic keys, Initial
secrets, Retry integrity tag and packet protection are implemented and checked
against RFC 8448 and RFC 9001 -- 329 host checks, with the vectors extracted
from the RFC text and two independent Python oracles recomputing them. Two
adversarial audits of that half found a remote stack overflow, a resumption
secret derived from the wrong transcript, an encoder using the wrong packet
number range and a decrypt path that failed on every packet; all four are fixed
and the fixes are pinned by tests.
What is not implemented is the handshake: no ClientHello, ServerHello,
extensions, Certificate, CertificateVerify or Finished. That is B-66 on the
XAIOS side, gated by B-67 -- nothing on XAIOS can yet decide whether to trust a
server certificate, which is a policy decision rather than missing code.
Record the XAIOS-side answer to WT-35 and WT-36, and the limit it found
WT-35 is implemented, tested and pushed on XAIOS's `webtransport` branch
(4ddd7d8, 56ed3fd), awaiting audit and merge to main. The row said the kernel
already handled datagram sends from a socket that has never received and that
this was "a small userspace/syscall addition"; the first half was right and the
second was not quite. Three defects were found by building the gate rather than
by reading the code, and they are named in the outcome because each one is the
kind that reads as correct:
- the chosen port travelled back through a field of the request structure, so
the caller read zero for exactly the case the call exists for;
- `kernel_socket_alloc` does not check for a port already held, so two
ephemeral opens could be handed one port and the reply lookup -- which
stops at the first match -- would leave the second unreachable and silent;
- the ephemeral counter wrapped at the top of `uint16_t` rather than of the
range, so one draw in 16384 handed out port 0 and reported "no port".
WT-36 is answered, and the answer is narrower than the row assumed. An
oversized datagram is dropped whole at the frame against the same bound the
read is clamped to, so a caller sizing its buffer at SOCKET_BUFFER_SIZE cannot
be truncated and needs no flag; the row's "maximum-datagram-size policy" is
already the behaviour. Truncation is still silent for a caller that asks for
less, and saying so needs a syscall change rather than a stack one, so the row
stays P2 with that stated rather than closed.
WT-39 is new: NETWORK_MAX_LISTENERS is 16 and serves TCP and UDP together, and
every datagram socket now registers a row, so a ceiling that previously took
sixteen deliberate binds is now on a path that does not ask for it. Nothing
here reaches it; it is recorded because WT-35 changed who is exposed to it.
Drop C++ from the wiki and resolve the two-tree item
The C++ port is gone from the repository, so the wiki no longer describes it.
Home, Implementation Status, Known Limitations and the Repository Guide now speak of a
single port target rather than two. The Repository Guide's generated-output rule no
longer names `CPP/out/`.
WT-11 is resolved rather than deleted. It recorded that the C99 and C++ trees were
independent, which was correct and is why removing the C++ tree left `C99/` intact —
worth keeping as the answer to a question someone will ask again.
The remaining mentions of C++ are the ones that matter: Implementation Status says
XAIOS has no C++ support and never will, and that its source contains zero C++
files. That is the constraint that drove the decision, not a description of a port.
Record the XAIOS inspection and the real blocker: no TLS 1.3
XAIOS was read directly rather than reasoned about. The C++ question is closed: 596 C
files, 239 headers, 58 assembly files, and zero C++ of any extension. A pure C99 port
needs no C++ toolchain and emits no C++ calls.
Three assumptions are now settled:
- libc is picolibc, built freestanding into a sysroot, so the configurable allocator
stands.
- The network stack is real and in-kernel (IPv4, IPv6, ARP, NDP, routing, three NIC
drivers), reached through a capability-checked syscall API rather than POSIX sockets.
xaios_net_sendto/recvfrom carry genuine datagrams with ARP resolution and a bounded
first-contact retry.
- OpenSSL is absent, so the plan's crypto dependency is wrong. XAIOS vendors BearSSL,
and its build script compiles every source with -std=c99 -ffreestanding -Werror, so
the whole library is available, not just the objects xapt reaches.
The decisive finding is WT-6, raised to P0: BearSSL has no TLS 1.3. The vendored copy is
explicitly for a TLS 1.2 client, bearssl_ssl.h defines BR_TLS10/11/12 with no BR_TLS13,
and there is no TLS 1.3 source anywhere in the tree. QUIC requires TLS 1.3, so the
handshake cannot be delegated. BearSSL does supply every primitive needed to write it —
AES-GCM, ChaCha20-Poly1305, HKDF, SHA-2, X25519, ECDSA and RSA-PSS verification — so the
crypto is solved and the handshake is the work.
Added WT-35 to WT-38 for what the inspection turned up: no userspace ephemeral UDP
socket creation, datagram truncation reporting unspecified, freestanding build
constraints, and the real network-stack layout. WT-12 narrowed to "pin or trust set",
since XAIOS already pins an operator-set RSA key for xapt.
Implementation Status now describes XAIOS from its source instead of describing a
hypothetical freestanding target.