Skip to content
Merged
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ tag is placed.
| lexical | [genesis](libraries/lexical/openspec/changes/archive/2026-10-09-genesis) | lexical: the lexical forms of JSON Schema's string formats | own | implemented | 0.1.0 | 2026-10-09 | [code](https://github.com/webcpporg/lexical/tree/e286ca4) |
| lexical | [strategies](libraries/lexical/openspec/changes/strategies) | lexical: one entry point, strategies and Boost.Regex | own | draft | | | |
| pratt | [genesis](libraries/pratt/openspec/changes/archive/2026-10-08-genesis) | pratt: a generic Pratt parser engine for C++20, with a decimal calculator | own | implemented | 0.1.0 | 2026-10-08 | [code](https://github.com/webcpporg/pratt/tree/d78451b) |
| secure | [genesis](libraries/secure/openspec/changes/genesis) | secure: the side-channel and secret-in-memory primitives crypto, hash and codecs share (DIT guard, erase, secret, constant-time blocks), no algorithm | own | implementing | | 2026-11-24 | [code](https://github.com/webcpporg/secure) |
| trystero | [genesis](libraries/trystero/openspec/changes/archive/2026-10-09-genesis) | trystero: serverless WebRTC rooms, wire compatible with Trystero | port of Trystero 0.26.0 | implemented | 0.1.0 | 2026-10-09 | [code](https://github.com/webcpporg/trystero/tree/160f431) |
| trystero | [bounded-json-parse](libraries/trystero/openspec/changes/bounded-json-parse) | trystero: bound the text and the objects a room parses | port of Trystero 0.26.0 | draft | | | |
| trystero | [shared-connection](libraries/trystero/openspec/changes/archive/2026-11-14-shared-connection) | trystero: one connection shared by the rooms of an app | port of Trystero 0.26.0 | implemented | 0.1.0 | 2026-10-11 | [code](https://github.com/webcpporg/trystero/tree/e9326e94c06cfa9ffdbd0a8d3c8d72b80b3b9b59) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ increment 6 (Botan) merges (design D8).

## Open

- [ ] The final quiet measurement pass measures the guard's cost again and regenerates the
throughput tables (design.md, "As built").
- [ ] The final quiet measurement pass regenerates the throughput tables (design.md, "As built");
the guard's cost was measured again on an idle machine on 2026-11-26 (clear 37.0 ns, set 1.2 ns).
- [ ] crypto's `detail/timing.hpp` names hash's copy at crypto's next change of it.
- [ ] The MSVC lane's known-failures list gains the seven no-exceptions builds of the Boost.JSON
class.
11 changes: 11 additions & 0 deletions libraries/secure/openspec/changes/genesis/.openspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
schema: spec-driven
created: 2026-11-24
webcpp:
library: secure
title: "secure: the side-channel and secret-in-memory primitives crypto, hash and codecs share (DIT guard, erase, secret, constant-time blocks), no algorithm"
kind: own
port_of: null
status: implementing
release: null
implementation: https://github.com/webcpporg/secure
decided: 2026-11-24
443 changes: 443 additions & 0 deletions libraries/secure/openspec/changes/genesis/design.md

Large diffs are not rendered by default.

116 changes: 116 additions & 0 deletions libraries/secure/openspec/changes/genesis/proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
## Why

Three webcpp libraries handle secrets, and each either holds its own copy of the same small
primitives or would have to reach into another library's internals to get them:

- webcpp::crypto holds the DIT guard (`include/webcpp/crypto/detail/timing.hpp`), the volatile wipe
(`detail/wipe.hpp`), the public `crypto::erase_secret`, `crypto::constant_time_equal` and
`crypto::secret<N>`, and the constant-time lane's declassify marker (`detail/declassify.hpp`).
- webcpp::hash holds a second copy of the guard (`include/webcpp/hash/detail/timing.hpp`, with an
`engaged` flag) and a second wipe (`detail/wipe.hpp`), because it depends on no other webcpp
library and crypto's `detail` is not its to include; a test of crypto keeps the two guards in step.
- webcpp::codecs, whose genesis the owner approved on 2026-11-24, needs the guard, a wipe, a secret
type and constant-time selection and lookup for its secret encodings, and would have made a third
copy of each.

config's change `timing-guard` (2026-11-24) moved the guard alone into webcpp::config. It was built
and verified natively, the Windows on ARM64 branch once on the owner's Windows 11 ARM64 VM, then
withdrawn before any push: on 2026-11-24 the owner decided instead that these primitives are a
library of their own, webcpp::secure, and that config stays macros only.

## What Changes

- **New library `webcpp::secure`**, of webcpp's own design, header-only C++20,
`/webcpp/secure//secure`, repository `webcpporg/secure` (the owner creates it), submodule
`libs/secure`, BSL-1.0. It holds no cryptographic algorithm: only the side-channel and
secret-in-memory primitives that crypto, hash and codecs share. It depends on Boost's headers and
`/webcpp/config//config` (the platform macros) alone. Every name is in `webcpp::secure` and every
header under `<webcpp/secure/...>` (the owner's rule: the top-level namespace and include root are
for libraries with a repository of their own).
- **`<webcpp/secure/timing_guard.hpp>`**, public, since it is the library's purpose:
`secure::timing_guard` (RAII, `explicit timing_guard(bool engaged = true)`, not copyable or
movable), `secure::cpu_has_dit()`, `secure::dit_is_set()`, the macro
`WEBCPP_SECURE_TIMING_COVERED` where the guard acts, and the test seam
`WEBCPP_SECURE_TIMING_ENTERED(where)`. It sets arm64's DIT for its scope when the CPU has FEAT_DIT
and DIT is clear, and clears it on exit only when it set it, so guards nest across libraries and
a program that set DIT keeps it. Covered: arm64 under Apple's systems, Linux and Android, and
Windows (`_M_ARM64`, not ARM64EC, through `_ReadStatusReg`, `_WriteStatusReg` and `__isb`, with
FEAT_DIT probed once under structured exception handling); an empty class elsewhere.
- **`<webcpp/secure/erase_secret.hpp>`**: `secure::erase_secret(range)`, moved from crypto with its
name and contract, over secure's volatile wipe.
- **`<webcpp/secure/constant_time_equal.hpp>`**: `secure::constant_time_equal(first, second)`,
moved from crypto with its name, now over any two contiguous ranges of bytes (a span, an array, a
`secret<N>`, a Boost.Hash2 digest) so that secure names no Boost.Hash2 type; it holds the guard.
- **`<webcpp/secure/secret.hpp>`**: `secure::secret<N>`, moved from crypto unchanged in behaviour:
`N` owned bytes, wiped on destruction and on move, copied only by `clone()`, viewed through
`bytes()`, `writable()` and an lvalue's implicit span.
- **`<webcpp/secure/declassify.hpp>`**: `secure::declassify(object)`, the marker library code
calls on a value derived from secrets that it branches on by design (a tag's verdict): nothing in
a program's build, memcheck's `VALGRIND_MAKE_MEM_DEFINED` when a constant-time test build defines
`WEBCPP_SECURE_CT_VALGRIND`, MemorySanitizer's `__msan_unpoison` under `WEBCPP_SECURE_CT_MSAN`.
The marking of secrets and the reading of the checkers' shadow, which only tests do, are test
support, not public.
- **`<webcpp/secure/constant_time.hpp>`**, namespace `secure::constant_time`: the building blocks
codecs needs, as primitives: `value_barrier`, masks from a bit and from comparisons of unsigned
values (`mask_from_bit`, `is_zero_mask`, `is_equal_mask`, `is_less_mask`,
`is_in_range_mask`), `select` by mask, `select_bytes` (a conditional copy), `lookup` (a table
read whole, the entry chosen by masks), and comparisons of byte sequences returning masks
(`equal_mask`, `is_zero_mask` of bytes, `less_mask`, big-endian).
- **`<webcpp/secure.hpp>`**, the convenience header, and `<webcpp/secure/config.hpp>`.
- **Tests**: the guard's (`timing_guard_test`, `_nesting_`, `_seam_`, `_threads_`, `_windows_`,
header-alone), crypto's `erase_secret_test`, `constant_time_equal_test` and
`declassify_compile_test` moved, `secret_test`, the constant-time blocks against a plain
reference (every 8-bit pair, random wider ones), the allocation test, and the own lane
`constant-time` (memcheck, MemorySanitizer, dudect, each with a planted leak that must fail). The
seam recorder, the DIT helper and the checkers' marks live in secure's own `test/support/`, and
hash and crypto keep or gain their own copies in theirs (design O1, decided 2026-11-24).
- **Documentation**: the library's page, the guard's coverage table, how to erase, the secret type,
the constant-time blocks with their limits, and the changelog.

Not in this change: webcpp::codecs' genesis, which uses secure from its first line (amended the
same day). The migrations of hash and crypto, which this paragraph first named as their own
follow-up changes, the owner folded into the same delivery on 2026-11-24, after secure's own tasks
(tasks.md sections 7 and 8): webcpp::hash's guard and wipe move to secure and hash's copies are
deleted (hash then depends on secure), then webcpp::crypto's every caller moves to secure and
`crypto::erase_secret`, `crypto::constant_time_equal`, `crypto::secret`, `detail/timing.hpp`,
`detail/wipe.hpp` and `detail/declassify.hpp` are deleted with no alias.

## Capabilities

### New Capabilities

- `secure`: webcpp::secure, the DIT timing guard, `erase_secret`, `constant_time_equal`,
`secret<N>`, the declassify marker, the constant-time building blocks, with their build, tests,
lanes and documentation.

### Modified Capabilities

None.

## Impact

- **Kind:** own (`"port-of": null`): webcpp's own design, moved from webcpp::crypto and
webcpp::hash and from config's withdrawn change `timing-guard`; the constant-time blocks follow
BoringSSL's `constant_time_*` and libsodium's arithmetic. Repository `webcpporg/secure` (not
created; the owner creates it), checked out as the submodule `libs/secure`, BSL-1.0, "Copyright
(c) 2026 WebCpp.org".
- **Implementation:** nothing is built in secure's name. The prior code is in `reference/prior/`:
the guard as config's withdrawn branch built it (Windows on ARM64 included) with its tests, the
shared seam of that branch, and crypto's headers and tests that move. To build: the library's
repository, `build.jam`, `include/webcpp/secure.hpp`, `include/webcpp/secure/*.hpp`, tests, the
constant-time lane, `doc/`, the superproject's pointer, `CODING-GUIDELINES.md` chapter 17's entry
and the index page; then hash and crypto moved onto it.
- **Dependencies:** Boost 1.92's headers (Core's `lightweight_test` in tests) and
`/webcpp/config//config`. For the constant-time lane: valgrind, MemorySanitizer and dudect as
webcpp::crypto's lane uses them. secure depends on no other webcpp library; hash, crypto and
codecs depend on it.
- **Status:** approved by the owner on 2026-11-24 (`decided`), and `accepted` the same day once
`reference/plan.md` carried the plan's code, which `tools/proposals.py` requires of an
`accepted` proposal.
- **Other proposals:** replaces `libraries/config`'s change `timing-guard`, withdrawn the same day
(archived as `2026-11-24-timing-guard`). `libraries/codecs`'s genesis uses secure's guard, erase,
secret and constant-time blocks (its owner decision 14). hash's and crypto's migrations, which
the genesis first named follow-up changes, are part of this delivery by the owner's decision of
2026-11-24 (tasks.md sections 7 and 8): `libraries/hash` (its guard and wipe on secure's) and
`libraries/crypto` (every caller on secure's names, its copies deleted with no alias, its
`data-independent-timing` requirements read with secure's guard and seam).
39 changes: 39 additions & 0 deletions libraries/secure/openspec/changes/genesis/reference/STATUS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# webcpp::secure: where the implementation stands, and what to start from

2026-11-25: built, awaiting tasks.md 10.1 (the full verification on every lane, the idle
re-measure of the guard, the pull requests and the merge). Tasks 1.1 to 9.1 are done, each on the
branch `secure/genesis` of its repository: webcpporg/secure at `43ce517` (the library, 1.1 to
6.1), webcpporg/hash at `5b5efcd` (its migration, 7.1 and 7.2), webcpporg/crypto at `04d56e7`
(8.1) and webcpporg/webcpp at `55e4895` (the guidelines, AGENTS.md, the release notes, the tools
and the gitlinks, 9.1), with the final review's fixes. What follows, written with the genesis,
is where the implementation started.

Written 2026-11-24, with the genesis. Nothing is built in secure's name yet. The owner created the
repository `webcpporg/secure` on 2026-11-24 and its submodule `libs/secure`. `prior/` holds the code
an implementer ports, exact copies of files committed elsewhere, none of them renamed yet:

| `prior/` | Copied from | What it is |
| --- | --- | --- |
| `config/include/webcpp/config/detail/timing_guard.hpp` | webcpporg/config, branch `config/timing-guard` at `ba72ad4` (local, never pushed) | The guard of config's withdrawn change `timing-guard`: crypto's guard with hash's `engaged` flag, the one seam, Windows on ARM64 (`_ReadStatusReg`, `_WriteStatusReg`, `__isb`, the SEH probe). Named `webcpp::config::detail` and `WEBCPP_CONFIG_DETAIL_*`; becomes `webcpp::secure` and `WEBCPP_SECURE_*` (design D2, D3). |
| `config/test/timing_guard_*_test.cpp` | the same commit | Its tests: plain, nesting, seam, threads, Windows. |
| `node-test/include/webcpp/test/timing_seam.hpp`, `timing_dit.hpp` | the superproject webcpporg/webcpp, branch `config/timing-guard` at `83c9a31` (local) | The seam recorder and the DIT helper that branch shared in `tools/node-test`. secure ports them into its own `test/support/` (design D9); the shared place is open (O1). |
| `crypto/include/webcpp/crypto/{erase_secret,constant_time_equal,secret}.hpp`, `detail/{wipe,declassify}.hpp` | webcpporg/crypto `main` at `3314a1d` | The public names that move to secure with no alias (design D4 to D7). |
| `crypto/test/{erase_secret,constant_time_equal,declassify_compile}_test.cpp` | the same commit | Their tests, which move with them. |

## The withdrawn change's verification, which the port inherits

- Natively (clang, this Mac): config 27 tests, hash 295, crypto 541 passed, 0 failed, with every
guard site of hash (28) and crypto (187 in 26 headers) moved onto the shared guard.
- The Windows on ARM64 branch, once, on the owner's Windows 11 ARM64 VM: MSVC 14.3 and 14.5, arm64
and x64, debug builds; config's tests and example passed with 0 known and 0 new failures on each
of the four lanes; on arm64 `cpu_has_dit()` was true and DIT stayed set across sleeps inside a
guard.
- Not run: a release build on the VM, clang-cl ARM64, a CPU without FEAT_DIT (the probe's filter
path), crypto's dudect on Windows ARM64, gcc 15, WASI, Emscripten and the constant-time lane for
the last tasks of that branch. Its measurement of the guard's cost was taken under load and is
not reused (design D11).

The withdrawn branch's commits (config `ba72ad4`, hash `43b6732`, crypto `b0c1f4f`, superproject
`83c9a31`) are a worked example of moving every guard site of hash and crypto by a rename, for
their migrations, which the owner folded into this delivery on 2026-11-24 (tasks.md sections 7
and 8). The plan is `plan.md`, beside this file.
Loading