Skip to content

libs/crypto: webcpp::crypto foundation increment 1, its third-party wiring and shared tooling - #35

Merged
pinhopro merged 65 commits into
mainfrom
crypto/foundation-1
Nov 19, 2026
Merged

pinhopro merged 65 commits into
mainfrom
crypto/foundation-1

Conversation

@pinhopro

Copy link
Copy Markdown
Contributor

What this brings

The superproject side of webcpp::crypto's foundation, increment 1: the libs/crypto gitlink (1fc5140), the backends' third-party wiring and the shared tooling the library needs.

Shared tools and CI changes (they affect every library)

  • third_party/Jamfile, .gitmodules: libsodium as /third_party//sodium (shared with webcpp::hash), ed25519-speccheck vectors.
  • tools/webcpp.jam, tools/variants/: crypto's per-family defaults, refusals naming their Jamfile line, release-built size tables for plain linked programs on every target.
  • tools/ci/matrix.py, .github/workflows/library.yml: a library's own lanes (crypto's constant-time lanes, the Linux container lane).
  • tools/lint/lint.sh: the lint reads the own lanes' sanitizer and Valgrind headers; tools/compile_diagnostic/.
  • tools/openssl/build.py, tools/libdatachannel/build.py and their jam rules: build.json is a declared output written last and atomically, so an interrupted build is built again instead of being taken as complete (found by the local MSVC lane).
  • tools/test/: crypto_jamfiles_test fixtures per family and target, crypto_collect_test, and tests for the changes above.
  • CODING-GUIDELINES.md (chapters 10, 15, 17), AGENTS.md, doc/releases/0.1.0.adoc.

Verification (local, on the final heads, before this PR)

  • Full lint (tools/lint/lint.sh, clang-format and clang-tidy): clean.
  • Lanes from scratch, -a, test and example: native 309, gcc-15 277, wasip2 268, wasip3 261, emscripten 202; 0 failed, 0 warnings.
  • Constant time: macOS native dudect 3/3 (DIT set; the planted leak caught at |t| 96 to 247), wasip2 2/2 (X25519 printed, not judged), Linux container (memcheck, MSan) 10/10 with planted leaks caught.
  • C suites on four targets, release size tables regenerated, throughput re-measured on release builds on an idle machine (1-minute load 2.2 to 3.4, two runs within 3%).
  • Docs, site and site-test 97/97; the crypto pages checked rendered at 1280 px and 375 px (no sideways scroll).
  • Tools tests 64/64, crypto_jamfiles_test on native, wasip2, wasip3 and emscripten; generate.py --check.
  • Local MSVC lane (real cl.exe under Wine): 14.3 and 14.5 each 538 passed, 0 new failures, 19 known Wine artifacts; crypto's 305 tests and test/msvc 41/41 pass. heavy_test is listed as a provisional Wine artifact (Rosetta aborts cl on it); no Windows build has compiled it yet, so the Windows CI decides.
  • Not run locally: the CI's x86-64 container lanes and Apple Clang.

For the owner

  • X25519 on wasip2 is an open finding. dudect times libsodium's X25519 agreement under wasmtime on Apple silicon at |t| 107 to 260 (threshold 10); natively it passes. The likely cause is Apple's DIT bit, which wasmtime does not set: with DIT set in wasmtime's main thread (an experiment, not the lane) the same case reads |t| 1.5 to 2.1. The wasip2 case prints its result without judging, and the constant-time page, crypto.json and the X25519 chapter state the finding.
  • webcpp does not set DIT for user programs. The dudect harness sets DIT on macOS and Linux arm64 and fails where the CPU has DIT and it is not set. Without DIT, X25519 with an all-zero secret runs about 1 ns faster in 15 us (|t| 6.7 to 14.5). The docs tell users on Apple silicon to set DIT around secret operations. Whether the library should set it is an owner decision for later.
  • AES-GCM's default on MSVC is OpenSSL built no-asm, which is not constant time; stated in the docs.
  • gcm's seal does not zero its output on backend_failure (OpenSSL path), unlike every other family's seal and open; follow-up.
  • The trailing-comma workaround: clang-tidy's readability-trailing-comma and clang-format disagree on one-row vectors; the ChaCha fixtures keep their layout under an exemption (b7cc466).
  • C4459 on MSVC: a program with a namespace-scope name such as seed, message or peer_public_key, built at /W4 /WX, can hit C4459 through a header parameter; the headers were left (no rename makes the class go away); the library's own tests are clean.
  • Parked Minors: x25519/formats.hpp:188's refusal is not reached by a test (its text is pinned through x25519.hpp:165); generate.py accepts a lane_note that is neither a string nor an object.
  • After merge, every CI lane's OpenSSL and libdatachannel configuration cache misses once (build.py changed), so the first run is slower.

Related PRs

🤖 Generated with Claude Code

