diff --git a/AGENTS.md b/AGENTS.md
index 74d00bc4..fdc96e57 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -77,7 +77,7 @@ for web developers and for AI developers (`CODING-GUIDELINES.md` chapter 16).
| beast | HTTP and WebSocket applications using native/WASIp3 sockets, browser WebSocket/fetch, WASI host HTTP or supplied streams | native, emscripten, wasip2, wasip3, by backend | a submodule at `libs/beast`; all 53 upstream applications remain in its compatibility matrix |
| cobalt | Boost.Cobalt coroutine applications with shipped Wasm adaptations and optional corrected SSL | native, emscripten, wasip2, wasip3, by capability | a submodule at `libs/cobalt`; see its feature and application matrices for variants |
| config | webcpp's configuration, which every library includes first: the target, exceptions and webcpp's version, as Boost.Config is Boost's; webcpp's own | native, wasip2, wasip3, emscripten | a submodule at `libs/config` |
-| crypto | AES-GCM, the AES block cipher, random_device, a constant-time equal and secp256k1 over C libraries built from source (BearSSL, OpenSSL, libsecp256k1, ctaes), webcpp's own | native, wasip2, wasip3, emscripten (OpenSSL not on emscripten); its own lane c-suites | a submodule at libs/crypto |
+| crypto | AES-GCM, the AES block cipher, random_device, constant_time_equal and secp256k1 over C libraries built from source (BearSSL, OpenSSL, libsecp256k1, ctaes), webcpp's own | native, wasip2, wasip3, emscripten (OpenSSL not on emscripten); its own lane c-suites | a submodule at libs/crypto |
| xactor | a deterministic actor system, webcpp's own | native, wasip2, wasip3 (`xactor_asio` native only) | a submodule at `libs/xactor`; the model for every port |
| xstate | a port of XState 5.33.2's state machines and actors; depends on xactor and Boost.JSON | native, wasip2, wasip3; its oracle lane | a submodule at `libs/xstate`; the first user of the shared oracle (`CODING-GUIDELINES.md` chapter 12) |
| pratt | a Pratt parser engine, generic through concepts, with a calculator built on it, webcpp's own | native, emscripten, wasip2, wasip3 | a submodule at `libs/pratt`; born with the allocation rule (`CODING-GUIDELINES.md` chapter 4) |
diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md
index b3a1cb76..369b203c 100644
--- a/CODING-GUIDELINES.md
+++ b/CODING-GUIDELINES.md
@@ -6994,25 +6994,42 @@ makes a room read, through webcpp::beast's bounded handshake layer.
webcpp::crypto gives C++20 programs on every target the primitives of
cryptography over widely used C libraries that webcpp builds from their
-sources: AES-GCM and the AES block cipher, a `random_device` on the system's
-generator, a constant-time `equal`, and secp256k1's BIP340 Schnorr and ECDSA
-signatures, ECDH, strict DER and the x-only tweak. Version 0.1 is the
-proposal's increments 1 and 2, as the owner set them on 2026-11-14; OpenSSL's
-memory option is built after it (its block below, unreleased); what is decided
-and not built is in chapter 17.
+sources. Version 0.1 is the proposal's increments 1 and 2, as the owner set
+them on 2026-11-14: AES-GCM and the AES block cipher, a `random_device` on the
+system's generator, a constant-time comparison (named `constant_time_equal`
+since the uniform-types change), and secp256k1's BIP340 Schnorr and ECDSA
+signatures, ECDH, strict DER and the x-only tweak. What is built after it is
+unreleased and has its blocks below: OpenSSL's memory option, the curves and
+constructions of the later changes, and `erase_secret`; what is decided and
+not built is in chapter 17.
**Scope.**
- **crypto holds primitives only, grouped in namespaces whose headers mirror
- them: the root (`error`, `random_device`, `equal`, `config`), `backends`,
- `ciphers` (`aes128`, `aes192`, `aes256`, `gcm`, `aes128_gcm`, `aes256_gcm`,
- under ``) and `curves::secp256k1` (under
+ them: the root (`error`, `random_device`, `constant_time_equal`,
+ `erase_secret`, `config`), `backends`, `ciphers` (`aes128`, `aes192`,
+ `aes256`, `gcm`, `aes128_gcm`, `aes256_gcm`, under
+ ``) and `curves::secp256k1` (under
``).** The owner's rule of 2026-11-15: a protocol's
steps (BIPs, EIPs, NIPs) belong to a domain library built on these
primitives (a future webcpp::bitcoin, ethereum or nostr), so the Taproot
functions became a generic x-only tweak and lax DER left the library; the
removed code is kept on the library's branch `save/bitcoin-taproot`.
Source: `libraries/crypto/openspec/changes/genesis/design.md` (proposals).
+- **Public names are spelled out; only algorithm and format proper names stay
+ acronyms.** A nonce is `nonce` (`nonce_bytes`, `nonce_size`,
+ `invalid_nonce_size`), associated data `associated_data`, a context
+ `context`; `aes`, `gcm`, `chacha20`, `hmac`, `hkdf`, `ecdsa`, `eddsa`,
+ `sha256`, `kx`, `der`, `pem`, `spki` and `pkcs8` stay, as do a standard's own
+ variable names (ECDSA's `r` and `s`) and the standard library's `max_`. The
+ owner's rule of 2026-11-23: a reader should not need a glossary for a
+ parameter. Names taken from a C library are spelled out too: secp256k1's
+ `public_key_tweak_add` and `secret_key_negate` (libsecp256k1's `pubkey`,
+ `seckey`), MuSig2's `generate_nonce`, silent payments'
+ `previous_outputs_summary`; a class template is named for its algorithm, as
+ `ciphers::basic_chacha20_poly1305`, `basic_box` and `basic_secretbox` are.
+ Source: `libraries/crypto/openspec/changes/uniform-types/design.md` owner
+ decision 13, D11, owner decision 14, D12 (proposals).
- **Hashing and HMAC stay with Boost.Hash2, and HKDF, when a program needs
it, is written on `boost::hash2::hmac`; every call is synchronous, and
WebCrypto is not a backend.** The owner's amendment C1 of 2026-10-10; with C
@@ -7026,10 +7043,11 @@ and not built is in chapter 17.
the output `result_type`, modes as templates over a cipher
(`ciphers::gcm>`), tags as `boost::hash2::digest<16>`,
and the backend a template parameter defaulting to the default backend; a
- keyed object is built by `static make(...)`, which returns
- `boost::system::result`, never by a constructor.** Boost's own shape is
- what a Boost user expects; a key can have the wrong size and a backend can
- fail to allocate, and the library works without exceptions.
+ keyed object is built by a static factory named by its input (`from_key`,
+ `from_secret`), which returns `boost::system::result`, never by a
+ constructor.** Boost's own shape is what a Boost user expects; a key can
+ have the wrong size and a backend can fail to allocate, and the library works
+ without exceptions.
Source: `libraries/crypto/openspec/changes/genesis/design.md` D2
(proposals); `include/webcpp/crypto/ciphers/gcm.hpp` (libs/crypto).
- **The algorithm types do every guard, the moved-from state, the
@@ -7056,27 +7074,27 @@ and not built is in chapter 17.
clang refuses under `on`.
Source: `include/webcpp/crypto/detail/limits.hpp` (libs/crypto).
- **One public header per responsibility; a backend's header checks that its
- library is linked; `config.hpp`, `error.hpp`, `equal.hpp`,
- `random_device.hpp` and `` compile with no backend
- linked.** A program that only draws random bytes or compares tags names no
- backend library, and one that only signs names `/third_party//secp256k1`
- alone.
+ library is linked; `config.hpp`, `error.hpp`, `constant_time_equal.hpp`,
+ `erase_secret.hpp`, `random_device.hpp` and `` compile
+ with no backend linked.** A program that only draws random bytes or compares
+ tags names no backend library, and one that only signs names
+ `/third_party//secp256k1` alone.
Source: `libraries/crypto/openspec/changes/genesis/reference/spec.md`
section 2.2 (proposals); `test/Jamfile`'s headers-alone list (libs/crypto).
-- **`equal` compares in constant time: it reads every byte, accumulates the
- XOR of each pair in a `volatile` local read once after the loop and reduces
- it without a branch; spans of different sizes compare unequal without their
- contents being read.** Hash2's `digest::operator==` is `memcmp`; a size
- is public.
- Source: `include/webcpp/crypto/equal.hpp` (libs/crypto).
+- **`constant_time_equal` compares in constant time: it reads every byte,
+ accumulates the XOR of each pair in a `volatile` local read once after the
+ loop and reduces it without a branch; spans of different sizes compare
+ unequal without their contents being read.** Hash2's `digest::operator==`
+ is `memcmp`; a size is public.
+ Source: `include/webcpp/crypto/constant_time_equal.hpp` (libs/crypto).
- **Every public function that runs a backend's cryptographic code, and
- `equal`, holds `detail::timing_guard` as its first statement: on 64-bit ARM
- under macOS, iOS, Linux and Android, where the CPU has FEAT_DIT, it sets
- PSTATE.DIT for the call (`msr s3_3_c4_c2_5`, then `isb`) and returns the
- thread's DIT as it found it, after an error and an exception too; on x86,
- WebAssembly and Windows on ARM64 it is empty. A later increment's public
- function that calls a backend holds one too and joins its backend's
- coverage test, which checks through the seam
+ `constant_time_equal`, holds `detail::timing_guard` as its first statement:
+ on 64-bit ARM under macOS, iOS, Linux and Android, where the CPU has
+ FEAT_DIT, it sets PSTATE.DIT for the call (`msr s3_3_c4_c2_5`, then `isb`)
+ and returns the thread's DIT as it found it, after an error and an exception
+ too; on x86, WebAssembly and Windows on ARM64 it is empty. A later
+ increment's public function that calls a backend holds one too and joins its
+ backend's coverage test, which checks through the seam
`WEBCPP_CRYPTO_DETAIL_TIMING_ENTERED` that each call entered its own
guard.** None of the C libraries sets DIT, which Apple requires of
constant-time code, and without it libsodium's X25519 was measured not
@@ -7105,14 +7123,15 @@ and not built is in chapter 17.
**Authenticated encryption.**
- **`seal` and `open` work in place on `data`, with the tag apart; an AEAD
- copies the tag into a local array and consumes the IV and the additional
+ copies the tag into a local array and consumes the nonce and the associated
data before it writes the first byte of `data`.** No buffer is copied, and a
- tag, IV or additional data in the same buffer as `data` gives correct
+ tag, nonce or associated data in the same buffer as `data` gives correct
results.
Source: `libraries/crypto/openspec/changes/genesis/specs/crypto/spec.md`
"GCM: in place, the tag apart" (proposals).
- **Every function checks its conditions first, in a fixed order (key size,
- moved-from, the incremental state, IV size, tag size, the length limits),
+ moved-from, the incremental state, nonce size, tag size, the length
+ limits),
and returns before it reads a secret byte; a refusal leaves `data`
untouched.** The rulebook's rule that a function starts with its guards.
Source: `libraries/crypto/openspec/changes/genesis/reference/spec.md`
@@ -7124,31 +7143,33 @@ and not built is in chapter 17.
plaintext before the tag is known.
Source: `libraries/crypto/openspec/changes/genesis/design.md` D5
(proposals).
-- **The incremental seal is `begin_seal(iv, additional_data)`, `update(data)`
- and `result()`, and any error in it ends the message and wipes its state.**
- Additional data is taken whole, so no piece of it needs a growing buffer.
+- **The incremental seal is `begin_seal(nonce, associated_data)`,
+ `update(data)` and `result()`, and any error in it ends the message and wipes
+ its state.** Associated data is taken whole, so no piece of it needs a
+ growing buffer.
Source: `libraries/crypto/openspec/changes/genesis/design.md` D6
(proposals).
-- **GCM accepts IVs of 1 to 128 bytes, keys of 16, 24 and 32 bytes and tags
- of 16 bytes on every backend, and refuses a message over 2^36 - 32 bytes
- and additional data over 2^61 - 1 bytes with `message_too_long`.** OpenSSL
- accepts no IV longer than 128 bytes, so without webcpp's cap the same call
- would succeed or fail by backend; the limits are NIST SP 800-38D's; the
- page says that a key meant for WebCrypto is of 16 or 32 bytes.
+- **GCM accepts nonces of 1 to 128 bytes, keys of 16, 24 and 32 bytes and
+ tags of 16 bytes on every backend, and refuses a message over 2^36 - 32
+ bytes and associated data over 2^61 - 1 bytes with `message_too_long`.**
+ OpenSSL accepts no nonce longer than 128 bytes, so without webcpp's cap the
+ same call would succeed or fail by backend; the limits are NIST SP 800-38D's;
+ the page says that a key meant for WebCrypto is of 16 or 32 bytes.
Source: `libraries/crypto/openspec/changes/genesis/design.md` D7 and D8
(proposals).
-- **An AEAD object is used by one thread at a time, and the page says that an
- IV is never repeated under one key and gives the limit of 2^32 messages per
- key with random IVs.** It holds a message's state and a key; a repeated IV
- exposes the XOR of the plaintexts and lets an attacker forge tags.
+- **An AEAD object is used by one thread at a time, and the page says that a
+ nonce is never repeated under one key and gives the limit of 2^32 messages
+ per key with random nonces.** It holds a message's state and a key; a
+ repeated nonce exposes the XOR of the plaintexts and lets an attacker forge
+ tags.
Source: `libraries/crypto/openspec/changes/genesis/reference/spec.md`
section 2.4 (proposals); `doc/aead.adoc` (libs/crypto).
**Block cipher.**
- **`ciphers::aes128`, `aes192` and `aes256` are complete types for every
- backend; `make`, `encrypt` and `decrypt` exist on ctaes and OpenSSL, and
- BearSSL's `make` stops with a `static_assert` that names them; the block
+ backend; `from_key`, `encrypt` and `decrypt` exist on ctaes and OpenSSL, and
+ BearSSL's `from_key` stops with a `static_assert` that names them; the block
cipher has no default backend of its own.** BearSSL exports AES only inside
its modes; `aes256<>` stays the cipher of `aes256_gcm`, which a second
default would break.
@@ -7199,16 +7220,16 @@ and not built is in chapter 17.
- **`curves::p256` is a family of its own, on BearSSL, its one backend and
default on all four targets; OpenSSL and Botan join in their increments.**
- A key pair made from its 32-byte scalar (`make`, refused before BearSSL when
- 0 or not below n, by a constant-time check whose verdict alone is public) or
- drawn (`generate`), its public point computed once; a `public_key` validated
- once where it arrives, SEC 1's uncompressed point or its two coordinates;
- ECDSA over a SHA-256 digest with RFC 6979's nonce, raw (WebCrypto's form)
- and strict DER; ECDH's raw x, as WebCrypto's `deriveBits` gives it. BearSSL
- allocates nothing; natively it runs `br_ec_p256_m62` where BearSSL has a
- 128-bit product, on WebAssembly `br_ec_p256_m31` always. BearSSL's own
- stack frames keep what they compute from the scalar, which webcpp cannot
- wipe; the page says so.
+ A key pair made from its 32-byte scalar (`from_secret`, refused before
+ BearSSL when 0 or not below n, by a constant-time check whose verdict alone
+ is public) or drawn (`generate`), its public point computed once; a
+ `public_key` validated once where it arrives, SEC 1's uncompressed point or
+ its two coordinates; ECDSA over a SHA-256 digest with RFC 6979's nonce, raw
+ (WebCrypto's form) and strict DER; ECDH's raw x, as WebCrypto's `deriveBits`
+ gives it. BearSSL allocates nothing; natively it runs `br_ec_p256_m62` where
+ BearSSL has a 128-bit product, on WebAssembly `br_ec_p256_m31` always.
+ BearSSL's own stack frames keep what they compute from the scalar, which
+ webcpp cannot wipe; the page says so.
Source: `libraries/crypto/openspec/changes/foundation/design.md` D36
(proposals); `include/webcpp/crypto/curves/p256.hpp` and
`backends/bearssl.hpp` (libs/crypto).
@@ -7237,12 +7258,39 @@ and not built is in chapter 17.
input)` and `crypto::verify(scheme, signature, input, public_key)`, and
their `async_` forms, on Ed25519, P-256 and secp256k1; a digest only as
`crypto::prehashed{digest}`; every key pair a `crypto::keypair`, with a
- typed public key, `secret()` and `agree`.** A span is a message whatever
- its size, so a 32-byte message is never read as a digest; a pair of scheme
- and input that is not valid stops the build with its reason. `Backend` is
- the first template parameter of every `crypto::verify`.
+ typed public key and `secret()`.** A span is a message whatever its size,
+ so a 32-byte message is never read as a digest; a pair of scheme and input
+ that is not valid stops the build with its reason. `Backend` is the first
+ template parameter of every `crypto::verify`.
Source: `include/webcpp/crypto/signing.hpp`, `keypair.hpp` (libs/crypto);
`libraries/crypto/openspec/changes/unified-sign/design.md` (proposals).
+- **Every value has its type: signatures per curve and scheme, X25519's keys;
+ key pairs, AEADs and boxes checked by concepts; constructions by purpose;
+ factories named by their input.** Five signature types
+ (`ed25519::signature`, P-256's and secp256k1's `ecdsa_signature`,
+ `recoverable_signature`, `schnorr_signature`), made from bytes by
+ `from_bytes` and converting into nothing; `x25519::public_key` and
+ `x25519::basic_keypair`; the concepts `keypair`, `signing_keypair`,
+ `agreement_keypair`, `secret_key_encryption::aead::cipher`,
+ `streaming_cipher` and `secret_key_encryption::authenticated_box`, each
+ type's header checking its own row; the namespaces `secret_key_encryption`,
+ `public_key_encryption` and `key_exchange`, named by the problem they solve;
+ `from_secret`, `from_bytes`, `from_key`, `from_keys`, `from_keypair`,
+ `derive_from_seed` and `generate`, with no `make`. Ed25519ph is a scheme,
+ `eddsa_prehashed`; the secret-hygiene utilities are named by what they do:
+ `constant_time_equal`, `erase_secret`; the AEAD contract is
+ `secret_key_encryption::aead`'s and the secret boxes
+ `secret_key_encryption`'s; the one-shot ChaCha20-Poly1305 template is
+ `ciphers::basic_chacha20_poly1305`. Bytes passed where a signature or a key
+ of another curve was meant compiled and failed at run time, or verified
+ under the wrong scheme; generic code needs a contract the compiler checks; a
+ factory called `make` read as drawing a key, and a caller who passed fixed
+ bytes got a predictable private key.
+ Source: `include/webcpp/crypto/detail/signature.hpp`, `keypair.hpp`,
+ `factories.hpp`, `secret_key_encryption/aead.hpp`,
+ `secret_key_encryption/authenticated_box.hpp` (libs/crypto);
+ `libraries/crypto/openspec/changes/uniform-types/design.md` owner decisions
+ 1 to 14, D1 to D12 (proposals).
- **Constant time, sizes and throughput cover the family.** memcheck and
MemorySanitizer run the key pair's making, signing with its low-S
normalization and check, `agree` and `decode_pkcs8` (`paths.hpp`), each
@@ -7317,9 +7365,9 @@ and not built is in chapter 17.
core constant time.
Source: `doc/jamfile.adoc`, `doc/backends.adoc` (libs/crypto); the owner's
decision 2 of 2026-11-14 (proposals, `reference/plan.md`).
-- **OpenSSL is given the key once, in `make`; each message re-initialises
+- **OpenSSL is given the key once, in `from_key`; each message re-initialises
the context with a null key; lengths go in pieces of at most `INT_MAX`
- rounded down to a multiple of 16; `make` maps a null `EVP_CIPHER_CTX_new`
+ rounded down to a multiple of 16; `from_key` maps a null `EVP_CIPHER_CTX_new`
to `not_enough_memory` and a failed fetch or init to `backend_failure`; and
the thread's error queue is left as it was found.** EVP takes lengths as
`int`; the error queue cannot tell a memory failure apart across versions;
@@ -7384,9 +7432,9 @@ and not built is in chapter 17.
off on Windows; libsecp256k1's context is randomized from `random_device`;
webcpp never calls `RAND_bytes`.** No backend chooses its own entropy.
Source: `third_party/Jamfile` (webcpp).
-- **webcpp's code allocates only `keypair::make`'s context, in the resource
- the user gives; no seal, open, `encrypt`, `fill`, signature, `agree` or
- verification allocates on any backend; OpenSSL's `make` allocates its
+- **webcpp's code allocates only `keypair::from_secret`'s context, in the
+ resource the user gives; no seal, open, `encrypt`, `fill`, signature, `agree`
+ or verification allocates on any backend; OpenSSL's `from_key` allocates its
context through OpenSSL's own allocator, which its page states and
`allocation_openssl` counts, unless the program takes OpenSSL's memory
option (below), which sends every allocation of OpenSSL's to the program's
@@ -7438,7 +7486,7 @@ and not built is in chapter 17.
functions other than OpenSSL's three defaults are
`memory_functions_refused`, then the resource is constructed, then the
adapter is installed, and OpenSSL's refusal is `memory_functions_refused`;
- every OpenSSL `make` under the option checks that the adapter is in place
+ every OpenSSL `from_key` under the option checks that the adapter is in place
and otherwise returns `memory_functions_not_installed`.** Replacing another
party's functions would make OpenSSL free that party's blocks through
webcpp's adapter; a forgotten install gives an error, not an allocation
@@ -7494,7 +7542,7 @@ and not built is in chapter 17.
every call of the C library's allocator through an interposer per system;
and `neighbours`, beside Asio's TLS and libdatachannel; `header_alone` and
the `windows_h` twins compile. The fixtures `memory_option`,
- `memory_missing_definition_install`, `memory_missing_definition_make`,
+ `memory_missing_definition_install`, `memory_missing_definition_from_key`,
`memory_two_files` and `openssl_memory_on_emscripten` build the user's
Jamfiles, and `test/messages` and `test/msvc` check each `#error`.** The
counter proves the whole process, Beast's TLS and libdatachannel's DTLS
@@ -7569,7 +7617,7 @@ and not built is in chapter 17.
pieces; FIPS 197 for the block cipher; BIP340's vectors, Wycheproof's
Bitcoin ECDSA file and DER through `from_der`, and BIP341's wallet
vectors through the tweak.** Every case runs because keys of 24 bytes and
- IVs of any size up to 128 are accepted.
+ nonces of any size up to 128 are accepted.
Source: `test/Jamfile` (libs/crypto); `third_party/libs/wycheproof`,
`third_party/libs/bips` (webcpp).
- **BearSSL and OpenSSL are compared on AES-GCM, and ctaes and OpenSSL on the
@@ -8835,20 +8883,20 @@ increments 1 and 2, whose state is first.
and the caller lends the workspace.** libsecp256k1 checks counts, a used
nonce and an id with `ARG_CHECK`, whose callback aborts; the functions
return `invalid_input_size` or another error before it is reached. A
- function that needs scratch space (`pubkey_combine`, the MuSig2 aggregates)
- takes a `workspace` the caller sizes with `combine_workspace_size` or
- `workspace_size`, and wipes it on every return, a refusal's included, so no
- function allocates. A silent payments label lookup returns exactly
- `std::optional>` into bytes it owns:
- libsecp256k1 reads them after the lookup returns, so a result by value, a
- convertible one included, is refused at compile time.
+ function that needs scratch space (`public_key_combine`, the MuSig2
+ aggregates) takes a `workspace` the caller sizes with
+ `combine_workspace_size` or `workspace_size`, and wipes it on every return,
+ a refusal's included, so no function allocates. A silent payments label
+ lookup returns exactly `std::optional>`
+ into bytes it owns: libsecp256k1 reads them after the lookup returns, so a
+ result by value, a convertible one included, is refused at compile time.
Source: `libs/crypto/include/webcpp/crypto/curves/secp256k1/tweak.hpp`,
`musig.hpp` and `silent_payments.hpp`.
- **Constant time and sizes extend to the modules.** Memcheck and
MemorySanitizer check libsecp256k1's own `ctime_tests.c` and webcpp's code
around each module (the key pair's making, its signatures and tweak, the
three ECDH forms, the key tweaks, PKCS#8, ElligatorSwift's `create` and
- `xdh`, MuSig2's `nonce_gen` and `partial_sign`, the silent payments'
+ `xdh`, MuSig2's `generate_nonce` and `partial_sign`, the silent payments'
`create_outputs`, `create_label` and `scan_outputs`, each workspace's wipe
included), written once in `test/constant_time/paths.hpp`; dudect times
`agree` natively and on wasip2, in a program of its own, so that
@@ -8883,8 +8931,8 @@ Tasks 3.1 to 3.6, built on its branch, merged 2026-11-22).**
(Valgrind memcheck and MemorySanitizer, each harness failing on a planted
leak, and libsecp256k1's `ctime_tests`), and statistically by dudect's
method natively and under wasmtime on wasip2, through the seam
- `WEBCPP_CRYPTO_DETAIL_DECLASSIFY`.** `equal` compiles in the user's
- translation unit, so it is checked at -O2 and -Os; under wasmtime the
+ `WEBCPP_CRYPTO_DETAIL_DECLASSIFY`.** `constant_time_equal` compiles in the
+ user's translation unit, so it is checked at -O2 and -Os; under wasmtime the
engine's compiler decides whether BearSSL's `bmul64` stays constant time.
The page's per-target cells are generated from the lane's own entries, and
a target the lane does not run says "not measured yet".
@@ -8955,13 +9003,13 @@ Tasks 3.1 to 3.6, built on its branch, merged 2026-11-22).**
**ChaCha20-Poly1305 (built in increment 1, Task 8b, merged; the genesis's increment 4).**
- **`ciphers::chacha20_poly1305` on BearSSL and OpenSSL is one shot only,
- with an IV of exactly 12 bytes, refuses a message over 2^38 - 64 bytes with
+ with a nonce of exactly 12 bytes, refuses a message over 2^38 - 64 bytes with
`message_too_long`, and where BearSSL leaves the tag check to its caller the
- backend compares with `equal` and zeroes `data` on a mismatch; it is a
- family of the one-shot template `ciphers::aead`, not
- new traits.** BearSSL's
- ChaCha20-Poly1305 is one function over the whole message; 12 bytes and the
- limit are RFC 8439's.
+ backend compares with `constant_time_equal` and zeroes `data` on a mismatch;
+ it is a family of the one-shot template
+ `ciphers::basic_chacha20_poly1305`, not new traits.**
+ BearSSL's ChaCha20-Poly1305 is one function over the whole message; 12
+ bytes and the limit are RFC 8439's.
Source: `libraries/crypto/openspec/changes/genesis/reference/spec.md`
section 2.5 (proposals).
- **The BearSSL backend takes `br_chacha20_sse2_get()` else
@@ -9588,6 +9636,11 @@ and G4); the proposal, with the specification, the design and the plan, is in
D1 to D9 (proposals); `include/webcpp/hash/detail/timing.hpp`,
`test/timing_coverage__test.cpp` (libs/hash);
`test/timing_hash_interop_test.cpp` (libs/crypto).
+- **hash follows crypto's naming rule: public names spelled out, algorithm
+ proper names excepted.** HKDF's `ikm`, `prk` and `info` are renamed by a
+ change of hash's.
+ Source: `libraries/crypto/openspec/changes/uniform-types/design.md` owner
+ decision 13, D11 (proposals).
- **Seven increments, each usable alone.** The first, built, is Hash2 by alias,
`keccak_256`, `blake3`, HKDF, PBKDF2, Argon2id, scrypt, the default backend
and the measured table; the second, built, is the families and libsodium's
diff --git a/libs/crypto b/libs/crypto
index 02552068..3314a1d1 160000
--- a/libs/crypto
+++ b/libs/crypto
@@ -1 +1 @@
-Subproject commit 025520686003828307e7de26f17a645b492f5183
+Subproject commit 3314a1d122220f960fc72920b239131ee314b6a3
diff --git a/libs/hash b/libs/hash
index eed3aab4..030e7572 160000
--- a/libs/hash
+++ b/libs/hash
@@ -1 +1 @@
-Subproject commit eed3aab4954871060b00ac59f9f10eb4b3b40226
+Subproject commit 030e7572e7f89120639fe807c717ae91353d87e1
diff --git a/tools/test/fixtures/crypto_jamfiles/aead_not_a_family_on_emscripten/aead_not_a_family_on_emscripten.outcome b/tools/test/fixtures/crypto_jamfiles/aead_not_a_family_on_emscripten/aead_not_a_family_on_emscripten.outcome
index 640f96ae..a7832249 100644
--- a/tools/test/fixtures/crypto_jamfiles/aead_not_a_family_on_emscripten/aead_not_a_family_on_emscripten.outcome
+++ b/tools/test/fixtures/crypto_jamfiles/aead_not_a_family_on_emscripten/aead_not_a_family_on_emscripten.outcome
@@ -12,5 +12,5 @@
targets: emscripten
build: fails
# tag::messages[]
-contains: webcpp::crypto: ciphers::aead takes an AEAD family: families::chacha20_poly1305, families::chacha20_poly1305_original, families::xchacha20_poly1305, families::secretbox_xsalsa20poly1305 or families::secretbox_xchacha20poly1305.
+contains: webcpp::crypto: ciphers::basic_chacha20_poly1305 takes an AEAD family: families::chacha20_poly1305, families::chacha20_poly1305_original or families::xchacha20_poly1305.
# end::messages[]
diff --git a/tools/test/fixtures/crypto_jamfiles/aead_not_a_family_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/aead_not_a_family_on_emscripten/app.cpp
index 5a12fa21..91cf10ae 100644
--- a/tools/test/fixtures/crypto_jamfiles/aead_not_a_family_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/aead_not_a_family_on_emscripten/app.cpp
@@ -4,7 +4,8 @@
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
-// A program for Emscripten that gives ciphers::aead a family that is no AEAD's, AES-GCM's.
+// A program for Emscripten that gives ciphers::basic_chacha20_poly1305 a family that is no AEAD's,
+// AES-GCM's.
#include
#include
@@ -13,7 +14,8 @@
int main() {
namespace crypto = webcpp::crypto;
- using aead = crypto::ciphers::aead;
+ using cipher =
+ crypto::ciphers::basic_chacha20_poly1305;
std::array const key{};
- return aead::make(key) ? 0 : 1;
+ return cipher::from_key(key) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/aes_block_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/aes_block_default/app.cpp
index b54dd449..d8a2ee38 100644
--- a/tools/test/fixtures/crypto_jamfiles/aes_block_default/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/aes_block_default/app.cpp
@@ -27,7 +27,7 @@ int main() {
0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89,
};
std::array block = plain;
- auto aes = webcpp::crypto::ciphers::aes256<>::make(key);
+ auto aes = webcpp::crypto::ciphers::aes256<>::from_key(key);
bool const ok =
aes && aes->encrypt(block) && block == expected && aes->decrypt(block) && block == plain;
auto const name = webcpp::crypto::ciphers::aes256<>::backend_type::name;
diff --git a/tools/test/fixtures/crypto_jamfiles/aes_block_default_not_linked_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/aes_block_default_not_linked_on_emscripten/app.cpp
index 772d7157..4ae90902 100644
--- a/tools/test/fixtures/crypto_jamfiles/aes_block_default_not_linked_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/aes_block_default_not_linked_on_emscripten/app.cpp
@@ -13,5 +13,5 @@
int main() {
std::array const key{};
- return webcpp::crypto::ciphers::aes256<>::make(key) ? 0 : 1;
+ return webcpp::crypto::ciphers::aes256<>::from_key(key) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/block/block.cpp b/tools/test/fixtures/crypto_jamfiles/block/block.cpp
index 659cfb57..d24bdde4 100644
--- a/tools/test/fixtures/crypto_jamfiles/block/block.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/block/block.cpp
@@ -27,7 +27,7 @@ int main() {
0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89,
};
std::array block = plain;
- auto aes = webcpp::crypto::ciphers::aes256::make(key);
+ auto aes = webcpp::crypto::ciphers::aes256::from_key(key);
bool const ok =
aes && aes->encrypt(block) && block == expected && aes->decrypt(block) && block == plain;
std::printf("ctaes aes256 %s\n", ok ? "ok" : "FAILED");
diff --git a/tools/test/fixtures/crypto_jamfiles/both_bearssl_named/app.cpp b/tools/test/fixtures/crypto_jamfiles/both_bearssl_named/app.cpp
index 64319067..b9f9955a 100644
--- a/tools/test/fixtures/crypto_jamfiles/both_bearssl_named/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/both_bearssl_named/app.cpp
@@ -6,13 +6,13 @@
// Seals one zero block under AES-256-GCM on BearSSL, named in the type where OpenSSL, linked
// too, is the default natively, and checks it against the GCM specification's test case 14 (key,
-// IV and plaintext all zero), then opens it again, and prints the backend that ran. The zero key
-// and IV are the test vector's: a real program draws its key from random_device and never reuses
-// an IV under it.
+// nonce and plaintext all zero), then opens it again, and prints the backend that ran. The zero key
+// and nonce are the test vector's: a real program draws its key from random_device and never reuses
+// a nonce under it.
#include
#include
#include
-#include
+#include
#include
#include
@@ -25,7 +25,7 @@ using aead_type = crypto::ciphers::gcm const key{};
- std::array const iv{};
+ std::array const nonce{};
std::array data{};
std::array const cipher{
0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e,
@@ -35,14 +35,15 @@ int main() {
0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0,
0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19,
};
- auto aead = aead_type::make(key);
+ auto aead = aead_type::from_key(key);
if (!aead) {
return 1;
}
- auto const tag = aead->seal(iv, {}, data);
- bool const sealed = tag && data == cipher && webcpp::crypto::equal(*tag, expected_tag);
+ auto const tag = aead->seal(nonce, {}, data);
+ bool const sealed =
+ tag && data == cipher && webcpp::crypto::constant_time_equal(*tag, expected_tag);
bool const opened =
- aead->open(iv, {}, data, expected_tag) && data == std::array{};
+ aead->open(nonce, {}, data, expected_tag) && data == std::array{};
auto const name = aead_type::backend_type::name;
std::printf("aes256_gcm %s backend=%.*s\n", sealed && opened ? "ok" : "FAILED",
static_cast(name.size()), name.data());
diff --git a/tools/test/fixtures/crypto_jamfiles/box_default_not_linked_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/box_default_not_linked_on_emscripten/app.cpp
index ff84d5d4..31cea0d1 100644
--- a/tools/test/fixtures/crypto_jamfiles/box_default_not_linked_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/box_default_not_linked_on_emscripten/app.cpp
@@ -6,22 +6,38 @@
// As test/messages/box_default_not_linked, on Emscripten.
-#include
-#include
-#include
+#include
+#include
+#include
+#include
#include
#include
-int main() {
- namespace crypto = webcpp::crypto;
+namespace {
+
+namespace crypto = webcpp::crypto;
+
+/**
+ * Calls each, the key pair and the peer's public key parameters: making them would call X25519's
+ * engine, whose own refusal is not the one under test.
+ */
+bool called(crypto::curves::x25519::keypair const& own_keypair,
+ crypto::curves::x25519::public_key const& peer_public_key) {
std::array const key{};
std::array sealed{};
- return crypto::ciphers::secretbox<>::make(key) &&
- crypto::ciphers::secretbox_xchacha20poly1305<>::make(key) &&
- crypto::hybrid::box::make(key, key) &&
- crypto::hybrid::box_xchacha20poly1305::make(key, key) &&
- crypto::hybrid::sealed_box::seal(key, {}, sealed)
- ? 0
- : 1;
+ return crypto::secret_key_encryption::secretbox<>::from_key(key) &&
+ crypto::secret_key_encryption::secretbox_xchacha20poly1305<>::from_key(key) &&
+ crypto::public_key_encryption::box::from_keys(own_keypair, peer_public_key) &&
+ crypto::public_key_encryption::box_xchacha20poly1305::from_keys(own_keypair,
+ peer_public_key) &&
+ crypto::public_key_encryption::sealed_box::seal(peer_public_key, {}, sealed);
+}
+
+} // namespace
+
+// The function is compiled, which is the test; it is never run.
+int main() {
+ static_cast(&called);
+ return 0;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/box_not_a_family_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/box_not_a_family_on_emscripten/app.cpp
index 3e263b23..117e33f4 100644
--- a/tools/test/fixtures/crypto_jamfiles/box_not_a_family_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/box_not_a_family_on_emscripten/app.cpp
@@ -6,19 +6,28 @@
// As test/messages/box_not_a_family, on Emscripten.
-#include
-
-#include
-#include
+#include
+#include
namespace {
/** A type that names no family, and so has no default backend. */
struct not_a_family {};
+/**
+ * Makes the box from a key pair and a peer's public key, which are parameters: making them would
+ * call X25519's engine.
+ */
+bool made(webcpp::crypto::curves::x25519::keypair const& own_keypair,
+ webcpp::crypto::curves::x25519::public_key const& peer_public_key) {
+ using box = webcpp::crypto::public_key_encryption::basic_box;
+ return box::from_keys(own_keypair, peer_public_key).has_value();
+}
+
} // namespace
+// The function is compiled, which is the test; it is never run.
int main() {
- std::array const key{};
- return webcpp::crypto::hybrid::basic_box::make(key, key) ? 0 : 1;
+ static_cast(&made);
+ return 0;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/box_not_a_family_on_emscripten/box_not_a_family_on_emscripten.outcome b/tools/test/fixtures/crypto_jamfiles/box_not_a_family_on_emscripten/box_not_a_family_on_emscripten.outcome
index 0f59b244..560996b6 100644
--- a/tools/test/fixtures/crypto_jamfiles/box_not_a_family_on_emscripten/box_not_a_family_on_emscripten.outcome
+++ b/tools/test/fixtures/crypto_jamfiles/box_not_a_family_on_emscripten/box_not_a_family_on_emscripten.outcome
@@ -12,5 +12,5 @@
targets: emscripten
build: fails
# tag::messages[]
-contains: webcpp::crypto: hybrid::basic_box takes a box family: families::box_xsalsa20poly1305 or families::box_xchacha20poly1305.
+contains: webcpp::crypto: public_key_encryption::basic_box takes a box family: families::box_xsalsa20poly1305 or families::box_xchacha20poly1305.
# end::messages[]
diff --git a/tools/test/fixtures/crypto_jamfiles/box_xchacha20poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/box_xchacha20poly1305_default/app.cpp
index 1047963b..5c8d67f1 100644
--- a/tools/test/fixtures/crypto_jamfiles/box_xchacha20poly1305_default/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/box_xchacha20poly1305_default/app.cpp
@@ -6,10 +6,12 @@
// Seals NaCl's message from Alice to Bob in the XChaCha20 box on the default backend,
// checks the tag and the ciphertext's first bytes against those libsodium's own test suite
-// does not print and an independent implementation computed, opens it with Bob's keys, and
-// prints the backend that ran. The keys and nonce are NaCl's test's.
-#include
-#include
+// does not print and an independent implementation computed, opens it with Bob's keys, each an
+// X25519 key pair and the peer's public key, and prints the backend that ran. The keys and nonce
+// are NaCl's test's.
+#include
+#include
+#include
#include
#include
@@ -37,7 +39,7 @@ std::array from_hex(std::string_view hex) {
} // namespace
int main() {
- using box = webcpp::crypto::hybrid::box_xchacha20poly1305;
+ using box = webcpp::crypto::public_key_encryption::box_xchacha20poly1305;
auto const alice_secret =
from_hex<32>("77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a");
auto const alice_public =
@@ -46,7 +48,7 @@ int main() {
from_hex<32>("5dab087e624a8a4b79e17f8b83800ee66f3bb1292618b6fd1c2f8b27ff88e0eb");
auto const bob_public =
from_hex<32>("de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f");
- auto const iv = from_hex<24>("69696ee955b62b73cd62bda875fc73d68219e0036b7a0b37");
+ auto const nonce = from_hex<24>("69696ee955b62b73cd62bda875fc73d68219e0036b7a0b37");
auto const plaintext = from_hex<131>(
"be075fc53c81f2d5cf141316ebeb0c7b5228c52a4c62cbd44b66849b64244ffce5ecbaaf33bd751a1ac7"
"28d45e6c61296cdc3c01233561f41db66cce314adb310e3be8250c46f06dceea3a7fa1348057e2f6556a"
@@ -55,14 +57,23 @@ int main() {
auto const expected_tag = from_hex<16>("0b4ff00742f3c1aa99a6321e3883b03c");
auto const expected_head = from_hex<8>("ef2c6061b7bcec0c");
auto data = plaintext;
- auto alice = box::make(alice_secret, bob_public);
- auto bob = box::make(bob_secret, alice_public);
+ namespace x25519 = webcpp::crypto::curves::x25519;
+ auto const alice_pair = x25519::keypair::from_secret(alice_secret);
+ auto const bob_pair = x25519::keypair::from_secret(bob_secret);
+ auto const alice_key = x25519::public_key::from_bytes(alice_public);
+ auto const bob_key = x25519::public_key::from_bytes(bob_public);
bool ok = false;
+ if (!alice_pair || !bob_pair || !alice_key || !bob_key) {
+ std::printf("box_xchacha20poly1305 FAILED\n");
+ return 1;
+ }
+ auto alice = box::from_keys(*alice_pair, *bob_key);
+ auto bob = box::from_keys(*bob_pair, *alice_key);
if (alice && bob) {
- auto const sealed = alice->seal(iv, data);
- ok = sealed && webcpp::crypto::equal(*sealed, expected_tag) &&
+ auto const sealed = alice->seal(nonce, data);
+ ok = sealed && webcpp::crypto::constant_time_equal(*sealed, expected_tag) &&
std::equal(expected_head.begin(), expected_head.end(), data.begin()) &&
- bob->open(iv, data, *sealed) && data == plaintext;
+ bob->open(nonce, data, *sealed) && data == plaintext;
}
auto const name = box::backend_type::name;
std::printf("box_xchacha20poly1305 %s backend=%.*s\n", ok ? "ok" : "FAILED",
diff --git a/tools/test/fixtures/crypto_jamfiles/box_xsalsa20poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/box_xsalsa20poly1305_default/app.cpp
index 2d721847..7401ecd4 100644
--- a/tools/test/fixtures/crypto_jamfiles/box_xsalsa20poly1305_default/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/box_xsalsa20poly1305_default/app.cpp
@@ -6,10 +6,12 @@
// Seals NaCl's box (libsodium's test/default/box.c) from Alice to Bob on the default
// backend, checks the tag and the ciphertext's first bytes against box.exp, opens it with Bob's
-// keys (box2.c), and prints the backend that ran. The keys and nonce are the test's: a real
-// program draws its secret key from random_device, and a nonce at random for every message.
-#include
-#include
+// keys (box2.c), each an X25519 key pair and the peer's public key, and prints the backend that
+// ran. The keys and nonce are the test's: a real program draws its key pair with generate(), and
+// a nonce at random for every message.
+#include
+#include
+#include
#include
#include
@@ -37,7 +39,7 @@ std::array from_hex(std::string_view hex) {
} // namespace
int main() {
- using webcpp::crypto::hybrid::box;
+ using webcpp::crypto::public_key_encryption::box;
auto const alice_secret =
from_hex<32>("77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a");
auto const alice_public =
@@ -46,7 +48,7 @@ int main() {
from_hex<32>("5dab087e624a8a4b79e17f8b83800ee66f3bb1292618b6fd1c2f8b27ff88e0eb");
auto const bob_public =
from_hex<32>("de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f");
- auto const iv = from_hex<24>("69696ee955b62b73cd62bda875fc73d68219e0036b7a0b37");
+ auto const nonce = from_hex<24>("69696ee955b62b73cd62bda875fc73d68219e0036b7a0b37");
auto const plaintext = from_hex<131>(
"be075fc53c81f2d5cf141316ebeb0c7b5228c52a4c62cbd44b66849b64244ffce5ecbaaf33bd751a1ac7"
"28d45e6c61296cdc3c01233561f41db66cce314adb310e3be8250c46f06dceea3a7fa1348057e2f6556a"
@@ -55,14 +57,23 @@ int main() {
auto const expected_tag = from_hex<16>("f3ffc7703f9400e52a7dfb4b3d3305d9");
auto const expected_head = from_hex<8>("8e993b9f48681273");
auto data = plaintext;
- auto alice = box::make(alice_secret, bob_public);
- auto bob = box::make(bob_secret, alice_public);
+ namespace x25519 = webcpp::crypto::curves::x25519;
+ auto const alice_pair = x25519::keypair::from_secret(alice_secret);
+ auto const bob_pair = x25519::keypair::from_secret(bob_secret);
+ auto const alice_key = x25519::public_key::from_bytes(alice_public);
+ auto const bob_key = x25519::public_key::from_bytes(bob_public);
bool ok = false;
+ if (!alice_pair || !bob_pair || !alice_key || !bob_key) {
+ std::printf("box FAILED\n");
+ return 1;
+ }
+ auto alice = box::from_keys(*alice_pair, *bob_key);
+ auto bob = box::from_keys(*bob_pair, *alice_key);
if (alice && bob) {
- auto const sealed = alice->seal(iv, data);
- ok = sealed && webcpp::crypto::equal(*sealed, expected_tag) &&
+ auto const sealed = alice->seal(nonce, data);
+ ok = sealed && webcpp::crypto::constant_time_equal(*sealed, expected_tag) &&
std::equal(expected_head.begin(), expected_head.end(), data.begin()) &&
- bob->open(iv, data, *sealed) && data == plaintext;
+ bob->open(nonce, data, *sealed) && data == plaintext;
}
auto const name = box::backend_type::name;
std::printf("box %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()),
diff --git a/tools/test/fixtures/crypto_jamfiles/canary_ctaes_missing/app.cpp b/tools/test/fixtures/crypto_jamfiles/canary_ctaes_missing/app.cpp
index 4d687f7b..79bb3fee 100644
--- a/tools/test/fixtures/crypto_jamfiles/canary_ctaes_missing/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/canary_ctaes_missing/app.cpp
@@ -15,6 +15,6 @@
int main() {
std::array const key{};
std::array block{};
- auto aes = webcpp::crypto::ciphers::aes256::make(key);
+ auto aes = webcpp::crypto::ciphers::aes256::from_key(key);
return aes && aes->encrypt(block) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/canary_missing/app.cpp b/tools/test/fixtures/crypto_jamfiles/canary_missing/app.cpp
index 9e538fc8..22d1e5e3 100644
--- a/tools/test/fixtures/crypto_jamfiles/canary_missing/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/canary_missing/app.cpp
@@ -15,9 +15,9 @@
int main() {
std::array const key{};
- std::array const iv{};
+ std::array const nonce{};
std::array data{};
auto aead = webcpp::crypto::ciphers::gcm<
- webcpp::crypto::ciphers::aes256>::make(key);
- return aead && aead->seal(iv, {}, data) ? 0 : 1;
+ webcpp::crypto::ciphers::aes256>::from_key(key);
+ return aead && aead->seal(nonce, {}, data) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/canary_other_commit/app.cpp b/tools/test/fixtures/crypto_jamfiles/canary_other_commit/app.cpp
index 9e538fc8..22d1e5e3 100644
--- a/tools/test/fixtures/crypto_jamfiles/canary_other_commit/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/canary_other_commit/app.cpp
@@ -15,9 +15,9 @@
int main() {
std::array const key{};
- std::array const iv{};
+ std::array const nonce{};
std::array data{};
auto aead = webcpp::crypto::ciphers::gcm<
- webcpp::crypto::ciphers::aes256>::make(key);
- return aead && aead->seal(iv, {}, data) ? 0 : 1;
+ webcpp::crypto::ciphers::aes256>::from_key(key);
+ return aead && aead->seal(nonce, {}, data) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/app.cpp b/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/app.cpp
index 9e538fc8..22d1e5e3 100644
--- a/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/app.cpp
@@ -15,9 +15,9 @@
int main() {
std::array const key{};
- std::array const iv{};
+ std::array const nonce{};
std::array data{};
auto aead = webcpp::crypto::ciphers::gcm<
- webcpp::crypto::ciphers::aes256>::make(key);
- return aead && aead->seal(iv, {}, data) ? 0 : 1;
+ webcpp::crypto::ciphers::aes256>::from_key(key);
+ return aead && aead->seal(nonce, {}, data) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_missing/app.cpp b/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_missing/app.cpp
index f6b4a1b1..9c74a121 100644
--- a/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_missing/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_missing/app.cpp
@@ -17,6 +17,6 @@ int main() {
secret.fill(0x42);
std::array const message{};
std::array const aux{};
- auto key = webcpp::crypto::curves::secp256k1::keypair::make(secret);
+ auto key = webcpp::crypto::curves::secp256k1::keypair::from_secret(secret);
return key && key->sign(webcpp::crypto::schnorr, message, aux) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_small/app.cpp b/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_small/app.cpp
index f6b4a1b1..9c74a121 100644
--- a/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_small/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_small/app.cpp
@@ -17,6 +17,6 @@ int main() {
secret.fill(0x42);
std::array const message{};
std::array const aux{};
- auto key = webcpp::crypto::curves::secp256k1::keypair::make(secret);
+ auto key = webcpp::crypto::curves::secp256k1::keypair::from_secret(secret);
return key && key->sign(webcpp::crypto::schnorr, message, aux) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/canary_without/app.cpp b/tools/test/fixtures/crypto_jamfiles/canary_without/app.cpp
index 9e538fc8..22d1e5e3 100644
--- a/tools/test/fixtures/crypto_jamfiles/canary_without/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/canary_without/app.cpp
@@ -15,9 +15,9 @@
int main() {
std::array const key{};
- std::array const iv{};
+ std::array const nonce{};
std::array data{};
auto aead = webcpp::crypto::ciphers::gcm<
- webcpp::crypto::ciphers::aes256>::make(key);
- return aead && aead->seal(iv, {}, data) ? 0 : 1;
+ webcpp::crypto::ciphers::aes256>::from_key(key);
+ return aead && aead->seal(nonce, {}, data) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/chacha20_poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/chacha20_poly1305_default/app.cpp
index 35709070..f7bae48b 100644
--- a/tools/test/fixtures/crypto_jamfiles/chacha20_poly1305_default/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/chacha20_poly1305_default/app.cpp
@@ -9,7 +9,7 @@
// that ran. The key and nonce are the RFC's: a real program draws its key from random_device and
// never reuses a nonce under it.
#include
-#include
+#include
#include
#include
@@ -27,9 +27,9 @@ int main() {
}
// NOLINTBEGIN(readability-trailing-comma): it asks a list of one row, wrapped, for the comma
// and refuses it once clang-format puts the brace on a line of its own
- std::array const iv{0x07, 0x00, 0x00, 0x00, 0x40, 0x41,
- 0x42, 0x43, 0x44, 0x45, 0x46, 0x47};
- std::array const additional_data{0x50, 0x51, 0x52, 0x53, 0xc0, 0xc1,
+ std::array const nonce{0x07, 0x00, 0x00, 0x00, 0x40, 0x41,
+ 0x42, 0x43, 0x44, 0x45, 0x46, 0x47};
+ std::array const associated_data{0x50, 0x51, 0x52, 0x53, 0xc0, 0xc1,
0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7};
// NOLINTEND(readability-trailing-comma)
constexpr std::string_view sunscreen =
@@ -43,13 +43,13 @@ int main() {
0x7e, 0x90, 0x2e, 0xcb, 0xd0, 0x60, 0x06, 0x91,
};
std::array const expected_head{0xd3, 0x1a, 0x8d, 0x34, 0x64, 0x8e, 0x60, 0xdb};
- auto sealer = aead::make(key);
+ auto sealer = aead::from_key(key);
bool ok = false;
if (sealer) {
- auto const tag = sealer->seal(iv, additional_data, data);
- ok = tag && webcpp::crypto::equal(*tag, expected_tag) &&
+ auto const tag = sealer->seal(nonce, associated_data, data);
+ ok = tag && webcpp::crypto::constant_time_equal(*tag, expected_tag) &&
std::equal(expected_head.begin(), expected_head.end(), data.begin()) &&
- sealer->open(iv, additional_data, data, expected_tag) && data == plaintext;
+ sealer->open(nonce, associated_data, data, expected_tag) && data == plaintext;
}
auto const name = aead::backend_type::name;
std::printf("chacha20_poly1305 %s backend=%.*s\n", ok ? "ok" : "FAILED",
diff --git a/tools/test/fixtures/crypto_jamfiles/chacha20_poly1305_original_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/chacha20_poly1305_original_default/app.cpp
index 9617d93b..20498eb9 100644
--- a/tools/test/fixtures/crypto_jamfiles/chacha20_poly1305_original_default/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/chacha20_poly1305_original_default/app.cpp
@@ -9,7 +9,7 @@
// ciphertext against libsodium's, opens it again, and prints the backend that ran. The key and
// nonce are the test's: a real program draws its key from random_device and numbers its nonces.
#include
-#include
+#include
#include
#include
@@ -24,10 +24,10 @@ int main() {
0x57, 0xf3, 0xbe, 0x3b, 0x50, 0x06, 0xda, 0x37, 0x1e, 0xce, 0x27,
0x2a, 0xfa, 0x1b, 0x5d, 0xbd, 0xd1, 0x10, 0x0a, 0x10, 0x07,
};
- std::array const iv{0xcd, 0x7c, 0xf6, 0x7b, 0xe3, 0x9c, 0x79, 0x4a};
+ std::array const nonce{0xcd, 0x7c, 0xf6, 0x7b, 0xe3, 0x9c, 0x79, 0x4a};
// NOLINTBEGIN(readability-trailing-comma): it asks a list of one row, wrapped, for the comma
// and refuses it once clang-format puts the brace on a line of its own
- std::array const additional_data{0x87, 0xe2, 0x29, 0xd4, 0x50,
+ std::array const associated_data{0x87, 0xe2, 0x29, 0xd4, 0x50,
0x08, 0x45, 0xa0, 0x79, 0xc0};
std::array const plaintext{0x86, 0xd0, 0x99, 0x74, 0x84,
0x0b, 0xde, 0xd2, 0xa5, 0xca};
@@ -39,13 +39,13 @@ int main() {
std::array const expected_head{0xe3, 0xe4, 0x46, 0xf7, 0xed,
0xe9, 0xa1, 0x9b, 0x62, 0xa4};
// NOLINTEND(readability-trailing-comma)
- auto sealer = aead::make(key);
+ auto sealer = aead::from_key(key);
bool ok = false;
if (sealer) {
- auto const tag = sealer->seal(iv, additional_data, data);
- ok = tag && webcpp::crypto::equal(*tag, expected_tag) &&
+ auto const tag = sealer->seal(nonce, associated_data, data);
+ ok = tag && webcpp::crypto::constant_time_equal(*tag, expected_tag) &&
std::equal(expected_head.begin(), expected_head.end(), data.begin()) &&
- sealer->open(iv, additional_data, data, expected_tag) && data == plaintext;
+ sealer->open(nonce, associated_data, data, expected_tag) && data == plaintext;
}
auto const name = aead::backend_type::name;
std::printf("chacha20_poly1305_original %s backend=%.*s\n", ok ? "ok" : "FAILED",
diff --git a/tools/test/fixtures/crypto_jamfiles/chacha_default_not_linked_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/chacha_default_not_linked_on_emscripten/app.cpp
index be09fbaf..2c0bfaad 100644
--- a/tools/test/fixtures/crypto_jamfiles/chacha_default_not_linked_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/chacha_default_not_linked_on_emscripten/app.cpp
@@ -14,9 +14,9 @@
int main() {
namespace ciphers = webcpp::crypto::ciphers;
std::array const key{};
- return ciphers::chacha20_poly1305<>::make(key) &&
- ciphers::chacha20_poly1305_original<>::make(key) &&
- ciphers::xchacha20_poly1305<>::make(key)
+ return ciphers::chacha20_poly1305<>::from_key(key) &&
+ ciphers::chacha20_poly1305_original<>::from_key(key) &&
+ ciphers::xchacha20_poly1305<>::from_key(key)
? 0
: 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/chacha_header_not_included_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/chacha_header_not_included_on_emscripten/app.cpp
index 978746f8..4c862670 100644
--- a/tools/test/fixtures/crypto_jamfiles/chacha_header_not_included_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/chacha_header_not_included_on_emscripten/app.cpp
@@ -14,5 +14,5 @@
int main() {
namespace crypto = webcpp::crypto;
std::array const key{};
- return crypto::ciphers::chacha20_poly1305::make(key) ? 0 : 1;
+ return crypto::ciphers::chacha20_poly1305::from_key(key) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/chacha_on_ctaes_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/chacha_on_ctaes_on_emscripten/app.cpp
index 6bdc0fa0..1eda0472 100644
--- a/tools/test/fixtures/crypto_jamfiles/chacha_on_ctaes_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/chacha_on_ctaes_on_emscripten/app.cpp
@@ -15,5 +15,5 @@
int main() {
namespace crypto = webcpp::crypto;
std::array const key{};
- return crypto::ciphers::chacha20_poly1305::make(key) ? 0 : 1;
+ return crypto::ciphers::chacha20_poly1305::from_key(key) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/chacha_openssl_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/chacha_openssl_on_emscripten/app.cpp
index 28b98359..47611931 100644
--- a/tools/test/fixtures/crypto_jamfiles/chacha_openssl_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/chacha_openssl_on_emscripten/app.cpp
@@ -14,5 +14,5 @@
int main() {
namespace crypto = webcpp::crypto;
std::array const key{};
- return crypto::ciphers::chacha20_poly1305::make(key) ? 0 : 1;
+ return crypto::ciphers::chacha20_poly1305::from_key(key) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/chacha_unknown_backend_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/chacha_unknown_backend_on_emscripten/app.cpp
index 470d9c8b..de36e3e2 100644
--- a/tools/test/fixtures/crypto_jamfiles/chacha_unknown_backend_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/chacha_unknown_backend_on_emscripten/app.cpp
@@ -20,5 +20,5 @@ struct my_backend {};
int main() {
std::array const key{};
- return webcpp::crypto::ciphers::chacha20_poly1305::make(key) ? 0 : 1;
+ return webcpp::crypto::ciphers::chacha20_poly1305::from_key(key) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp
index 64f6c149..4a37c2e4 100644
--- a/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp
@@ -7,8 +7,8 @@
// Signs RFC 8032's first Ed25519 test (section 7.1, TEST 1: the empty message) with a key pair
// made from its seed on the default backend, checks the signature against the RFC's and verifies
// it, and prints the backend that ran. The seed is the RFC's: a real program draws its own.
+#include
#include
-#include
#include
#include
@@ -32,12 +32,12 @@ int main() {
0x59, 0x5b, 0xbe, 0x24, 0x65, 0x51, 0x41, 0x43, 0x8e, 0x7a, 0x10, 0x0b,
};
std::span const message{};
- auto const key = ed25519::keypair::make(seed);
+ auto const key = ed25519::keypair::from_secret(seed);
bool ok = false;
if (key) {
auto const signature = key->sign(crypto::eddsa, message);
auto const public_key = key->public_key();
- ok = signature && public_key && crypto::equal(*signature, expected) &&
+ ok = signature && public_key && crypto::constant_time_equal(signature->bytes(), expected) &&
crypto::verify(crypto::eddsa, *signature, message, *public_key).has_value();
}
auto const name = ed25519::keypair::backend_type::name;
diff --git a/tools/test/fixtures/crypto_jamfiles/ed25519_default_not_linked_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/ed25519_default_not_linked_on_emscripten/app.cpp
index 09bda19e..f9fa4afa 100644
--- a/tools/test/fixtures/crypto_jamfiles/ed25519_default_not_linked_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/ed25519_default_not_linked_on_emscripten/app.cpp
@@ -12,5 +12,5 @@
int main() {
std::array const seed{};
- return webcpp::crypto::curves::ed25519::keypair::make(seed) ? 0 : 1;
+ return webcpp::crypto::curves::ed25519::keypair::from_secret(seed) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/ed25519_on_bearssl_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/ed25519_on_bearssl_on_emscripten/app.cpp
index 87d21620..f040274a 100644
--- a/tools/test/fixtures/crypto_jamfiles/ed25519_on_bearssl_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/ed25519_on_bearssl_on_emscripten/app.cpp
@@ -12,8 +12,8 @@
int main() {
std::array const seed{};
- return webcpp::crypto::curves::ed25519::basic_keypair::make(
- seed)
+ return webcpp::crypto::curves::ed25519::basic_keypair<
+ webcpp::crypto::backends::bearssl>::from_secret(seed)
? 0
: 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/app.cpp
index 30ebac05..b4e74cd8 100644
--- a/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/app.cpp
@@ -22,8 +22,8 @@ struct lenient {};
int main() {
auto const public_key =
- webcpp::crypto::curves::ed25519::public_key::make(std::array{});
- std::array const signature{};
+ webcpp::crypto::curves::ed25519::public_key::from_bytes(std::array{});
+ webcpp::crypto::curves::ed25519::signature const signature{};
return public_key &&
webcpp::crypto::verify(webcpp::crypto::eddsa, signature,
std::span{}, *public_key, lenient{})
diff --git a/tools/test/fixtures/crypto_jamfiles/ed25519ph_sha256_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/ed25519ph_sha256_on_emscripten/app.cpp
index 3439f1c2..2a2f0076 100644
--- a/tools/test/fixtures/crypto_jamfiles/ed25519ph_sha256_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/ed25519ph_sha256_on_emscripten/app.cpp
@@ -4,10 +4,12 @@
// accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
-// A program that names SHA-256 in Ed25519ph's type, which RFC 8032 defines over SHA-512.
+// A program that names SHA-256 in Ed25519ph's streaming signer, which RFC 8032 defines over
+// SHA-512.
#include
#include
int main() {
- return webcpp::crypto::curves::ed25519::ph::begin() ? 0 : 1;
+ return webcpp::crypto::curves::ed25519::prehashed_signer::begin() ? 0
+ : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/ed25519ph_sha256_on_emscripten/ed25519ph_sha256_on_emscripten.outcome b/tools/test/fixtures/crypto_jamfiles/ed25519ph_sha256_on_emscripten/ed25519ph_sha256_on_emscripten.outcome
index 64ae41e0..c4e25fd7 100644
--- a/tools/test/fixtures/crypto_jamfiles/ed25519ph_sha256_on_emscripten/ed25519ph_sha256_on_emscripten.outcome
+++ b/tools/test/fixtures/crypto_jamfiles/ed25519ph_sha256_on_emscripten/ed25519ph_sha256_on_emscripten.outcome
@@ -12,5 +12,5 @@
targets: emscripten
build: fails
# tag::messages[]
-contains: webcpp::crypto: Ed25519ph is defined over SHA-512 (RFC 8032 section 5.1); name curves::ed25519::ph.
+contains: webcpp::crypto: Ed25519ph is defined over SHA-512 (RFC 8032 section 5.1); name curves::ed25519::prehashed_signer.
# end::messages[]
diff --git a/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp b/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp
index 9f68789b..d1d7833f 100644
--- a/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp
@@ -8,8 +8,8 @@
// NIST test vector (GCM test case 14), opens it again, then signs a message with BIP340 through
// libsecp256k1, verifies the signature, and refuses a changed message.
#include
+#include
#include
-#include
#include
#include
@@ -18,7 +18,7 @@
int main() {
std::array const key{};
- std::array const iv{};
+ std::array const nonce{};
std::array data{};
std::array const cipher{
0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e,
@@ -28,14 +28,15 @@ int main() {
0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0,
0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19,
};
- auto aead = webcpp::crypto::ciphers::aes256_gcm::make(key);
+ auto aead = webcpp::crypto::ciphers::aes256_gcm::from_key(key);
if (!aead) {
return 1;
}
- auto const tag = aead->seal(iv, {}, data);
- bool const sealed = tag && data == cipher && webcpp::crypto::equal(*tag, expected_tag);
+ auto const tag = aead->seal(nonce, {}, data);
+ bool const sealed =
+ tag && data == cipher && webcpp::crypto::constant_time_equal(*tag, expected_tag);
bool const opened =
- aead->open(iv, {}, data, expected_tag) && data == std::array{};
+ aead->open(nonce, {}, data, expected_tag) && data == std::array{};
auto const name = webcpp::crypto::ciphers::aes256_gcm::backend_type::name;
std::printf("aes256_gcm %s backend=%.*s\n", sealed && opened ? "ok" : "FAILED",
static_cast(name.size()), name.data());
@@ -46,7 +47,7 @@ int main() {
std::array message{};
message.fill(0x17);
std::array const aux{};
- auto pair = secp256k1::keypair::make(secret);
+ auto pair = secp256k1::keypair::from_secret(secret);
bool signed_ok = false;
if (pair) {
auto const signature = pair->sign(webcpp::crypto::schnorr, message, aux);
diff --git a/tools/test/fixtures/crypto_jamfiles/gcm_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/gcm_default/app.cpp
index 14a122b2..14b60607 100644
--- a/tools/test/fixtures/crypto_jamfiles/gcm_default/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/gcm_default/app.cpp
@@ -5,11 +5,11 @@
// https://www.boost.org/LICENSE_1_0.txt)
// Seals one zero block under AES-256-GCM with the default backend and checks it against the
-// GCM specification's test case 14 (key, IV and plaintext all zero), then opens it again, and
-// prints the backend that ran. The zero key and IV are the test vector's: a real program draws
-// its key from random_device and never reuses an IV under it.
+// GCM specification's test case 14 (key, nonce and plaintext all zero), then opens it again, and
+// prints the backend that ran. The zero key and nonce are the test vector's: a real program draws
+// its key from random_device and never reuses a nonce under it.
#include
-#include
+#include
#include
#include
@@ -17,7 +17,7 @@
int main() {
std::array const key{};
- std::array const iv{};
+ std::array const nonce{};
std::array data{};
std::array const cipher{
0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e,
@@ -27,14 +27,15 @@ int main() {
0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0,
0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19,
};
- auto aead = webcpp::crypto::ciphers::aes256_gcm::make(key);
+ auto aead = webcpp::crypto::ciphers::aes256_gcm::from_key(key);
if (!aead) {
return 1;
}
- auto const tag = aead->seal(iv, {}, data);
- bool const sealed = tag && data == cipher && webcpp::crypto::equal(*tag, expected_tag);
+ auto const tag = aead->seal(nonce, {}, data);
+ bool const sealed =
+ tag && data == cipher && webcpp::crypto::constant_time_equal(*tag, expected_tag);
bool const opened =
- aead->open(iv, {}, data, expected_tag) && data == std::array{};
+ aead->open(nonce, {}, data, expected_tag) && data == std::array{};
auto const name = webcpp::crypto::ciphers::aes256_gcm::backend_type::name;
std::printf("aes256_gcm %s backend=%.*s\n", sealed && opened ? "ok" : "FAILED",
static_cast(name.size()), name.data());
diff --git a/tools/test/fixtures/crypto_jamfiles/heavy_without_threads_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/heavy_without_threads_on_emscripten/app.cpp
index 8abdab43..27e523db 100644
--- a/tools/test/fixtures/crypto_jamfiles/heavy_without_threads_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/heavy_without_threads_on_emscripten/app.cpp
@@ -16,11 +16,11 @@ boost::system::result slow(int value) noexcept {
}
template
-auto async_slow(Executor const& work, int value, CompletionToken&& token) {
+auto async_slow(Executor const& work, int value, CompletionToken&& completion_token) {
WEBCPP_CRYPTO_DETAIL_REQUIRE_THREADS("async_slow", "slow");
return webcpp::crypto::detail::run_on_work(
work, []() noexcept { return boost::system::result(); },
- [value]() noexcept { return slow(value); }, token);
+ [value]() noexcept { return slow(value); }, completion_token);
}
struct executor {};
diff --git a/tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp
index 8f9fbd54..ddb46c5a 100644
--- a/tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp
@@ -8,8 +8,8 @@
// computes each side's session keys from the other's public key, checks the client's transmit
// key against kx.exp's and the server's receive key, and prints the backend that ran. The seeds
// are libsodium's test's: a real program draws its key pair with generate().
-#include
-#include
+#include
+#include
#include
#include
@@ -17,7 +17,7 @@
#include
int main() {
- namespace x25519 = webcpp::crypto::curves::x25519;
+ namespace key_exchange = webcpp::crypto::key_exchange;
std::array client_seed{};
for (std::size_t i = 0; i < client_seed.size(); ++i) {
client_seed[i] = static_cast(i);
@@ -29,8 +29,8 @@ int main() {
0x99, 0x18, 0xd1, 0x29, 0xb6, 0x5d, 0xeb, 0x78, 0x9a, 0xf8, 0xc8,
0x35, 0x1f, 0x39, 0x1f, 0xeb, 0x0c, 0xbf, 0x23, 0x86, 0x04,
};
- auto const client = x25519::kx_keypair<>::make(client_seed);
- auto const server = x25519::kx_keypair<>::make(server_seed);
+ auto const client = key_exchange::kx_keypair<>::derive_from_seed(client_seed);
+ auto const server = key_exchange::kx_keypair<>::derive_from_seed(server_seed);
bool ok = false;
if (client && server) {
auto const client_public = client->public_key();
@@ -39,11 +39,11 @@ int main() {
auto const client_keys = client->client_session_keys(*server_public);
auto const server_keys = server->server_session_keys(*client_public);
ok = client_keys && server_keys &&
- webcpp::crypto::equal(client_keys->transmit.bytes(), expected) &&
- webcpp::crypto::equal(server_keys->receive.bytes(), expected);
+ webcpp::crypto::constant_time_equal(client_keys->transmit.bytes(), expected) &&
+ webcpp::crypto::constant_time_equal(server_keys->receive.bytes(), expected);
}
}
- auto const name = x25519::kx_keypair<>::backend_type::name;
+ auto const name = key_exchange::kx_keypair<>::backend_type::name;
std::printf("kx %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()),
name.data());
return ok ? 0 : 1;
diff --git a/tools/test/fixtures/crypto_jamfiles/kx_default_not_linked_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/kx_default_not_linked_on_emscripten/app.cpp
index 8794e496..4bd90f04 100644
--- a/tools/test/fixtures/crypto_jamfiles/kx_default_not_linked_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/kx_default_not_linked_on_emscripten/app.cpp
@@ -6,12 +6,12 @@
// As test/messages/kx_default_not_linked, on Emscripten.
-#include
+#include
#include
#include
int main() {
std::array const seed{};
- return webcpp::crypto::curves::x25519::kx_keypair<>::make(seed) ? 0 : 1;
+ return webcpp::crypto::key_exchange::kx_keypair<>::derive_from_seed(seed) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/Jamfile b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_from_key/Jamfile
similarity index 100%
rename from tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/Jamfile
rename to tools/test/fixtures/crypto_jamfiles/memory_missing_definition_from_key/Jamfile
diff --git a/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/app.cpp b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_from_key/app.cpp
similarity index 85%
rename from tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/app.cpp
rename to tools/test/fixtures/crypto_jamfiles/memory_missing_definition_from_key/app.cpp
index ab78b653..dfd18207 100644
--- a/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_from_key/app.cpp
@@ -5,7 +5,7 @@
// https://www.boost.org/LICENSE_1_0.txt)
// Sets the memory option and makes AES-256-GCM on OpenSSL, without the install, and defines no
-// webcpp::crypto::openssl_memory_resource(): make's guard compares OpenSSL's functions with the
+// webcpp::crypto::openssl_memory_resource(): from_key's guard compares OpenSSL's functions with the
// adapter's address, which odr-uses the adapter, so the link fails naming the function (spec
// section 3.7).
#include
@@ -18,6 +18,6 @@
int main() {
std::array const key{};
auto const aead = webcpp::crypto::ciphers::gcm<
- webcpp::crypto::ciphers::aes256>::make(key);
+ webcpp::crypto::ciphers::aes256>::from_key(key);
return aead ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/memory_missing_definition_make.outcome b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_from_key/memory_missing_definition_from_key.outcome
similarity index 100%
rename from tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/memory_missing_definition_make.outcome
rename to tools/test/fixtures/crypto_jamfiles/memory_missing_definition_from_key/memory_missing_definition_from_key.outcome
diff --git a/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp b/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp
index c97c87ed..9d377604 100644
--- a/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp
@@ -6,8 +6,8 @@
// Sends every allocation of OpenSSL's to the program's own resource, then seals and opens one
// block with AES-256-GCM on the default backend, OpenSSL natively when linked, and prints the
-// backend that ran. The zero key and IV keep the output stable: a real program draws its key
-// from random_device and never reuses an IV under it.
+// backend that ran. The zero key and nonce keep the output stable: a real program draws its key
+// from random_device and never reuses a nonce under it.
#include
#include
@@ -35,16 +35,17 @@ int main() {
return 1;
}
std::array const key{};
- std::array const iv{};
+ std::array const nonce{};
std::array data{};
- auto aead = webcpp::crypto::ciphers::aes256_gcm::make(key);
+ auto aead = webcpp::crypto::ciphers::aes256_gcm::from_key(key);
if (!aead) {
std::string const message = aead.error().message();
- std::printf("make: %s\n", message.c_str());
+ std::printf("from_key: %s\n", message.c_str());
return 1;
}
- auto const tag = aead->seal(iv, {}, data);
- bool const ok = tag && aead->open(iv, {}, data, *tag) && data == std::array{};
+ auto const tag = aead->seal(nonce, {}, data);
+ bool const ok =
+ tag && aead->open(nonce, {}, data, *tag) && data == std::array{};
auto const name = webcpp::crypto::ciphers::aes256_gcm::backend_type::name;
std::printf("aes256_gcm %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()),
name.data());
diff --git a/tools/test/fixtures/crypto_jamfiles/memory_two_files/main.cpp b/tools/test/fixtures/crypto_jamfiles/memory_two_files/main.cpp
index 5596f026..64477815 100644
--- a/tools/test/fixtures/crypto_jamfiles/memory_two_files/main.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/memory_two_files/main.cpp
@@ -5,7 +5,7 @@
// https://www.boost.org/LICENSE_1_0.txt)
// The file of memory_two_files compiled without the memory option: it makes AES-256-GCM on
-// OpenSSL, whose make differs from with.cpp's, and calls with.cpp's.
+// OpenSSL, whose from_key differs from with.cpp's, and calls with.cpp's.
#include
#include
#include
@@ -18,6 +18,6 @@ bool make_with_the_option();
int main() {
std::array const key{};
auto const aead = webcpp::crypto::ciphers::gcm<
- webcpp::crypto::ciphers::aes256>::make(key);
+ webcpp::crypto::ciphers::aes256>::from_key(key);
return aead && make_with_the_option() ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/memory_two_files/memory_two_files.outcome b/tools/test/fixtures/crypto_jamfiles/memory_two_files/memory_two_files.outcome
index 85037855..9a5dd151 100644
--- a/tools/test/fixtures/crypto_jamfiles/memory_two_files/memory_two_files.outcome
+++ b/tools/test/fixtures/crypto_jamfiles/memory_two_files/memory_two_files.outcome
@@ -5,7 +5,7 @@
# https://www.boost.org/LICENSE_1_0.txt)
# A record: two files compiled one with and one without the memory option link here, GNU ld
-# and ld64 keeping one of the two make functions. Only MSVC's linker stops them, with LNK2038
+# and ld64 keeping one of the two from_key functions. Only MSVC's linker stops them, with LNK2038
# (backends/openssl.hpp's #pragma detect_mismatch), libs/crypto/test/msvc/memory_two_files.
[all]
targets: native
diff --git a/tools/test/fixtures/crypto_jamfiles/memory_two_files/with.cpp b/tools/test/fixtures/crypto_jamfiles/memory_two_files/with.cpp
index da1df856..c60542c2 100644
--- a/tools/test/fixtures/crypto_jamfiles/memory_two_files/with.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/memory_two_files/with.cpp
@@ -21,6 +21,6 @@ std::pmr::memory_resource& webcpp::crypto::openssl_memory_resource() noexcept {
bool make_with_the_option() {
std::array const key{};
return webcpp::crypto::ciphers::gcm<
- webcpp::crypto::ciphers::aes256>::make(key)
+ webcpp::crypto::ciphers::aes256>::from_key(key)
.has_value();
}
diff --git a/tools/test/fixtures/crypto_jamfiles/no_backend_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/no_backend_on_emscripten/app.cpp
index 239e2450..749064e4 100644
--- a/tools/test/fixtures/crypto_jamfiles/no_backend_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/no_backend_on_emscripten/app.cpp
@@ -12,5 +12,5 @@
int main() {
std::array const key{};
- return webcpp::crypto::ciphers::aes256_gcm::make(key) ? 0 : 1;
+ return webcpp::crypto::ciphers::aes256_gcm::from_key(key) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/openssl_linked/app.cpp b/tools/test/fixtures/crypto_jamfiles/openssl_linked/app.cpp
index 9eecbb0e..4ed7ceea 100644
--- a/tools/test/fixtures/crypto_jamfiles/openssl_linked/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/openssl_linked/app.cpp
@@ -5,7 +5,7 @@
// https://www.boost.org/LICENSE_1_0.txt)
// A user's program that names /webcpp/crypto//openssl: it prints the define the alias gives,
-// then seals an empty message under the zero key of 32 bytes and the zero IV of 12 bytes
+// then seals an empty message under the zero key of 32 bytes and the zero nonce of 12 bytes
// with OpenSSL's AES-256-GCM, and prints the tag (McGrew and Viega's test case 13).
#include
@@ -23,12 +23,13 @@ int main() {
#endif
namespace crypto = webcpp::crypto;
std::array const key{};
- std::array const iv{};
- auto made = crypto::ciphers::gcm>::make(key);
+ std::array const nonce{};
+ auto made =
+ crypto::ciphers::gcm>::from_key(key);
if (!made) {
return 1;
}
- auto const tag = made->seal(iv, {}, std::span());
+ auto const tag = made->seal(nonce, {}, std::span());
if (!tag) {
return 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/p256_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/p256_default/app.cpp
index 7f29441e..d417d608 100644
--- a/tools/test/fixtures/crypto_jamfiles/p256_default/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/p256_default/app.cpp
@@ -27,7 +27,7 @@ int main() {
0xbc, 0x99, 0xa4, 0x1a, 0xe9, 0xe9, 0x56, 0x28, 0xbc, 0x64, 0xf2, 0xf1, 0xb2,
0x0c, 0x2d, 0x7e, 0x9f, 0x51, 0x77, 0xa3, 0xc2, 0x94, 0xd4, 0x46, 0x22, 0x99,
};
- auto const key = p256::keypair::make(scalar);
+ auto const key = p256::keypair::from_secret(scalar);
bool ok = false;
if (key) {
auto const public_key = key->public_key();
diff --git a/tools/test/fixtures/crypto_jamfiles/p256_default_not_linked_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/p256_default_not_linked_on_emscripten/app.cpp
index ef6a9e7b..57e87ff8 100644
--- a/tools/test/fixtures/crypto_jamfiles/p256_default_not_linked_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/p256_default_not_linked_on_emscripten/app.cpp
@@ -13,5 +13,5 @@
int main() {
std::array scalar{};
scalar.back() = 1;
- return webcpp::crypto::curves::p256::keypair::make(scalar) ? 0 : 1;
+ return webcpp::crypto::curves::p256::keypair::from_secret(scalar) ? 0 : 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/p256_on_sodium_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/p256_on_sodium_on_emscripten/app.cpp
index 3004f578..11873da7 100644
--- a/tools/test/fixtures/crypto_jamfiles/p256_on_sodium_on_emscripten/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/p256_on_sodium_on_emscripten/app.cpp
@@ -13,8 +13,8 @@
int main() {
std::array scalar{};
scalar.back() = 1;
- return webcpp::crypto::curves::p256::basic_keypair::make(
- scalar)
+ return webcpp::crypto::curves::p256::basic_keypair<
+ webcpp::crypto::backends::sodium>::from_secret(scalar)
? 0
: 1;
}
diff --git a/tools/test/fixtures/crypto_jamfiles/sealed_box_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/sealed_box_default/app.cpp
index f7fb125c..a399284d 100644
--- a/tools/test/fixtures/crypto_jamfiles/sealed_box_default/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/sealed_box_default/app.cpp
@@ -8,7 +8,7 @@
// checks that it opened as it was sealed, and prints the backend that ran. Bob's secret key is
// fixed here: a real program draws it from random_device.
#include
-#include
+#include
#include
#include
@@ -17,17 +17,22 @@
#include
int main() {
- using webcpp::crypto::hybrid::sealed_box;
+ using webcpp::crypto::public_key_encryption::sealed_box;
std::array bob_secret{};
bob_secret.fill(0x11);
- auto const bob_public = webcpp::crypto::curves::x25519::public_key(bob_secret);
+ auto const bob = webcpp::crypto::curves::x25519::keypair::from_secret(bob_secret);
+ if (!bob) {
+ std::printf("sealed_box FAILED\n");
+ return 1;
+ }
+ auto const bob_public = bob->public_key();
constexpr std::string_view feedback = "The coffee machine on the third floor is broken.";
std::array message{};
std::ranges::copy(feedback, message.begin());
std::array sealed{};
std::array opened{};
bool const ok = bob_public && sealed_box::seal(*bob_public, message, sealed) &&
- sealed_box::open(*bob_public, bob_secret, sealed, opened) && opened == message;
+ sealed_box::open(*bob, sealed, opened) && opened == message;
auto const name = sealed_box::backend_type::name;
std::printf("sealed_box %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()),
name.data());
diff --git a/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp
index e26d6122..ff96477d 100644
--- a/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp
+++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp
@@ -7,8 +7,8 @@
// Signs BIP 340's first test vector (secret key 3, a zero message and zero auxiliary data) with
// a key pair on the default backend, checks the signature against the vector's and verifies it,
// and prints the backend that ran. The secret key is the vector's: a real program draws its own.
+#include
#include