Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
cfb544f
crypto: the backend libsodium, its canary and its three layers
Nov 17, 2026
01c1c9b
crypto: the reference links libsodium, so backends/sodium.hpp compile…
Nov 17, 2026
5eb9113
crypto: secret<N>, and the errors 15 to 20
Nov 17, 2026
5d759c4
crypto: secret<N>'s tests catch a dead-store wipe; no views of a dyin…
Nov 17, 2026
a3eac75
crypto: the changelog's Unreleased holds ten lines at most, as the li…
Nov 17, 2026
a07da77
crypto: sodium_ready's result is [[nodiscard]], as the lint's rule as…
Nov 17, 2026
47438a4
crypto: the aggregate's headers-alone line links libsodium, so that e…
Nov 17, 2026
beabd27
crypto: secret<N>'s conversion to its span stays implicit, as the spe…
Nov 17, 2026
e3aad77
crypto: the capability table, supports_v and the generated refusals
Nov 17, 2026
7f227c0
crypto: the families' defaults are the one source of the defaults pag…
Nov 17, 2026
52104c3
crypto: one default per family and target, by a stated reason (design…
Nov 17, 2026
954b0f5
crypto: a default row of some compilers names them from crypto.json's…
Nov 17, 2026
f746e5b
crypto: the optimised tests link on Emscripten without debug informat…
Nov 17, 2026
9f7253a
crypto: the examples and the use cases teach AES-GCM's default, and t…
Nov 17, 2026
4da310c
crypto: /webcpp/crypto//gcm-default links AES-GCM's default on every …
Nov 17, 2026
8ea4d40
crypto: Ed25519 and Ed25519ph on libsodium
Nov 17, 2026
5015df3
crypto: X25519 and the Ed25519 to X25519 conversion
Nov 17, 2026
1509343
crypto: secret<N>'s deleted bytes() on an rvalue is [[nodiscard]], as…
Nov 17, 2026
eafacac
crypto: X25519's refusals each pinned by a test (mixed order, y = p +…
Nov 17, 2026
2413fc5
crypto: threads detection, and heavy operations' variants refused wit…
Nov 17, 2026
47a040b
crypto: Ed25519ph names webcpp::hash::sha2_512 from hash's header, Ed…
Nov 17, 2026
965cefc
crypto: llms.txt names a class's functions bare, as every other entry…
Nov 17, 2026
bda4735
crypto: Ed25519's strict policy, and the twelve edge cases per backend
Nov 17, 2026
aa29922
crypto: Ed25519's edge cases record the node and OpenSSL of WebCrypto…
Nov 17, 2026
cc7acc6
crypto: one AEAD template, and ChaCha20-Poly1305, its original form a…
Nov 17, 2026
a3a17ea
crypto: ciphers::aead refuses a type that is no AEAD family first and…
Nov 17, 2026
68acb51
crypto: ChaCha20-Poly1305 on BearSSL and OpenSSL over ciphers::aead, …
Nov 17, 2026
d3214e5
crypto: the libsodium allocation test counts Ed25519 and X25519 too
Nov 18, 2026
11db183
crypto: the changelog's Unreleased lines fit the lint again, the ChaC…
Nov 18, 2026
6ce469e
crypto: the heavy operations' runner passes clang-tidy, names Boost.A…
Nov 18, 2026
1703bef
crypto: X25519's stand-in backend has internal linkage, as clang-tidy…
Nov 18, 2026
185ebfb
crypto: Ed25519's edge-case test passes clang-tidy and holds no fluen…
Nov 18, 2026
56e507a
crypto: Ed25519's generate() says its seed comes from the system's ge…
Nov 18, 2026
adad54c
crypto: the OpenSSL error-queue and the wipe tests pass clang-tidy
Nov 18, 2026
5c6ce50
crypto: secret<N>'s test states why it reads moved-from secrets, as c…
Nov 18, 2026
22d598c
crypto: WEBCPP_CRYPTO_HAS_THREADS has its Doc Comment, so the page's …
Nov 18, 2026
1189d77
crypto: the threads test pins that a native build with threading=sing…
Nov 18, 2026
39762d3
crypto: the heavy refusal tells a native build to leave out WEBCPP_CR…
Nov 18, 2026
19f2921
crypto: aead_not_a_family is declared alone, so another error beside …
Nov 18, 2026
4fbd5dc
crypto: without threads, detail::run_heavy's stand-in stops a heavy v…
Nov 18, 2026
2530a18
crypto: detail::run_heavy carries the handler's allocator and cancell…
Nov 18, 2026
c677a11
crypto: the ChaCha20-Poly1305 docs say BearSSL reads the additional d…
Nov 18, 2026
9c8805e
crypto: OpenSSL's ChaCha20-Poly1305 engine records its constant-time …
Nov 18, 2026
fab7664
crypto: the speccheck test fails, rather than throws, on a committed …
Nov 18, 2026
bd0870e
crypto: a default not linked is refused with its family's /webcpp/cry…
Nov 18, 2026
dc26dff
crypto: chacha_on_ctaes and aead_not_a_family have their Emscripten f…
Nov 18, 2026
8085e71
crypto: every /webcpp/crypto//<family>-default has a user-Jamfile fix…
Nov 18, 2026
04edbe8
crypto: the heavy stand-in's error defers to the refusal above it, an…
Nov 18, 2026
8b14dcf
crypto: the speccheck test fails, rather than throws, on any committe…
Nov 18, 2026
75fed2d
crypto: box, sealed boxes and secretbox on libsodium
Nov 18, 2026
99121d1
crypto: libsodium's own suite and WebCrypto's oracle for Ed25519 and …
Nov 18, 2026
1d7547d
crypto: the constant-time lane over version 0.1's backends, memcheck …
Nov 18, 2026
1371486
crypto: the constant-time lane's review fixes: MemorySanitizer's verd…
Nov 18, 2026
9e5ac75
crypto: SPKI, PKCS#8 and PEM for Ed25519 and X25519
Nov 18, 2026
0719af6
crypto: PEM's own strictness checks pinned on a lenient stand-in back…
Nov 18, 2026
8ce6e3a
crypto: crypto_kx on libsodium
Nov 18, 2026
a2b505b
crypto: sizes and throughput from release builds, as references
Nov 18, 2026
ecdb611
crypto: the size baseline carries the sized programs' harness, a cell…
Nov 18, 2026
3d390a6
crypto: libsodium's own suite names box_easy, box_easy2, secretbox_ea…
Nov 18, 2026
de3edee
crypto: backends::sodium's canary declaration and base64 buffer pass …
Nov 18, 2026
c7bfddf
crypto: the RFC 8410 prefixes of Ed25519's and X25519's formats end w…
Nov 18, 2026
7725e54
crypto: run_heavy's associations are const and its result is captured…
Nov 18, 2026
e552ab8
crypto: pem::unarmour slices its text with detail::pem_part, which ne…
Nov 18, 2026
ad9ad1e
crypto: the key formats' tests pass clang-tidy: smaller functions, tr…
Nov 18, 2026
ca8e728
crypto: WebCrypto's 25519 oracle seeds reproducibly by intent, and th…
Nov 18, 2026
ff8ceb3
crypto: the speccheck test reads the upstream cases and the outside v…
Nov 18, 2026
031f811
crypto: the generated capabilities test's main, one check per cell, i…
Nov 18, 2026
e0815ba
crypto: hybrid::box's Doc Comment says its nonce is safe to draw at r…
Nov 18, 2026
2121936
crypto: the test Jamfile's libsodium comments wrap at 80 columns
Nov 18, 2026
ae09b3f
crypto: the RFC 8410 prefixes name their DER parts a row each, the la…
Nov 18, 2026
be4333e
crypto: pem::unarmour reads a checked line count unchecked, which nev…
Nov 18, 2026
818cfe9
crypto: the WebCrypto formats oracle's message is written a word a row
Nov 18, 2026
1c54f74
crypto: heavy_without_threads_first pins the threads refusal as the f…
Nov 18, 2026
3678eb8
crypto: kx's sessions call the engine directly, kx_default_not_linked…
Nov 18, 2026
421e570
crypto: the XChaCha20 box vector's generator, basic_box refusing a no…
Nov 18, 2026
b8be72f
crypto: the constant-time lane's paragraph says MemorySanitizer is cl…
Nov 18, 2026
310fb78
crypto: the A3 merge's Minors: the secret box guide names no entropy …
Nov 18, 2026
9be238b
crypto: the memory option's windows.h twins link libsodium, as the te…
Nov 18, 2026
af8e7aa
crypto: the constant-time lane, over libsodium's code and the new guards
Nov 18, 2026
0d3e25e
crypto: X25519's agreement under wasmtime, an open finding, printed a…
Nov 18, 2026
12ac5ad
crypto: the constant-time paths written once for memcheck and MemoryS…
Nov 18, 2026
8eff31b
crypto: the sealed box's seal and open in the constant-time lane, und…
Nov 18, 2026
cbf1e1b
crypto: dudect_sodium's verdict named for what it means, and its exce…
Nov 18, 2026
4cc3ee6
crypto: sodium_msan stops when third_party/Jamfile's libsodium config…
Nov 18, 2026
7fc2bc8
crypto: paths.hpp's two checks that depend on the checker computed on…
Nov 18, 2026
cd1d370
crypto: the documentation of increment 1, its tables generated from t…
Nov 18, 2026
fbc22b6
crypto: sodium_msan peeks each of third_party's libsodium configurati…
Nov 19, 2026
aaf77c8
crypto: the generated constant time is what the lane runs, per family…
Nov 19, 2026
6b0eaf2
crypto: chunked messages taught with their binding to order and end, …
Nov 19, 2026
1559bcf
crypto: AGENTS.md names the generators, the chunking sentence agrees …
Nov 19, 2026
d3b7ad1
crypto: the constant-time Jamfile quotes its libsodium define in a co…
Nov 19, 2026
b0444e0
crypto: generate.py takes a lane note per checker, written beside tha…
Nov 19, 2026
a2080a2
crypto: ciphers::aead's and hybrid::basic_box's seal zero the data wh…
Nov 19, 2026
22df9f3
crypto: wipe_objects_sodium shows libsodium's AEAD, secret box and bo…
Nov 19, 2026
9410286
crypto: the OpenSSL memory option's everything test covers chacha20_p…
Nov 19, 2026
879b229
crypto: every compile-time message has a test of its own: X25519's an…
Nov 19, 2026
509defe
crypto: wipe_objects_test's RFC 7748 key and libsodium regions end wi…
Nov 19, 2026
458fdef
crypto: box_messages, file_share and xchacha_seal bind the refusal's …
Nov 19, 2026
f09e953
crypto: test/Jamfile's aead_box_mock comment wrapped at 80 columns (J…
Nov 19, 2026
548468f
crypto: c-suites builds libsecp256k1's optimised tests without debug …
Nov 19, 2026
efcdac2
crypto: the size tables regenerated by generate.py --sizes from the l…
Nov 19, 2026
ec4c075
crypto: a comparison table's measured cell escapes its bars, whose |t…
Nov 19, 2026
5bef2c1
crypto: dudect runs under arm64's DIT and fails where the CPU has it …
Nov 19, 2026
9611d55
crypto: X25519's wasip2 finding states its measured cause, the host's…
Nov 19, 2026
1ff8655
crypto: the review's fixes to dudect under DIT: X25519's page warns o…
Nov 19, 2026
aebacd1
crypto: dudect's DIT scope, macOS and Linux on arm64 only, stated in …
Nov 19, 2026
38bc5d6
crypto: MSVC fixes from the local MSVC lane: pem.hpp calls (std::min)…
Nov 19, 2026
4ae6fe3
crypto: box_sodium_test names NaCl's nonce and message nacl_nonce and…
Nov 19, 2026
7b333ff
crypto: the throughput table measured again on an idle machine (1-min…
Nov 19, 2026
1fc5140
crypto: x25519.adoc's WebAssembly bullet reflowed, and the constant-t…
Nov 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
doc/html/
node_modules
.node-modules/
36 changes: 29 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,40 @@ specific to crypto.

## What crypto is

- **webcpp's own library** (`"port-of": null`) over C backends: BearSSL, OpenSSL, ctaes and
libsecp256k1. The algorithms are the backends'; crypto is the interface shaped as Boost.Hash2's.
- **webcpp's own library** (`"port-of": null`) over C backends: BearSSL, OpenSSL, ctaes,
libsecp256k1 and libsodium (the superproject's `/third_party//sodium`, shared with
webcpp::hash). The algorithms are the backends'; crypto is the interface shaped as Boost.Hash2's.
- **No oracle.** No original runs beside crypto: the evidence is the published vectors (the GCM
specification's cases, Wycheproof, FIPS 197, BIP340 and BIP341), the backends' own suites in the
lane `c-suites`, and the agreement tests, which compare two backends on random inputs (BearSSL
and OpenSSL on AES-GCM, ctaes and OpenSSL on the block cipher).
specification's cases, Wycheproof, FIPS 197, RFC 8439 and RFC 8032, BIP340 and BIP341), the
backends' own suites in the lane `c-suites`, and the agreement tests, which compare two backends
on random inputs.
- **One default backend per family and target, with its reason; no profile.** The capability table
(`supports_v`, `default_backend_t`) is generated, never read from a measurement.

## The generators

- `doc/tables/generate.py` reads `doc/tables/crypto.json`, the test Jamfiles, the message tests and
the superproject's Jamfile fixtures, and writes `doc/generated/*.adoc`, `doc/llms.txt`,
`include/webcpp/crypto/detail/capabilities.hpp`, `detail/defaults.hpp`, the defaults' aliases in
`build.jam`, `test/capabilities_test.cpp` and the Ed25519 cases' table from
`meta/ed25519_cases.json`. Each says it is generated: never edit it, change `crypto.json` or the
generator and run it again. `generate.py --check` writes nothing and fails on a difference; the
doc build runs it and `generate_test.py` (its tests, written first).
- A new family, backend, message test, fixture or MSVC case needs its `crypto.json` entry in the
same commit (`fixes` for each message, `fixtures` for each fixture, `lane` for the constant-time
lane's paths); the generator names what is missing.
- `generate.py --sizes <json>...` reads the own lane `sizes` (built at `variant=release`) into
`doc/tables/sizes.json`; `doc/performance.json` is `bench/collect.py`'s, release builds only.
Nothing that states a size or a speed is typed by hand.

## Cautions

- A backend's header supplies only the four traits (`block_state`, `block_engine`, `gcm_state`,
`gcm_engine`); every guard lives in the algorithm types.
- An algorithm type does every guard; a backend's header supplies only the six traits of
`detail/engines.hpp` (`block_state`, `block_engine`, `gcm_state`, `gcm_engine`, `aead_state`,
`aead_engine`) and, for the curves and `hybrid`, the functions of its own header.
- A test of a backend is a `.cpp` of its own per backend, never a define that changes the backend
of one source (spec section 4.3's pitfall).
- Every C library is unchanged upstream code. A moved pin is a change of its own
(CODING-GUIDELINES.md chapter 5, rule 12).
- X25519's constant time on wasip2 is an open finding (the page's constant-time table): do not
describe it as a pass.
13 changes: 13 additions & 0 deletions LICENSE-LIBSODIUM-DOC.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (c) 2014-2026, Frank Denis <github@pureftpd.org>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 changes: 18 additions & 0 deletions LICENSE-LIBSODIUM.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* ISC License
*
* Copyright (c) 2013-2026
* Frank Denis <j at pureftpd dot org>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,28 @@ MSVC), wasip2, wasip3 and Emscripten.
- `webcpp::crypto`: a `random_device` that reads the operating system's or the browser's
generator, a constant-time `equal` for tags and MACs, and `error`, every failure's value.
- `webcpp::crypto::ciphers`: AES-GCM (`gcm`, `aes128_gcm`, `aes256_gcm`) with keys of 16, 24 and
32 bytes, and the AES block cipher (`aes128`, `aes192`, `aes256`).
32 bytes, the AES block cipher (`aes128`, `aes192`, `aes256`), the ChaCha20-Poly1305 AEADs, and
NaCl's and libsodium's secret boxes (`secretbox`, `secretbox_xchacha20poly1305`).
- `webcpp::crypto::curves::secp256k1`: BIP 340 Schnorr and ECDSA signatures, their verification,
ECDH, ECDSA's strict DER and low-S forms, and the x-only tweak.
- `webcpp::crypto::curves::ed25519`: Ed25519 signatures (RFC 8032) with strict verification, the
X25519 secret key of a key pair, and Ed25519ph over SHA-512 for a message given in pieces.
- `webcpp::crypto::curves::x25519`: X25519 key agreement (RFC 7748), refusing an all-zero shared
secret, `curves::ed25519::to_x25519_public` for a peer known by its Ed25519 key, and
`kx_keypair`, libsodium's `crypto_kx`, a session key for each direction of a client and a server.
- Ed25519's and X25519's keys in RFC 8410's SPKI and PKCS#8, as OpenSSL and WebCrypto write them,
and `webcpp::crypto::pem` for their PEM text, each decoded strictly.
- `webcpp::crypto::hybrid`: NaCl's and libsodium's boxes between two key pairs (`box`,
`box_xchacha20poly1305`), refusing a peer key of small order, and sealed boxes (`sealed_box`),
anonymous encryption to a public key.

The algorithms are those of widely used, reviewed C libraries, each a backend that a program
names in its own Jamfile and that webcpp builds from its sources: BearSSL
(`/third_party//bearssl`), OpenSSL 3.5.9 (`/webcpp/crypto//openssl`, never the system's, refused
on Emscripten), ctaes (`/third_party//ctaes`) and libsecp256k1 (`/third_party//secp256k1`). Which
operation runs on which backend and target is the page's generated table, from the tests that run
each. Hashing and HMAC stay with Boost.Hash2. Protocols built on these primitives (Bitcoin,
Ethereum, Nostr) belong to domain libraries.
on Emscripten), ctaes (`/third_party//ctaes`), libsecp256k1 (`/third_party//secp256k1`) and
libsodium (`/third_party//sodium`). Which operation runs on which backend and target is the
page's generated table, from the tests that run each. Hashing and HMAC stay with Boost.Hash2.
Protocols built on these primitives (Bitcoin, Ethereum, Nostr) belong to domain libraries.

## Building and testing

Expand Down Expand Up @@ -46,4 +57,7 @@ from `doc/tables/crypto.json` and the tests; `b2 libs/crypto/doc` checks them.

crypto is under the Boost Software License, Version 1.0 (`LICENSE_1_0.txt`). The backends keep
their own: BearSSL is MIT (`LICENSE-BEARSSL.txt`), ctaes is MIT (`LICENSE-CTAES.txt`),
libsecp256k1 is MIT (`LICENSE-SECP256K1.txt`) and OpenSSL is Apache-2.0.
libsecp256k1 is MIT (`LICENSE-SECP256K1.txt`), libsodium is ISC (`LICENSE-LIBSODIUM.txt`) and
OpenSSL is Apache-2.0. The documentation's sections on libsodium's families adapt parts of
libsodium's documentation (`jedisct1/libsodium-doc`), which is ISC
(`LICENSE-LIBSODIUM-DOC.txt`).
38 changes: 38 additions & 0 deletions bench/Jamfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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 throughput of each family's fixed operation per backend (throughput.cpp,
# bench/operations.hpp). throughput_check is the correctness test of the
# measured program, run in every lane of test/ (test/Jamfile builds this
# project): each operation checked once, never timed. The measurement itself
# is made by hand by collect.py, which runs the program built here at
# variant=release and writes doc/performance.adoc; no lane measures it.

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

import webcpp ;
import webcpp-target ;

webcpp.targets native wasip2 wasip3 emscripten ;

# OpenSSL on the targets that have it; Emscripten has none.
rule with-openssl ( properties * )
{
if [ webcpp-target.target-of $(properties) ] in native wasip2 wasip3
{
return <library>/webcpp/crypto//openssl ;
}
}

.requirements = <library>/third_party//bearssl <library>/third_party//ctaes
<library>/third_party//secp256k1 <library>/third_party//sodium
<conditional>@with-openssl ;
webcpp.run throughput_check : throughput.cpp : $(.requirements) ;

# The same program at variant=release, the one collect.py measures, built and
# run by hand (doc/performance.adoc); no lane measures it.
exe throughput : throughput.cpp : $(.requirements) <variant>release ;
explicit throughput ;
Loading
Loading