Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2562267
secure: the library's skeleton, its configuration and the test rules …
Nov 24, 2026
a1126f7
secure: declare namespace webcpp::secure and give the guide its Excep…
Nov 24, 2026
c8f2722
secure: format the namespace declaration
Nov 24, 2026
a259d19
secure: timing_guard, cpu_has_dit and dit_is_set, the DIT guard moved…
Nov 24, 2026
3d9e36f
secure: erase_secret and secret<N>, moved from crypto, over secure's …
Nov 24, 2026
860ddbc
secure: wipe_record_test names the moved-from addresses before the move
Nov 24, 2026
c2acc2d
secure: constant_time_equal over any two byte sequences, and declassi…
Nov 24, 2026
7a9d92b
secure: constant_time_equal holds a by-value bytes() result for the w…
Nov 24, 2026
d64c5ed
secure: constant_time_equal returns the sequence without redundant pa…
Nov 24, 2026
40aa42d
secure: constant_time_equal returns the sequence through as_const
Nov 24, 2026
a58a769
secure: the constant-time building blocks, masks, select, lookup and …
Nov 24, 2026
f69c4a4
secure: lookup compares the index in the wider of size_t and the entr…
Nov 24, 2026
4bbfc72
secure: constant_time_test accepts plain char exactly where it is uns…
Nov 24, 2026
d7b4e8e
secure: no function allocates, and the convenience header compiles alone
Nov 25, 2026
7dfe06b
secure: allocation_test keeps clang-tidy quiet, and the Jamfile's com…
Nov 25, 2026
69f9f13
secure: value_barrier is an asm volatile statement, as D8 states, so …
Nov 25, 2026
1195d7e
secure: value_barrier is a volatile round trip under MemorySanitizer,…
Nov 25, 2026
09e8176
secure: the constant-time lane, memcheck, MemorySanitizer and dudect …
Nov 25, 2026
dc71cae
secure: the constant-time paths' list of marked operands ends with a …
Nov 25, 2026
4a05541
secure: the page, its examples, the guard's bench and collect.py
Nov 25, 2026
1fa0cc7
secure: the examples keep clang-tidy quiet, collect.py's lines keep t…
Nov 25, 2026
5f6a4b4
secure: the guard's cost, measured from a release build, with the loa…
Nov 25, 2026
b34c752
secure: state only the measured loads in the page's note, a self-cont…
Nov 25, 2026
27f1cdb
secure: erase example, NOLINT the includes that make each listing sta…
Nov 25, 2026
1df1ba5
secure: collect.py line within 100 columns
Nov 25, 2026
9fb33ed
secure: dudect's DIT line says the guard covers arm64 under macOS, Li…
Nov 25, 2026
e63d919
secure: convenience_header_test and timing_check end through webcpp::…
Nov 25, 2026
19002e7
secure: constant_time_sizes_test checks unequal sizes at run time on …
Nov 25, 2026
43ce517
secure: the MSVC compile-fail case secret_of_no_bytes, moved from cry…
Nov 25, 2026
89a4da0
secure: the erase example checks its wipe count in main, since Emscri…
Nov 25, 2026
c355460
secure: allocation_test's control counts std::allocator's storage, no…
Nov 25, 2026
3601156
secure: timing.cpp says what exit_status is for, and that only a main…
Nov 25, 2026
876351e
secure: no local name of a header hides a program's global (MSVC's C4…
Nov 25, 2026
5365a9c
secure: the blocks page and two static_assert messages name the param…
Nov 25, 2026
192558e
secure: a guard that found DIT set sets it again at its end, since Wi…
Nov 26, 2026
b935ab2
secure: report_case writes to a stream, std::cout by default, so that…
Nov 26, 2026
27a67b2
secure: dudect_blocks measures lookup, select_bytes and less_mask ins…
Nov 26, 2026
771cc29
secure: timing_guard_exceptions throws a type derived from std::excep…
Nov 26, 2026
36292dd
secure: the timing seam's path_in_library compares a path's component…
Nov 26, 2026
8c14f89
secure: the guard page says what a guard that finds DIT set does and …
Nov 26, 2026
639fd46
secure: the guard page's guard around a catch shows its braces withou…
Nov 26, 2026
5156776
secure: the guard's cost measured again on an idle machine (1-minute …
Nov 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Working on secure

webcpp's rules apply here: read the superproject's
[CODING-GUIDELINES.md](../../CODING-GUIDELINES.md)
(<https://github.com/webcpporg/webcpp/blob/main/CODING-GUIDELINES.md>) and its
[AGENTS.md](../../AGENTS.md)
(<https://github.com/webcpporg/webcpp/blob/main/AGENTS.md>) first. This file holds only what is
specific to secure.

## What secure is

- **webcpp's own library** (`"port-of": null`), with **no algorithm**: the side-channel and
secret-in-memory primitives that crypto, hash and the codecs share (the DIT timing guard,
`erase_secret`, `secret<N>`, `constant_time_equal`, `declassify` and the constant-time building
blocks).
- **Header-only**, every function `noexcept`; it raises no exception.

## Cautions

- A test is declared through `secure-run` (or `secure-compile`) in `test/Jamfile`, which builds it
with exceptions and without. The one exception is the own lane `constant-time`
(`test/constant_time/`): its programs (memcheck, MemorySanitizer and dudect) are native only,
one checker build each, and have no `_no_exceptions` twins; its Jamfile says so.
- A constant-time path that both checkers run goes in `test/constant_time/paths.hpp`, with its
operands marked secret through `test/support/constant_time_marks.hpp`; a planted leak is a
`[[gnu::noinline]]` function of its own, which the drivers require the report's first frame to
name.
- A test that defines a seam includes the seam's header first, before any header of secure.
- `detail` is not API: another library's header never includes it. Test code may call
`secure::detail::write_dit`.

## The guard's measured cost

`doc/performance.adoc` is generated: never edit it. `bench/collect.py` writes it, and
`doc/measurements.json` beside it, from `bench/timing.cpp` built at `variant=release`
(`b2 libs/secure/bench//timing`, explicit); it refuses a program built at another variant. Measure
only on an idle machine, release builds only: check `uptime` and the heavy queue first, then, from
the superproject's root:

```
python3 libs/secure/bench/collect.py --timing <the built timing> \
--data libs/secure/doc/measurements.json --page libs/secure/doc/performance.adoc
```

The page states the load averages the run saw. `--render-only` rewrites the page from the data.
`tools/test/secure_collect_test.py` tests the script, and `bench//timing_check` is the correctness
test of the measured program, run in every lane.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,31 @@ secure holds the side-channel and secret-in-memory primitives that the libraries
algorithm: the DIT timing guard, `erase_secret`, `secret<N>`, `constant_time_equal`, the
`declassify` marker and the constant-time building blocks, every name in `webcpp::secure`.

The library is being built; its design is the genesis of `libraries/secure` in
Every function is `noexcept` and none allocates; the library is header-only. Its page,
`doc/secure.adoc`, teaches each primitive with a program of `example/` and states what each covers
and what it does not; its design is the genesis of `libraries/secure` in
[webcpporg/proposals](https://github.com/webcpporg/proposals).

## Build and test

secure is built inside the [webcpp](https://github.com/webcpporg/webcpp) superproject, where it is
the submodule `libs/secure`; a program names `/webcpp/secure//secure`:

```jam
exe app : app.cpp /webcpp/secure//secure ;
```

From the superproject's root:

```
./b2 toolset=clang libs/secure/test libs/secure/example
```

## Documentation

The library's page is built with `./b2 libs/secure/doc doc` and published with webcpp's
documentation, at <https://webcpp.org>.

## Licence

Distributed under the Boost Software License, Version 1.0 (`LICENSE_1_0.txt`).
29 changes: 29 additions & 0 deletions bench/Jamfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2026 WebCpp.org
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# https://www.boost.org/LICENSE_1_0.txt)

# The cost of timing_guard, the scope every function of webcpp that computes on
# a secret runs in (timing.cpp, doc/performance.adoc). timing_check is the
# correctness test of the measured program, run in every lane of test/
# (test/Jamfile builds this project): the measurement at 10^3 iterations, its
# line's form and the thread's DIT checked, never timed against anything. It
# needs no backend: <webcpp/secure/timing_guard.hpp> alone. The measurement
# itself is made by hand by collect.py, which runs the program built here at
# variant=release and writes doc/measurements.json and doc/performance.adoc;
# no lane measures it.

project : requirements <library>/webcpp/secure//secure ;

import webcpp ;

webcpp.targets native wasip2 wasip3 emscripten ;

webcpp.run timing_check : timing.cpp ;
webcpp.run timing_check_no_exceptions : timing.cpp : <exception-handling>off ;

# The same program at variant=release, the one collect.py --timing measures,
# natively and by hand (doc/performance.adoc); no lane measures it.
exe timing : timing.cpp : <variant>release <library>/webcpp//node-test ;
explicit timing ;
Loading
Loading