R added 30 commits November 19, 2026 17:14
…als, and the lint's findings on the stream's earlier commits
…s page, and each refusal holds on its target
…ason (crypto's design D32)

Version 0.1's rule chose AES-GCM's default by what the program links and let a
define change it. Design D32 and the owner's answers Q1 to Q4 replace it: the
target alone chooses each family's default, a program names any other backend
in the type, and version 0.1's two defines stop the build. The fixture
both_bearssl_default is now both_bearssl_named.
…nd the fixtures that follow it

The gitlink moves to fbaf13f: design D32's defaults, a structured compilers key
for the defaults' rows, and the optimised tests linked on Emscripten without
debug information. The fixtures follow the defaults: both_bearssl_default is
both_bearssl_named, BearSSL named in the type; web runs on WebAssembly, where
BearSSL is the default; encrypt_and_sign names BearSSL; the two Emscripten
fixtures of version 0.1's defines and no_backend_on_emscripten check the new
texts, and default_bearssl_on_emscripten is new.
…SSL, now that OpenSSL is the default natively whatever is linked
…and encrypt_and_sign uses it on WebAssembly

The gitlink moves to the fix round of Task 5'. encrypt_and_sign is the program
it was, on the default backend, built on the WebAssembly targets where that is
BearSSL; no_backend_on_emscripten checks the needs message's new ending.
…gcm-default, and gcm_default is a fixture of the user's Jamfiles
…very target, and the fixtures build it on all four

The gitlink moves to fix round 2 of Task 5'. The new fixture gcm_default links
the alias and runs on native, wasip2, wasip3 and Emscripten, printing OpenSSL
natively and BearSSL elsewhere; encrypt_and_sign links it beside libsecp256k1
and runs natively again.
…d without threads, with the Emscripten fixtures of both
…missing ed25519-speccheck checkout is tested as refused
…ead, and ciphers::aead refuses a non-AEAD family first
…st counts Ed25519 and X25519, the lint's findings are fixed, and WEBCPP_CRYPTO_HAS_THREADS is documented
…sociations, alone message tests, ChaCha docs, default refusals naming their alias, and a fixture per default alias
… refusal, and the speccheck test reads every entry without throwing
…r-Jamfile fixture per new default alias

Five fixtures build and run /webcpp/crypto//<family>-default on native,
wasip2, wasip3 and Emscripten for the two secret boxes, the two boxes and the
sealed box; aead_not_a_family_on_emscripten states the longer list of AEAD
families.
An own lane runs on its runner, never in the container, so the apt packages it
needs come with its entry: matrix.py's OWN_LANE_PACKAGES gives crypto's
constant-time lane valgrind and llvm-18 (llvm-symbolizer-18, which reads
MemorySanitizer's frames), every other own lane's entry an empty "apt", and
the own-lanes job installs a non-empty list on Linux before the lane runs.
…and their packages install with retries

matrix.py's OWN_LANE_PACKAGES is keyed by target (crypto's constant-time lane
natively: valgrind, llvm-18, libclang-rt-18-dev), and lint-packages prints
their union, which the lint job installs; lint.sh gives a host entry the host
compiler's resource include directory after every other (-idirafter) when it
holds sanitizer/, which wasi-sdk's clang-tidy lacks. Every apt-get of
library.yml retries and fails on an index it cannot fetch.
R added 27 commits November 19, 2026 17:14
… from the trailing-comma check that clang-format contradicts
…, pem::unarmour's unchecked count and the oracle's message
…s direct calls and checks, the box vector's generator, the box's first error, doc fixes
…he tests they compile include backends/sodium.hpp
…n of increment 1, its tables generated from the data (gitlink cd1d370)
…he ciphers table in parts (gitlink 6b0eaf2)
…ance and increment 1's state

Increment 1 is built on its branch: libsodium's backend, the families, the capability table, the fixed defaults and the lanes c-suites, sizes and constant-time. X25519's constant time on wasip2 is recorded as an open finding.
…the ChaCha20-Poly1305, box and crypto_kx defaults not linked, box_not_a_family, X25519's and PEM's defaults, a header not included, an unknown backend, OpenSSL there, Ed25519's policy and secret<0>
…m's keys shown wiped, ChaCha20-Poly1305 in the OpenSSL resource, seal zeroing on failure, per-checker lane notes, B's Jamfile quote (gitlink 879b229)
…luent chains, a Jam comment's width), c-suites' Emscripten post-link warning, the size tables regenerated (gitlink efcdac2)
…e, Apple silicon's DIT, which wasmtime does not set
…, dudect_planted runs only the planted X25519 case (gitlink aebacd1)
…pp after a bare <windows.h>, the tests' <windows.h> through detail/windows.hpp, C4459 in four tests (gitlink 38bc5d6)
…confirmed by a second run (gitlink 7b333ff)
…the configuration's last output

b2 keeps a configuration's outputs once they exist (506cd3f), and build.py
published the archives before build.json: a build interrupted between the
two left a directory that every later build, b2 -a included, took as
complete, and libdatachannel's build then failed reading the absent record.

build.json is now an output of the build action, so a directory without it
is built again. A full build first removes the record, the upstream proof
and the archives an earlier interrupted build left, and publishes the proof
and then the record last, each written whole and replaced. Header
preparation no longer removes the record: it leaves a complete
configuration complete.
…record the configuration's last output

The rule tools/webcpp-third-party.jam states for every source-built
library, which OpenSSL follows since de9119f: libdatachannel's build.py
published its archives and then wrote build.json in place, and build.json
was no output of the build action, so a build interrupted between the two
left a directory b2 kept as complete.

build.json is now an output of the build action, so a directory without it
is built again. A full build first removes the record and the archives an
earlier interrupted build left, and publishes the record last, written
whole and replaced. Header preparation is unchanged.
…time Jamfile's DIT wording (gitlink 1fc5140)
@pinhopro
pinhopro merged commit 485c5e0 into main Nov 19, 2026
4 of 12 checks passed
@pinhopro
pinhopro deleted the crypto/foundation-1 branch November 19, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant