From a1d3c0d706666d923ad804d8a92a605b93613659 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 11:29:09 -0300 Subject: [PATCH 01/44] crypto fixtures: key pairs are made by from_secret, public keys by from_bytes, ciphers by from_key --- .../aead_not_a_family_on_emscripten/app.cpp | 2 +- .../fixtures/crypto_jamfiles/aes_block_default/app.cpp | 2 +- .../aes_block_default_not_linked_on_emscripten/app.cpp | 2 +- tools/test/fixtures/crypto_jamfiles/block/block.cpp | 2 +- .../fixtures/crypto_jamfiles/both_bearssl_named/app.cpp | 2 +- .../box_default_not_linked_on_emscripten/app.cpp | 8 ++++---- .../box_not_a_family_on_emscripten/app.cpp | 2 +- .../crypto_jamfiles/box_xchacha20poly1305_default/app.cpp | 4 ++-- .../crypto_jamfiles/box_xsalsa20poly1305_default/app.cpp | 4 ++-- .../fixtures/crypto_jamfiles/canary_ctaes_missing/app.cpp | 2 +- .../test/fixtures/crypto_jamfiles/canary_missing/app.cpp | 2 +- .../fixtures/crypto_jamfiles/canary_other_commit/app.cpp | 2 +- .../crypto_jamfiles/canary_other_configuration/app.cpp | 2 +- .../crypto_jamfiles/canary_secp256k1_missing/app.cpp | 2 +- .../crypto_jamfiles/canary_secp256k1_small/app.cpp | 2 +- .../test/fixtures/crypto_jamfiles/canary_without/app.cpp | 2 +- .../crypto_jamfiles/chacha20_poly1305_default/app.cpp | 2 +- .../chacha20_poly1305_original_default/app.cpp | 2 +- .../chacha_default_not_linked_on_emscripten/app.cpp | 6 +++--- .../chacha_header_not_included_on_emscripten/app.cpp | 2 +- .../crypto_jamfiles/chacha_on_ctaes_on_emscripten/app.cpp | 2 +- .../crypto_jamfiles/chacha_openssl_on_emscripten/app.cpp | 2 +- .../chacha_unknown_backend_on_emscripten/app.cpp | 2 +- .../test/fixtures/crypto_jamfiles/ed25519_default/app.cpp | 2 +- .../ed25519_default_not_linked_on_emscripten/app.cpp | 2 +- .../ed25519_on_bearssl_on_emscripten/app.cpp | 4 ++-- .../ed25519_unknown_policy_on_emscripten/app.cpp | 2 +- .../fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp | 4 ++-- tools/test/fixtures/crypto_jamfiles/gcm_default/app.cpp | 2 +- tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp | 4 ++-- .../kx_default_not_linked_on_emscripten/app.cpp | 2 +- .../memory_missing_definition_make/app.cpp | 4 ++-- tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp | 4 ++-- .../fixtures/crypto_jamfiles/memory_two_files/main.cpp | 4 ++-- .../memory_two_files/memory_two_files.outcome | 2 +- .../fixtures/crypto_jamfiles/memory_two_files/with.cpp | 2 +- .../crypto_jamfiles/no_backend_on_emscripten/app.cpp | 2 +- .../test/fixtures/crypto_jamfiles/openssl_linked/app.cpp | 3 ++- tools/test/fixtures/crypto_jamfiles/p256_default/app.cpp | 2 +- .../p256_default_not_linked_on_emscripten/app.cpp | 2 +- .../crypto_jamfiles/p256_on_sodium_on_emscripten/app.cpp | 4 ++-- .../fixtures/crypto_jamfiles/secp256k1_default/app.cpp | 2 +- .../crypto_jamfiles/secp256k1_ellswift_default/app.cpp | 4 ++-- .../crypto_jamfiles/secp256k1_musig_default/app.cpp | 4 ++-- .../secp256k1_silent_payments_default/app.cpp | 6 +++--- .../secretbox_xchacha20poly1305_default/app.cpp | 2 +- .../secretbox_xsalsa20poly1305_default/app.cpp | 2 +- tools/test/fixtures/crypto_jamfiles/server/app.cpp | 2 +- tools/test/fixtures/crypto_jamfiles/sign/sign.cpp | 2 +- tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp | 2 +- tools/test/fixtures/crypto_jamfiles/web/app.cpp | 2 +- .../crypto_jamfiles/xchacha20_poly1305_default/app.cpp | 2 +- 52 files changed, 71 insertions(+), 70 deletions(-) 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..0841b89e 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 @@ -15,5 +15,5 @@ int main() { namespace crypto = webcpp::crypto; using aead = crypto::ciphers::aead; std::array const key{}; - return aead::make(key) ? 0 : 1; + return aead::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..3ef31d33 100644 --- a/tools/test/fixtures/crypto_jamfiles/both_bearssl_named/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/both_bearssl_named/app.cpp @@ -35,7 +35,7 @@ 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; } 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..cda30114 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 @@ -17,10 +17,10 @@ int main() { namespace crypto = webcpp::crypto; 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) && + return crypto::ciphers::secretbox<>::from_key(key) && + crypto::ciphers::secretbox_xchacha20poly1305<>::from_key(key) && + crypto::hybrid::box::from_keys(key, key) && + crypto::hybrid::box_xchacha20poly1305::from_keys(key, key) && crypto::hybrid::sealed_box::seal(key, {}, sealed) ? 0 : 1; 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..7c5c639a 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 @@ -20,5 +20,5 @@ struct not_a_family {}; int main() { std::array const key{}; - return webcpp::crypto::hybrid::basic_box::make(key, key) ? 0 : 1; + return webcpp::crypto::hybrid::basic_box::from_keys(key, key) ? 0 : 1; } 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..d2d5de85 100644 --- a/tools/test/fixtures/crypto_jamfiles/box_xchacha20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/box_xchacha20poly1305_default/app.cpp @@ -55,8 +55,8 @@ 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); + auto alice = box::from_keys(alice_secret, bob_public); + auto bob = box::from_keys(bob_secret, alice_public); bool ok = false; if (alice && bob) { auto const sealed = alice->seal(iv, data); 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..6209fb72 100644 --- a/tools/test/fixtures/crypto_jamfiles/box_xsalsa20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/box_xsalsa20poly1305_default/app.cpp @@ -55,8 +55,8 @@ 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); + auto alice = box::from_keys(alice_secret, bob_public); + auto bob = box::from_keys(bob_secret, alice_public); bool ok = false; if (alice && bob) { auto const sealed = alice->seal(iv, data); 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..54954f43 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_missing/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/canary_missing/app.cpp @@ -18,6 +18,6 @@ int main() { std::array const iv{}; std::array data{}; auto aead = webcpp::crypto::ciphers::gcm< - webcpp::crypto::ciphers::aes256>::make(key); + webcpp::crypto::ciphers::aes256>::from_key(key); return aead && aead->seal(iv, {}, 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..54954f43 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_other_commit/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/canary_other_commit/app.cpp @@ -18,6 +18,6 @@ int main() { std::array const iv{}; std::array data{}; auto aead = webcpp::crypto::ciphers::gcm< - webcpp::crypto::ciphers::aes256>::make(key); + webcpp::crypto::ciphers::aes256>::from_key(key); return aead && aead->seal(iv, {}, 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..54954f43 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/app.cpp @@ -18,6 +18,6 @@ int main() { std::array const iv{}; std::array data{}; auto aead = webcpp::crypto::ciphers::gcm< - webcpp::crypto::ciphers::aes256>::make(key); + webcpp::crypto::ciphers::aes256>::from_key(key); return aead && aead->seal(iv, {}, 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..54954f43 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_without/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/canary_without/app.cpp @@ -18,6 +18,6 @@ int main() { std::array const iv{}; std::array data{}; auto aead = webcpp::crypto::ciphers::gcm< - webcpp::crypto::ciphers::aes256>::make(key); + webcpp::crypto::ciphers::aes256>::from_key(key); return aead && aead->seal(iv, {}, 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..03795b3d 100644 --- a/tools/test/fixtures/crypto_jamfiles/chacha20_poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/chacha20_poly1305_default/app.cpp @@ -43,7 +43,7 @@ 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); 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..a34d24e1 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 @@ -39,7 +39,7 @@ 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); 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..f83f32fd 100644 --- a/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp @@ -32,7 +32,7 @@ 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); 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..f0ab43f1 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,7 +22,7 @@ struct lenient {}; int main() { auto const public_key = - webcpp::crypto::curves::ed25519::public_key::make(std::array{}); + webcpp::crypto::curves::ed25519::public_key::from_bytes(std::array{}); std::array const signature{}; return public_key && webcpp::crypto::verify(webcpp::crypto::eddsa, signature, 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..39f06d8c 100644 --- a/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp @@ -28,7 +28,7 @@ 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; } @@ -46,7 +46,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..36ee1c5a 100644 --- a/tools/test/fixtures/crypto_jamfiles/gcm_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/gcm_default/app.cpp @@ -27,7 +27,7 @@ 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; } diff --git a/tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp index 8f9fbd54..b052ad1b 100644 --- a/tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp @@ -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 = x25519::kx_keypair<>::derive_from_seed(client_seed); + auto const server = x25519::kx_keypair<>::derive_from_seed(server_seed); bool ok = false; if (client && server) { auto const client_public = client->public_key(); 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..8ee1eb3f 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 @@ -13,5 +13,5 @@ int main() { std::array const seed{}; - return webcpp::crypto::curves::x25519::kx_keypair<>::make(seed) ? 0 : 1; + return webcpp::crypto::curves::x25519::kx_keypair<>::derive_from_seed(seed) ? 0 : 1; } diff --git a/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/app.cpp b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/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_make/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_option/app.cpp b/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp index c97c87ed..69b6b556 100644 --- a/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp @@ -37,10 +37,10 @@ int main() { std::array const key{}; std::array const iv{}; 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); 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..b59cb8ea 100644 --- a/tools/test/fixtures/crypto_jamfiles/openssl_linked/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/openssl_linked/app.cpp @@ -24,7 +24,8 @@ int main() { namespace crypto = webcpp::crypto; std::array const key{}; std::array const iv{}; - auto made = crypto::ciphers::gcm>::make(key); + auto made = + crypto::ciphers::gcm>::from_key(key); if (!made) { 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/secp256k1_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp index e26d6122..9a79e743 100644 --- a/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp @@ -28,7 +28,7 @@ int main() { 0x71, 0xe4, 0x82, 0xa7, 0x4f, 0x38, 0x2d, 0x2c, 0xe5, 0xeb, 0xee, 0xe8, 0xfd, 0xb2, 0x17, 0x2f, 0x47, 0x7d, 0xf4, 0x90, 0x0d, 0x31, 0x05, 0x36, 0xc0, }; - auto const key = secp256k1::keypair::make(secret); + auto const key = secp256k1::keypair::from_secret(secret); bool ok = false; if (key) { auto const signature = key->sign(webcpp::crypto::schnorr, message, aux); diff --git a/tools/test/fixtures/crypto_jamfiles/secp256k1_ellswift_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_ellswift_default/app.cpp index 6f65e024..5d42ef1f 100644 --- a/tools/test/fixtures/crypto_jamfiles/secp256k1_ellswift_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_ellswift_default/app.cpp @@ -29,8 +29,8 @@ std::array repeated(std::uint8_t value) { int main() { namespace crypto = webcpp::crypto; namespace secp256k1 = webcpp::crypto::curves::secp256k1; - auto const initiator = secp256k1::keypair::make(repeated(0x11)); - auto const responder = secp256k1::keypair::make(repeated(0x22)); + auto const initiator = secp256k1::keypair::from_secret(repeated(0x11)); + auto const responder = secp256k1::keypair::from_secret(repeated(0x22)); bool ok = false; if (initiator && responder) { auto const sent = secp256k1::ellswift_create(*initiator, repeated(0x33)); diff --git a/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp index 149f598f..10ce90e1 100644 --- a/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp @@ -76,8 +76,8 @@ bool sign_and_verify(secp256k1::keypair const& first, secp256k1::keypair const& int main() { namespace crypto = webcpp::crypto; - auto const first = secp256k1::keypair::make(repeated(0x11)); - auto const second = secp256k1::keypair::make(repeated(0x22)); + auto const first = secp256k1::keypair::from_secret(repeated(0x11)); + auto const second = secp256k1::keypair::from_secret(repeated(0x22)); bool const ok = first && second && sign_and_verify(*first, *second); auto const name = crypto::default_backend_t::name; std::printf("musig %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()), diff --git a/tools/test/fixtures/crypto_jamfiles/secp256k1_silent_payments_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_silent_payments_default/app.cpp index 38b8343d..04d63b60 100644 --- a/tools/test/fixtures/crypto_jamfiles/secp256k1_silent_payments_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_silent_payments_default/app.cpp @@ -67,9 +67,9 @@ bool pay_and_scan(secp256k1::keypair const& scan_pair, secp256k1::keypair const& int main() { namespace crypto = webcpp::crypto; - auto const scan_pair = secp256k1::keypair::make(repeated(0x51)); - auto const spend_pair = secp256k1::keypair::make(repeated(0x52)); - auto const donor = secp256k1::keypair::make(repeated(0x53)); + auto const scan_pair = secp256k1::keypair::from_secret(repeated(0x51)); + auto const spend_pair = secp256k1::keypair::from_secret(repeated(0x52)); + auto const donor = secp256k1::keypair::from_secret(repeated(0x53)); bool const ok = scan_pair && spend_pair && donor && pay_and_scan(*scan_pair, *spend_pair, *donor); auto const name = crypto::default_backend_t::name; diff --git a/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp index 6500b768..fdf55679 100644 --- a/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp @@ -44,7 +44,7 @@ int main() { auto const expected_tag = from_hex<16>("0c801a037c2ed0500d6ef68e8d195ece"); auto const expected = from_hex<21>("b05a15f8edb68b35773e81ac2aca18e9be53416f9a"); auto data = plaintext; - auto sealer = secretbox::make(key); + auto sealer = secretbox::from_key(key); bool ok = false; if (sealer) { auto const tag = sealer->seal(iv, {}, data); diff --git a/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp index 736a015a..c7c68dd5 100644 --- a/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp @@ -49,7 +49,7 @@ int main() { auto const expected_tag = from_hex<16>("f3ffc7703f9400e52a7dfb4b3d3305d9"); auto const expected_head = from_hex<8>("8e993b9f48681273"); auto data = plaintext; - auto sealer = secretbox::make(key); + auto sealer = secretbox::from_key(key); bool ok = false; if (sealer) { auto const tag = sealer->seal(iv, {}, data); diff --git a/tools/test/fixtures/crypto_jamfiles/server/app.cpp b/tools/test/fixtures/crypto_jamfiles/server/app.cpp index 14a122b2..36ee1c5a 100644 --- a/tools/test/fixtures/crypto_jamfiles/server/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/server/app.cpp @@ -27,7 +27,7 @@ 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; } diff --git a/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp b/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp index f6346234..335fcf08 100644 --- a/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp +++ b/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp @@ -19,7 +19,7 @@ int main() { std::array message{}; message.fill(0x17); std::array const aux{}; - auto key = secp256k1::keypair::make(secret); + auto key = secp256k1::keypair::from_secret(secret); bool ok = false; if (key) { auto const signature = key->sign(webcpp::crypto::schnorr, message, aux); diff --git a/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp b/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp index f6346234..335fcf08 100644 --- a/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp +++ b/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp @@ -19,7 +19,7 @@ int main() { std::array message{}; message.fill(0x17); std::array const aux{}; - auto key = secp256k1::keypair::make(secret); + auto key = secp256k1::keypair::from_secret(secret); bool ok = false; if (key) { auto const signature = key->sign(webcpp::crypto::schnorr, message, aux); diff --git a/tools/test/fixtures/crypto_jamfiles/web/app.cpp b/tools/test/fixtures/crypto_jamfiles/web/app.cpp index 14a122b2..36ee1c5a 100644 --- a/tools/test/fixtures/crypto_jamfiles/web/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/web/app.cpp @@ -27,7 +27,7 @@ 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; } diff --git a/tools/test/fixtures/crypto_jamfiles/xchacha20_poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/xchacha20_poly1305_default/app.cpp index 82106ade..893b55da 100644 --- a/tools/test/fixtures/crypto_jamfiles/xchacha20_poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/xchacha20_poly1305_default/app.cpp @@ -46,7 +46,7 @@ int main() { 0x47, 0xde, 0xaf, 0xd8, 0x78, 0x0a, 0xcf, 0x49, }; std::array const expected_head{0xbd, 0x6d, 0x17, 0x9d, 0x3e, 0x83, 0xd4, 0x3b}; - 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); From 491a565abe92f2f2efe21b189473911b323878d6 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 11:38:57 -0300 Subject: [PATCH 02/44] crypto fixtures: the missing memory resource's case is named by from_key --- .../Jamfile | 0 .../app.cpp | 0 .../memory_missing_definition_from_key.outcome} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename tools/test/fixtures/crypto_jamfiles/{memory_missing_definition_make => memory_missing_definition_from_key}/Jamfile (100%) rename tools/test/fixtures/crypto_jamfiles/{memory_missing_definition_make => memory_missing_definition_from_key}/app.cpp (100%) rename tools/test/fixtures/crypto_jamfiles/{memory_missing_definition_make/memory_missing_definition_make.outcome => memory_missing_definition_from_key/memory_missing_definition_from_key.outcome} (100%) 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 100% 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 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 From f2f0fae4224b71b69aff842eb8a971dcc4fc3576 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 11:53:59 -0300 Subject: [PATCH 03/44] crypto fixtures: the boxes and crypto_kx in their namespaces by purpose --- .../box_default_not_linked_on_emscripten/app.cpp | 10 +++++----- .../box_not_a_family_on_emscripten/app.cpp | 5 +++-- .../box_not_a_family_on_emscripten.outcome | 2 +- .../box_xchacha20poly1305_default/app.cpp | 4 ++-- .../box_xsalsa20poly1305_default/app.cpp | 4 ++-- tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp | 10 +++++----- .../kx_default_not_linked_on_emscripten/app.cpp | 4 ++-- .../crypto_jamfiles/sealed_box_default/app.cpp | 4 ++-- 8 files changed, 22 insertions(+), 21 deletions(-) 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 cda30114..7d5c8232 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 @@ -7,8 +7,8 @@ // As test/messages/box_default_not_linked, on Emscripten. #include -#include -#include +#include +#include #include #include @@ -19,9 +19,9 @@ int main() { std::array sealed{}; return crypto::ciphers::secretbox<>::from_key(key) && crypto::ciphers::secretbox_xchacha20poly1305<>::from_key(key) && - crypto::hybrid::box::from_keys(key, key) && - crypto::hybrid::box_xchacha20poly1305::from_keys(key, key) && - crypto::hybrid::sealed_box::seal(key, {}, sealed) + crypto::public_key_encryption::box::from_keys(key, key) && + crypto::public_key_encryption::box_xchacha20poly1305::from_keys(key, key) && + crypto::public_key_encryption::sealed_box::seal(key, {}, sealed) ? 0 : 1; } 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 7c5c639a..77381577 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,7 +6,7 @@ // As test/messages/box_not_a_family, on Emscripten. -#include +#include #include #include @@ -20,5 +20,6 @@ struct not_a_family {}; int main() { std::array const key{}; - return webcpp::crypto::hybrid::basic_box::from_keys(key, key) ? 0 : 1; + using box = webcpp::crypto::public_key_encryption::basic_box; + return box::from_keys(key, key) ? 0 : 1; } 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 d2d5de85..f97e93b8 100644 --- a/tools/test/fixtures/crypto_jamfiles/box_xchacha20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/box_xchacha20poly1305_default/app.cpp @@ -9,7 +9,7 @@ // 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 +#include #include #include @@ -37,7 +37,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 = 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 6209fb72..e87fc9f5 100644 --- a/tools/test/fixtures/crypto_jamfiles/box_xsalsa20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/box_xsalsa20poly1305_default/app.cpp @@ -9,7 +9,7 @@ // 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 +#include #include #include @@ -37,7 +37,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 = diff --git a/tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp index b052ad1b..45c55db6 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 @@ -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<>::derive_from_seed(client_seed); - auto const server = x25519::kx_keypair<>::derive_from_seed(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(); @@ -43,7 +43,7 @@ int main() { webcpp::crypto::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 8ee1eb3f..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<>::derive_from_seed(seed) ? 0 : 1; + return webcpp::crypto::key_exchange::kx_keypair<>::derive_from_seed(seed) ? 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..34112636 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,7 +17,7 @@ #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); From da5be7fd07611c289fe942b626520333994e013f Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 12:21:42 -0300 Subject: [PATCH 04/44] crypto fixtures and guidelines: tags are compared with constant_time_equal --- AGENTS.md | 2 +- CODING-GUIDELINES.md | 36 +++++++++---------- libs/crypto | 2 +- .../both_bearssl_named/app.cpp | 5 +-- .../box_xchacha20poly1305_default/app.cpp | 4 +-- .../box_xsalsa20poly1305_default/app.cpp | 4 +-- .../chacha20_poly1305_default/app.cpp | 4 +-- .../app.cpp | 4 +-- .../crypto_jamfiles/ed25519_default/app.cpp | 4 +-- .../crypto_jamfiles/encrypt_and_sign/app.cpp | 5 +-- .../crypto_jamfiles/gcm_default/app.cpp | 5 +-- .../crypto_jamfiles/kx_default/app.cpp | 6 ++-- .../crypto_jamfiles/secp256k1_default/app.cpp | 4 +-- .../secp256k1_ellswift_default/app.cpp | 4 +-- .../app.cpp | 4 +-- .../app.cpp | 4 +-- .../fixtures/crypto_jamfiles/server/app.cpp | 5 +-- .../test/fixtures/crypto_jamfiles/web/app.cpp | 5 +-- .../crypto_jamfiles/x25519_default/app.cpp | 4 +-- .../xchacha20_poly1305_default/app.cpp | 4 +-- 20 files changed, 60 insertions(+), 55 deletions(-) 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 58a299e4..4f3037b3 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -6974,7 +6974,7 @@ 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 +generator, `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 @@ -6983,9 +6983,9 @@ 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`, `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 @@ -7035,27 +7035,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`, + library is linked; `config.hpp`, `error.hpp`, `constant_time_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. 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 diff --git a/libs/crypto b/libs/crypto index 02552068..e4eddb59 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 025520686003828307e7de26f17a645b492f5183 +Subproject commit e4eddb593c331689bcbabce6dee7faec03bf83a9 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 3ef31d33..fee9a629 100644 --- a/tools/test/fixtures/crypto_jamfiles/both_bearssl_named/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/both_bearssl_named/app.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -40,7 +40,8 @@ int main() { return 1; } auto const tag = aead->seal(iv, {}, data); - bool const sealed = tag && data == cipher && webcpp::crypto::equal(*tag, expected_tag); + 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{}; auto const name = aead_type::backend_type::name; 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 f97e93b8..54a2b0e0 100644 --- a/tools/test/fixtures/crypto_jamfiles/box_xchacha20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/box_xchacha20poly1305_default/app.cpp @@ -8,7 +8,7 @@ // 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 #include #include @@ -60,7 +60,7 @@ int main() { bool ok = false; if (alice && bob) { auto const sealed = alice->seal(iv, data); - ok = sealed && webcpp::crypto::equal(*sealed, expected_tag) && + 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; } 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 e87fc9f5..9dd962d0 100644 --- a/tools/test/fixtures/crypto_jamfiles/box_xsalsa20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/box_xsalsa20poly1305_default/app.cpp @@ -8,7 +8,7 @@ // 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 #include #include @@ -60,7 +60,7 @@ int main() { bool ok = false; if (alice && bob) { auto const sealed = alice->seal(iv, data); - ok = sealed && webcpp::crypto::equal(*sealed, expected_tag) && + 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; } 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 03795b3d..5dcd152d 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 @@ -47,7 +47,7 @@ int main() { bool ok = false; if (sealer) { auto const tag = sealer->seal(iv, additional_data, data); - ok = tag && webcpp::crypto::equal(*tag, expected_tag) && + 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; } 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 a34d24e1..76d9f18a 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 @@ -43,7 +43,7 @@ int main() { bool ok = false; if (sealer) { auto const tag = sealer->seal(iv, additional_data, data); - ok = tag && webcpp::crypto::equal(*tag, expected_tag) && + 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; } diff --git a/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp index f83f32fd..d72b7f3f 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 @@ -37,7 +37,7 @@ int main() { 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, 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/encrypt_and_sign/app.cpp b/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp index 39f06d8c..159cc3e7 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 @@ -33,7 +33,8 @@ int main() { return 1; } auto const tag = aead->seal(iv, {}, data); - bool const sealed = tag && data == cipher && webcpp::crypto::equal(*tag, expected_tag); + 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{}; auto const name = webcpp::crypto::ciphers::aes256_gcm::backend_type::name; diff --git a/tools/test/fixtures/crypto_jamfiles/gcm_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/gcm_default/app.cpp index 36ee1c5a..2d8ffb9d 100644 --- a/tools/test/fixtures/crypto_jamfiles/gcm_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/gcm_default/app.cpp @@ -9,7 +9,7 @@ // 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. #include -#include +#include #include #include @@ -32,7 +32,8 @@ int main() { return 1; } auto const tag = aead->seal(iv, {}, data); - bool const sealed = tag && data == cipher && webcpp::crypto::equal(*tag, expected_tag); + 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{}; auto const name = webcpp::crypto::ciphers::aes256_gcm::backend_type::name; diff --git a/tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp index 45c55db6..ddb46c5a 100644 --- a/tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/kx_default/app.cpp @@ -8,7 +8,7 @@ // 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 @@ -39,8 +39,8 @@ 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 = key_exchange::kx_keypair<>::backend_type::name; diff --git a/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp index 9a79e743..e440b476 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 -#include #include #include @@ -33,7 +33,7 @@ int main() { if (key) { auto const signature = key->sign(webcpp::crypto::schnorr, message, aux); auto const public_key = key->public_key(); - ok = signature && public_key && webcpp::crypto::equal(*signature, expected) && + ok = signature && public_key && webcpp::crypto::constant_time_equal(*signature, expected) && webcpp::crypto::verify(webcpp::crypto::schnorr, *signature, message, *public_key); } auto const name = secp256k1::keypair::backend_type::name; diff --git a/tools/test/fixtures/crypto_jamfiles/secp256k1_ellswift_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_ellswift_default/app.cpp index 5d42ef1f..028b6583 100644 --- a/tools/test/fixtures/crypto_jamfiles/secp256k1_ellswift_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_ellswift_default/app.cpp @@ -8,9 +8,9 @@ // checks that each decodes to its key pair's public key and that both sides of BIP 324's // exchange agree, and prints the backend that ran. The secrets and the randomness are fixed: a // real program draws its own, and never prints a shared secret. +#include #include #include -#include #include #include @@ -44,7 +44,7 @@ int main() { secp256k1::ellswift_party::initiator); auto const theirs = secp256k1::ellswift_xdh(*responder, *sent, *received, secp256k1::ellswift_party::responder); - ok = mine && theirs && crypto::equal(mine->bytes(), theirs->bytes()); + ok = mine && theirs && crypto::constant_time_equal(mine->bytes(), theirs->bytes()); } } auto const name = crypto::default_backend_t::name; diff --git a/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp index fdf55679..2d2171e2 100644 --- a/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp @@ -9,7 +9,7 @@ // backend that ran. The key and nonce are the test's: a real program draws its key from // random_device, and a 24-byte nonce drawn at random for every message is safe. #include -#include +#include #include #include @@ -48,7 +48,7 @@ int main() { bool ok = false; if (sealer) { auto const tag = sealer->seal(iv, {}, data); - ok = tag && webcpp::crypto::equal(*tag, expected_tag) && data == expected && + ok = tag && webcpp::crypto::constant_time_equal(*tag, expected_tag) && data == expected && sealer->open(iv, {}, data, expected_tag) && data == plaintext; } auto const name = secretbox::backend_type::name; diff --git a/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp index c7c68dd5..b811ffd6 100644 --- a/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp @@ -9,7 +9,7 @@ // backend that ran. The key and nonce are the test's: a real program draws its key from // random_device, and a 24-byte nonce drawn at random for every message is safe. #include -#include +#include #include #include @@ -53,7 +53,7 @@ int main() { bool ok = false; if (sealer) { auto const tag = sealer->seal(iv, {}, data); - ok = tag && webcpp::crypto::equal(*tag, expected_tag) && + ok = tag && webcpp::crypto::constant_time_equal(*tag, expected_tag) && std::equal(expected_head.begin(), expected_head.end(), data.begin()) && sealer->open(iv, {}, data, expected_tag) && data == plaintext; } diff --git a/tools/test/fixtures/crypto_jamfiles/server/app.cpp b/tools/test/fixtures/crypto_jamfiles/server/app.cpp index 36ee1c5a..2d8ffb9d 100644 --- a/tools/test/fixtures/crypto_jamfiles/server/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/server/app.cpp @@ -9,7 +9,7 @@ // 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. #include -#include +#include #include #include @@ -32,7 +32,8 @@ int main() { return 1; } auto const tag = aead->seal(iv, {}, data); - bool const sealed = tag && data == cipher && webcpp::crypto::equal(*tag, expected_tag); + 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{}; auto const name = webcpp::crypto::ciphers::aes256_gcm::backend_type::name; diff --git a/tools/test/fixtures/crypto_jamfiles/web/app.cpp b/tools/test/fixtures/crypto_jamfiles/web/app.cpp index 36ee1c5a..2d8ffb9d 100644 --- a/tools/test/fixtures/crypto_jamfiles/web/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/web/app.cpp @@ -9,7 +9,7 @@ // 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. #include -#include +#include #include #include @@ -32,7 +32,8 @@ int main() { return 1; } auto const tag = aead->seal(iv, {}, data); - bool const sealed = tag && data == cipher && webcpp::crypto::equal(*tag, expected_tag); + 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{}; auto const name = webcpp::crypto::ciphers::aes256_gcm::backend_type::name; diff --git a/tools/test/fixtures/crypto_jamfiles/x25519_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/x25519_default/app.cpp index 99d4f072..38429082 100644 --- a/tools/test/fixtures/crypto_jamfiles/x25519_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/x25519_default/app.cpp @@ -7,8 +7,8 @@ // Agrees RFC 7748's shared secret (section 6.1) from Alice's secret key and Bob's public key on // the default backend, checks it against the RFC's, and prints the backend that ran. The keys are // the RFC's: a real program draws its own, and never prints a shared secret. +#include #include -#include #include #include @@ -32,7 +32,7 @@ int main() { 0x9e, 0x33, 0x76, 0xf0, 0x9b, 0x3c, 0x1e, 0x16, 0x17, 0x42, }; auto const shared = x25519::agree(alice_secret, bob_public); - bool const ok = shared && webcpp::crypto::equal(shared->bytes(), expected); + bool const ok = shared && webcpp::crypto::constant_time_equal(shared->bytes(), expected); auto const name = x25519::algorithm<>::backend_type::name; std::printf("x25519 %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()), name.data()); diff --git a/tools/test/fixtures/crypto_jamfiles/xchacha20_poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/xchacha20_poly1305_default/app.cpp index 893b55da..1034707e 100644 --- a/tools/test/fixtures/crypto_jamfiles/xchacha20_poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/xchacha20_poly1305_default/app.cpp @@ -9,7 +9,7 @@ // backend that ran. The key and nonce are the draft's: a real program draws its key from // random_device; a 24-byte nonce drawn at random is safe. #include -#include +#include #include #include @@ -50,7 +50,7 @@ int main() { bool ok = false; if (sealer) { auto const tag = sealer->seal(iv, additional_data, data); - ok = tag && webcpp::crypto::equal(*tag, expected_tag) && + 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; } From a675a384a6a8c1a6e2c6f24262aa0859157628aa Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 12:21:42 -0300 Subject: [PATCH 05/44] hash: the MAC pages and examples call constant_time_equal --- libs/hash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hash b/libs/hash index 3af42a2a..59debe6e 160000 --- a/libs/hash +++ b/libs/hash @@ -1 +1 @@ -Subproject commit 3af42a2a9abb617524d7c38e0c53beaa46ff3b66 +Subproject commit 59debe6e48c9395b656e2fcdc16230ae954d13e2 From 13b749effedcc1b988e6c6ba81d0a30ec80e33c7 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 12:29:16 -0300 Subject: [PATCH 06/44] crypto guidelines: erase_secret is a root name and its header needs no backend --- CODING-GUIDELINES.md | 25 +++++++++++++------------ libs/crypto | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 4f3037b3..e3c431c0 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -6974,18 +6974,19 @@ 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, `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. +generator, `constant_time_equal`, `erase_secret`, 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. **Scope.** - **crypto holds primitives only, grouped in namespaces whose headers mirror - them: the root (`error`, `random_device`, `constant_time_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 @@ -7036,10 +7037,10 @@ and not built is in chapter 17. 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`, `constant_time_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. + `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). - **`constant_time_equal` compares in constant time: it reads every byte, diff --git a/libs/crypto b/libs/crypto index e4eddb59..0a6d672a 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit e4eddb593c331689bcbabce6dee7faec03bf83a9 +Subproject commit 0a6d672a56c775556d5e6814a5d788bb32cdfba6 From efc2625efbb54c5d3faac6b1dafd1e86de080ba1 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 13:30:51 -0300 Subject: [PATCH 07/44] crypto fixtures: signatures are typed values --- libs/crypto | 2 +- tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp | 2 +- .../ed25519_unknown_policy_on_emscripten/app.cpp | 2 +- tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/crypto b/libs/crypto index 0a6d672a..16beeb90 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 0a6d672a56c775556d5e6814a5d788bb32cdfba6 +Subproject commit 16beeb90076e14f567d62d55e02d832e70d25d9f diff --git a/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp index d72b7f3f..4a37c2e4 100644 --- a/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp @@ -37,7 +37,7 @@ int main() { if (key) { auto const signature = key->sign(crypto::eddsa, message); auto const public_key = key->public_key(); - ok = signature && public_key && crypto::constant_time_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_unknown_policy_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/app.cpp index f0ab43f1..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 @@ -23,7 +23,7 @@ struct lenient {}; int main() { auto const public_key = webcpp::crypto::curves::ed25519::public_key::from_bytes(std::array{}); - std::array const signature{}; + 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/secp256k1_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp index e440b476..ff96477d 100644 --- a/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp @@ -33,7 +33,8 @@ int main() { if (key) { auto const signature = key->sign(webcpp::crypto::schnorr, message, aux); auto const public_key = key->public_key(); - ok = signature && public_key && webcpp::crypto::constant_time_equal(*signature, expected) && + ok = signature && public_key && + webcpp::crypto::constant_time_equal(signature->bytes(), expected) && webcpp::crypto::verify(webcpp::crypto::schnorr, *signature, message, *public_key); } auto const name = secp256k1::keypair::backend_type::name; From 3371f5c2c8a66161319337fd81dac4b7e3bc5ee0 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 13:38:54 -0300 Subject: [PATCH 08/44] crypto: libs/crypto at task 1.2's fix round 1 --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 16beeb90..b03cccc3 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 16beeb90076e14f567d62d55e02d832e70d25d9f +Subproject commit b03cccc30a68073e8747b6d23d8724b3fe5e1993 From 179c7278799e1d30d8d705f490c7a026400ee191 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 14:07:33 -0300 Subject: [PATCH 09/44] crypto: libs/crypto at task 1.3 and its fix round 1 (the pointer) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index b03cccc3..c9c71043 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit b03cccc30a68073e8747b6d23d8724b3fe5e1993 +Subproject commit c9c7104354e90d9fab80a660b0b1bb5d3f57736d From a7fb03616c360319838e8b3cc4c64204d9317b53 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 14:28:57 -0300 Subject: [PATCH 10/44] crypto fixtures: Ed25519ph's streaming signer is prehashed_signer --- libs/crypto | 2 +- .../crypto_jamfiles/ed25519ph_sha256_on_emscripten/app.cpp | 6 ++++-- .../ed25519ph_sha256_on_emscripten.outcome | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/crypto b/libs/crypto index c9c71043..999d8640 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit c9c7104354e90d9fab80a660b0b1bb5d3f57736d +Subproject commit 999d8640b6ac60eff7de4a927639c37a0147e17f 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[] From 22478a21eb4e1ec862cc2d8efca9442f3678bd1e Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 14:52:39 -0300 Subject: [PATCH 11/44] crypto: libs/crypto at task 1.4's fix round 1 (the pointer) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 999d8640..50db8234 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 999d8640b6ac60eff7de4a927639c37a0147e17f +Subproject commit 50db82340ba9c0243c0f19236fb3390b8a81dda8 From 29a34393e2e04c529a24ae5df138764951df0167 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 15:15:35 -0300 Subject: [PATCH 12/44] crypto fixtures: X25519 agrees with typed keys --- libs/crypto | 2 +- .../crypto_jamfiles/sealed_box_default/app.cpp | 12 +++++++++--- .../crypto_jamfiles/x25519_default/app.cpp | 17 ++++++++++++----- .../app.cpp | 13 ++++++++----- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/libs/crypto b/libs/crypto index 50db8234..a2ad4d12 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 50db82340ba9c0243c0f19236fb3390b8a81dda8 +Subproject commit a2ad4d12d25d2169b09198fa203bcd0b0f457483 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 34112636..94aeeab1 100644 --- a/tools/test/fixtures/crypto_jamfiles/sealed_box_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/sealed_box_default/app.cpp @@ -20,14 +20,20 @@ int main() { 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; + bool const ok = bob_public && sealed_box::seal(bob_public->bytes(), message, sealed) && + sealed_box::open(bob_public->bytes(), bob_secret, 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/x25519_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/x25519_default/app.cpp index 38429082..4bf4fa95 100644 --- a/tools/test/fixtures/crypto_jamfiles/x25519_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/x25519_default/app.cpp @@ -4,9 +4,10 @@ // accompanying file LICENSE_1_0.txt or copy at // https://www.boost.org/LICENSE_1_0.txt) -// Agrees RFC 7748's shared secret (section 6.1) from Alice's secret key and Bob's public key on -// the default backend, checks it against the RFC's, and prints the backend that ran. The keys are -// the RFC's: a real program draws its own, and never prints a shared secret. +// Agrees RFC 7748's shared secret (section 6.1) from Alice's key pair, made from her secret key, +// and Bob's public key on the default backend, checks it against the RFC's, and prints the +// backend that ran. The keys are the RFC's: a real program draws its own, and never prints a +// shared secret. #include #include @@ -31,9 +32,15 @@ int main() { 0xf4, 0x80, 0x35, 0x0f, 0x25, 0xe0, 0x7e, 0x21, 0xc9, 0x47, 0xd1, 0x9e, 0x33, 0x76, 0xf0, 0x9b, 0x3c, 0x1e, 0x16, 0x17, 0x42, }; - auto const shared = x25519::agree(alice_secret, bob_public); + auto const alice = x25519::keypair::from_secret(alice_secret); + auto const bob = x25519::public_key::from_bytes(bob_public); + if (!alice || !bob) { + std::printf("x25519 FAILED\n"); + return 1; + } + auto const shared = alice->agree(*bob); bool const ok = shared && webcpp::crypto::constant_time_equal(shared->bytes(), expected); - auto const name = x25519::algorithm<>::backend_type::name; + auto const name = x25519::keypair::backend_type::name; std::printf("x25519 %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/x25519_default_not_linked_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/x25519_default_not_linked_on_emscripten/app.cpp index b5b44d97..25013f53 100644 --- a/tools/test/fixtures/crypto_jamfiles/x25519_default_not_linked_on_emscripten/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/x25519_default_not_linked_on_emscripten/app.cpp @@ -4,15 +4,18 @@ // accompanying file LICENSE_1_0.txt or copy at // https://www.boost.org/LICENSE_1_0.txt) -// A program that agrees an X25519 shared secret on its default backend, libsodium on every target, -// without linking it, stops where it calls it, with the line that links libsodium, the one backend -// that has it (design D32). +// A program that makes an X25519 key pair and agrees a shared secret on its default backend, +// libsodium on every target, without linking it, stops where it calls it, with the line that +// links libsodium, the one backend that has it (design D32). #include #include #include int main() { - std::array const key{}; - return webcpp::crypto::curves::x25519::agree(key, key) ? 0 : 1; + namespace x25519 = webcpp::crypto::curves::x25519; + std::array const key{9}; + auto const key_pair = x25519::keypair::from_secret(key); + auto const peer = x25519::public_key::from_bytes(key); + return key_pair && peer && key_pair->agree(*peer) ? 0 : 1; } From f5790a6acecac6c733c11805793204f407286bdc Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 15:32:55 -0300 Subject: [PATCH 13/44] crypto: libs/crypto with the X25519 fix round --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index a2ad4d12..d043e346 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit a2ad4d12d25d2169b09198fa203bcd0b0f457483 +Subproject commit d043e3468e35a960d0efc0db529c2ac046977a98 From 7d38ca5da3d0838daa62cd214bc453bc10ac1739 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 15:53:35 -0300 Subject: [PATCH 14/44] crypto fixtures and guidelines: crypto's public names are spelled out --- CODING-GUIDELINES.md | 22 ++++++++++++++++--- libs/crypto | 2 +- .../both_bearssl_named/app.cpp | 12 +++++----- .../box_xchacha20poly1305_default/app.cpp | 6 ++--- .../box_xsalsa20poly1305_default/app.cpp | 6 ++--- .../crypto_jamfiles/canary_missing/app.cpp | 4 ++-- .../canary_other_commit/app.cpp | 4 ++-- .../canary_other_configuration/app.cpp | 4 ++-- .../crypto_jamfiles/canary_without/app.cpp | 4 ++-- .../chacha20_poly1305_default/app.cpp | 10 ++++----- .../app.cpp | 8 +++---- .../crypto_jamfiles/encrypt_and_sign/app.cpp | 6 ++--- .../crypto_jamfiles/gcm_default/app.cpp | 12 +++++----- .../crypto_jamfiles/memory_option/app.cpp | 11 +++++----- .../crypto_jamfiles/openssl_linked/app.cpp | 6 ++--- .../app.cpp | 6 ++--- .../app.cpp | 6 ++--- .../fixtures/crypto_jamfiles/server/app.cpp | 12 +++++----- .../test/fixtures/crypto_jamfiles/web/app.cpp | 12 +++++----- .../xchacha20_poly1305_default/app.cpp | 12 +++++----- 20 files changed, 91 insertions(+), 74 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index e3c431c0..988ff480 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -6993,6 +6993,16 @@ decided and not built is in chapter 17. 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. + Source: `libraries/crypto/openspec/changes/uniform-types/design.md` owner + decision 13, D11 (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 @@ -7104,9 +7114,10 @@ decided 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 @@ -9562,6 +9573,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 d043e346..ca1188a3 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit d043e3468e35a960d0efc0db529c2ac046977a98 +Subproject commit ca1188a3b80fc7c5999e74afffc5c8732237db8e 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 fee9a629..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,9 +6,9 @@ // 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 @@ -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, @@ -39,11 +39,11 @@ int main() { if (!aead) { return 1; } - auto const tag = aead->seal(iv, {}, data); + 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_xchacha20poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/box_xchacha20poly1305_default/app.cpp index 54a2b0e0..e0486f1e 100644 --- a/tools/test/fixtures/crypto_jamfiles/box_xchacha20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/box_xchacha20poly1305_default/app.cpp @@ -46,7 +46,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" @@ -59,10 +59,10 @@ int main() { auto bob = box::from_keys(bob_secret, alice_public); bool ok = false; if (alice && bob) { - auto const sealed = alice->seal(iv, data); + 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 9dd962d0..98109d78 100644 --- a/tools/test/fixtures/crypto_jamfiles/box_xsalsa20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/box_xsalsa20poly1305_default/app.cpp @@ -46,7 +46,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" @@ -59,10 +59,10 @@ int main() { auto bob = box::from_keys(bob_secret, alice_public); bool ok = false; if (alice && bob) { - auto const sealed = alice->seal(iv, data); + 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_missing/app.cpp b/tools/test/fixtures/crypto_jamfiles/canary_missing/app.cpp index 54954f43..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>::from_key(key); - return aead && aead->seal(iv, {}, data) ? 0 : 1; + 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 54954f43..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>::from_key(key); - return aead && aead->seal(iv, {}, data) ? 0 : 1; + 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 54954f43..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>::from_key(key); - return aead && aead->seal(iv, {}, data) ? 0 : 1; + return aead && aead->seal(nonce, {}, data) ? 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 54954f43..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>::from_key(key); - return aead && aead->seal(iv, {}, data) ? 0 : 1; + 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 5dcd152d..f7bae48b 100644 --- a/tools/test/fixtures/crypto_jamfiles/chacha20_poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/chacha20_poly1305_default/app.cpp @@ -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 = @@ -46,10 +46,10 @@ int main() { auto sealer = aead::from_key(key); bool ok = false; if (sealer) { - auto const tag = sealer->seal(iv, additional_data, data); + 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 76d9f18a..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 @@ -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}; @@ -42,10 +42,10 @@ int main() { auto sealer = aead::from_key(key); bool ok = false; if (sealer) { - auto const tag = sealer->seal(iv, additional_data, data); + 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/encrypt_and_sign/app.cpp b/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp index 159cc3e7..d1d7833f 100644 --- a/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp @@ -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, @@ -32,11 +32,11 @@ int main() { if (!aead) { return 1; } - auto const tag = aead->seal(iv, {}, data); + 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/gcm_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/gcm_default/app.cpp index 2d8ffb9d..14b60607 100644 --- a/tools/test/fixtures/crypto_jamfiles/gcm_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/gcm_default/app.cpp @@ -5,9 +5,9 @@ // 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 @@ -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, @@ -31,11 +31,11 @@ int main() { if (!aead) { return 1; } - auto const tag = aead->seal(iv, {}, data); + 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/memory_option/app.cpp b/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp index 69b6b556..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,7 +35,7 @@ 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::from_key(key); if (!aead) { @@ -43,8 +43,9 @@ int main() { 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/openssl_linked/app.cpp b/tools/test/fixtures/crypto_jamfiles/openssl_linked/app.cpp index b59cb8ea..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,13 +23,13 @@ int main() { #endif namespace crypto = webcpp::crypto; std::array const key{}; - std::array const iv{}; + 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/secretbox_xchacha20poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp index 2d2171e2..51f5cf82 100644 --- a/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp @@ -39,7 +39,7 @@ int main() { using secretbox = webcpp::crypto::ciphers::secretbox_xchacha20poly1305<>; auto const key = from_hex<32>("10c0ad4054b48d7d1de1d9ab6f782ca883d886573e9d18c1d47b6ee6b5208189"); - auto const iv = from_hex<24>("977edf57428d0e0247a3c88c9a9ec321bbaae1a4da8353b5"); + auto const nonce = from_hex<24>("977edf57428d0e0247a3c88c9a9ec321bbaae1a4da8353b5"); auto const plaintext = from_hex<21>("518e4a27949812424b2a381c3efea6055ee5e75eff"); auto const expected_tag = from_hex<16>("0c801a037c2ed0500d6ef68e8d195ece"); auto const expected = from_hex<21>("b05a15f8edb68b35773e81ac2aca18e9be53416f9a"); @@ -47,9 +47,9 @@ int main() { auto sealer = secretbox::from_key(key); bool ok = false; if (sealer) { - auto const tag = sealer->seal(iv, {}, data); + auto const tag = sealer->seal(nonce, {}, data); ok = tag && webcpp::crypto::constant_time_equal(*tag, expected_tag) && data == expected && - sealer->open(iv, {}, data, expected_tag) && data == plaintext; + sealer->open(nonce, {}, data, expected_tag) && data == plaintext; } auto const name = secretbox::backend_type::name; std::printf("secretbox_xchacha20poly1305 %s backend=%.*s\n", ok ? "ok" : "FAILED", diff --git a/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp index b811ffd6..e0b1599f 100644 --- a/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp @@ -40,7 +40,7 @@ int main() { using secretbox = webcpp::crypto::ciphers::secretbox<>; auto const key = from_hex<32>("1b27556473e985d462cd51197a9a46c76009549eac6474f206c4ee0844f68389"); - auto const iv = from_hex<24>("69696ee955b62b73cd62bda875fc73d68219e0036b7a0b37"); + auto const nonce = from_hex<24>("69696ee955b62b73cd62bda875fc73d68219e0036b7a0b37"); auto const plaintext = from_hex<131>( "be075fc53c81f2d5cf141316ebeb0c7b5228c52a4c62cbd44b66849b64244ffce5ecbaaf33bd751a1ac7" "28d45e6c61296cdc3c01233561f41db66cce314adb310e3be8250c46f06dceea3a7fa1348057e2f6556a" @@ -52,10 +52,10 @@ int main() { auto sealer = secretbox::from_key(key); bool ok = false; if (sealer) { - auto const tag = sealer->seal(iv, {}, data); + auto const tag = sealer->seal(nonce, {}, data); ok = tag && webcpp::crypto::constant_time_equal(*tag, expected_tag) && std::equal(expected_head.begin(), expected_head.end(), data.begin()) && - sealer->open(iv, {}, data, expected_tag) && data == plaintext; + sealer->open(nonce, {}, data, expected_tag) && data == plaintext; } auto const name = secretbox::backend_type::name; std::printf("secretbox %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()), diff --git a/tools/test/fixtures/crypto_jamfiles/server/app.cpp b/tools/test/fixtures/crypto_jamfiles/server/app.cpp index 2d8ffb9d..14b60607 100644 --- a/tools/test/fixtures/crypto_jamfiles/server/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/server/app.cpp @@ -5,9 +5,9 @@ // 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 @@ -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, @@ -31,11 +31,11 @@ int main() { if (!aead) { return 1; } - auto const tag = aead->seal(iv, {}, data); + 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/web/app.cpp b/tools/test/fixtures/crypto_jamfiles/web/app.cpp index 2d8ffb9d..14b60607 100644 --- a/tools/test/fixtures/crypto_jamfiles/web/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/web/app.cpp @@ -5,9 +5,9 @@ // 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 @@ -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, @@ -31,11 +31,11 @@ int main() { if (!aead) { return 1; } - auto const tag = aead->seal(iv, {}, data); + 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/xchacha20_poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/xchacha20_poly1305_default/app.cpp index 1034707e..55f543f3 100644 --- a/tools/test/fixtures/crypto_jamfiles/xchacha20_poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/xchacha20_poly1305_default/app.cpp @@ -26,13 +26,13 @@ int main() { key[index] = static_cast(0x80 + index); } // The nonce 0x40, 0x41, ..., 0x57. - std::array iv{}; - for (std::size_t index = 0; index < iv.size(); ++index) { - iv[index] = static_cast(0x40 + index); + std::array nonce{}; + for (std::size_t index = 0; index < nonce.size(); ++index) { + nonce[index] = static_cast(0x40 + index); } // 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{0x50, 0x51, 0x52, 0x53, 0xc0, 0xc1, + 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 = @@ -49,10 +49,10 @@ int main() { auto sealer = aead::from_key(key); bool ok = false; if (sealer) { - auto const tag = sealer->seal(iv, additional_data, data); + 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("xchacha20_poly1305 %s backend=%.*s\n", ok ? "ok" : "FAILED", From 502d9e4eef2600a9d0f3def03b1af5364b12968f Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 16:00:56 -0300 Subject: [PATCH 15/44] crypto guidelines: the AEAD rules say nonce and associated data --- CODING-GUIDELINES.md | 30 ++++++++++++++++-------------- libs/crypto | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 988ff480..0f9e64e3 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7095,14 +7095,15 @@ decided 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` @@ -7120,18 +7121,19 @@ decided and not built is in chapter 17. 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). @@ -7560,7 +7562,7 @@ decided 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 diff --git a/libs/crypto b/libs/crypto index ca1188a3..b44dde7a 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit ca1188a3b80fc7c5999e74afffc5c8732237db8e +Subproject commit b44dde7a4613bc89d55b1cb18e1b335c056afcb2 From 5ec30fa1e01ac99325009e59c2dde4e9989475e3 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 16:18:10 -0300 Subject: [PATCH 16/44] crypto: libs/crypto with X4's fix round 1 --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index b44dde7a..12fd7894 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit b44dde7a4613bc89d55b1cb18e1b335c056afcb2 +Subproject commit 12fd7894c2d7cab8ca62fc2565ff28cb00e15e76 From a871ec501a25198d26108b3a9975c9714218cf9f Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 16:44:11 -0300 Subject: [PATCH 17/44] crypto fixtures: crypto_kx and the boxes on typed X25519 keys --- libs/crypto | 2 +- .../app.cpp | 32 ++++++++++++++----- .../box_not_a_family_on_emscripten/app.cpp | 20 ++++++++---- .../box_xchacha20poly1305_default/app.cpp | 19 ++++++++--- .../box_xsalsa20poly1305_default/app.cpp | 19 ++++++++--- .../sealed_box_default/app.cpp | 5 ++- 6 files changed, 71 insertions(+), 26 deletions(-) diff --git a/libs/crypto b/libs/crypto index 12fd7894..26fe9478 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 12fd7894c2d7cab8ca62fc2565ff28cb00e15e76 +Subproject commit 26fe94782e455877f5a9bb675a76a80b23a67e71 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 7d5c8232..86e62945 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 @@ -7,21 +7,37 @@ // As test/messages/box_default_not_linked, on Emscripten. #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<>::from_key(key) && - crypto::ciphers::secretbox_xchacha20poly1305<>::from_key(key) && - crypto::public_key_encryption::box::from_keys(key, key) && - crypto::public_key_encryption::box_xchacha20poly1305::from_keys(key, key) && - crypto::public_key_encryption::sealed_box::seal(key, {}, sealed) - ? 0 - : 1; + crypto::ciphers::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 77381577..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,20 +6,28 @@ // As test/messages/box_not_a_family, on Emscripten. +#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{}; - using box = webcpp::crypto::public_key_encryption::basic_box; - return box::from_keys(key, key) ? 0 : 1; + static_cast(&made); + return 0; } 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 e0486f1e..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,9 +6,11 @@ // 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. +// 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 @@ -55,9 +57,18 @@ int main() { auto const expected_tag = from_hex<16>("0b4ff00742f3c1aa99a6321e3883b03c"); auto const expected_head = from_hex<8>("ef2c6061b7bcec0c"); auto data = plaintext; - auto alice = box::from_keys(alice_secret, bob_public); - auto bob = box::from_keys(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(nonce, data); ok = sealed && webcpp::crypto::constant_time_equal(*sealed, expected_tag) && 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 98109d78..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,9 +6,11 @@ // 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. +// 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 @@ -55,9 +57,18 @@ int main() { auto const expected_tag = from_hex<16>("f3ffc7703f9400e52a7dfb4b3d3305d9"); auto const expected_head = from_hex<8>("8e993b9f48681273"); auto data = plaintext; - auto alice = box::from_keys(alice_secret, bob_public); - auto bob = box::from_keys(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(nonce, data); ok = sealed && webcpp::crypto::constant_time_equal(*sealed, expected_tag) && 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 94aeeab1..a399284d 100644 --- a/tools/test/fixtures/crypto_jamfiles/sealed_box_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/sealed_box_default/app.cpp @@ -31,9 +31,8 @@ int main() { std::ranges::copy(feedback, message.begin()); std::array sealed{}; std::array opened{}; - bool const ok = bob_public && sealed_box::seal(bob_public->bytes(), message, sealed) && - sealed_box::open(bob_public->bytes(), bob_secret, sealed, opened) && - opened == message; + bool const ok = bob_public && sealed_box::seal(*bob_public, message, sealed) && + 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()); From ca9c292ab0d78817a107fc5fb489a9e4d78ab81f Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 16:52:56 -0300 Subject: [PATCH 18/44] crypto: libs/crypto with the X25519 refusals of crypto_kx and the boxes --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 26fe9478..d8b67525 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 26fe94782e455877f5a9bb675a76a80b23a67e71 +Subproject commit d8b67525da2c41480706843d791c87b82336edcd From 1c20ad1a6548204a1f773f0f00c461256c5ca6c3 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 17:07:32 -0300 Subject: [PATCH 19/44] crypto: libs/crypto with Ed25519's typed conversion to X25519 --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index d8b67525..ee2e030a 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit d8b67525da2c41480706843d791c87b82336edcd +Subproject commit ee2e030afa12f99ec6cf99ea882e342f2062a88b From b8225452d37cadb65c7e7a2a265b0802f48f31f7 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 17:13:12 -0300 Subject: [PATCH 20/44] crypto: libs/crypto with 2.3's fix round 1 --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index ee2e030a..21438072 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit ee2e030afa12f99ec6cf99ea882e342f2062a88b +Subproject commit 214380728210d93f6a18893243f5ec3786fcbf4f From 9f0142b62e00fe809263727defad5a065fabc106 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 17:35:24 -0300 Subject: [PATCH 21/44] crypto: libs/crypto with the three key pair concepts and 3.1's fix round 1 --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 21438072..494c0ca6 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 214380728210d93f6a18893243f5ec3786fcbf4f +Subproject commit 494c0ca61a9aeeef66fe0b233c412ab82bd0dddb From cdf455125fcc8c549f40ba31fb9fa8db36c60356 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 18:09:03 -0300 Subject: [PATCH 22/44] crypto fixtures: secret boxes are secret_key_encryption's and seal without associated data --- libs/crypto | 2 +- .../box_default_not_linked_on_emscripten/app.cpp | 6 +++--- .../secretbox_xchacha20poly1305_default/app.cpp | 8 ++++---- .../secretbox_xsalsa20poly1305_default/app.cpp | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libs/crypto b/libs/crypto index 494c0ca6..3b5629b4 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 494c0ca61a9aeeef66fe0b233c412ab82bd0dddb +Subproject commit 3b5629b45cff36a3a1db3e058d1eb1f68dd275ec 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 86e62945..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,10 +6,10 @@ // As test/messages/box_default_not_linked, on Emscripten. -#include #include #include #include +#include #include #include @@ -26,8 +26,8 @@ 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<>::from_key(key) && - crypto::ciphers::secretbox_xchacha20poly1305<>::from_key(key) && + 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) && diff --git a/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp index 51f5cf82..9b7cd458 100644 --- a/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secretbox_xchacha20poly1305_default/app.cpp @@ -8,8 +8,8 @@ // backend, checks the tag and the ciphertext against the test'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 a 24-byte nonce drawn at random for every message is safe. -#include #include +#include #include #include @@ -36,7 +36,7 @@ std::array from_hex(std::string_view hex) { } // namespace int main() { - using secretbox = webcpp::crypto::ciphers::secretbox_xchacha20poly1305<>; + using secretbox = webcpp::crypto::secret_key_encryption::secretbox_xchacha20poly1305<>; auto const key = from_hex<32>("10c0ad4054b48d7d1de1d9ab6f782ca883d886573e9d18c1d47b6ee6b5208189"); auto const nonce = from_hex<24>("977edf57428d0e0247a3c88c9a9ec321bbaae1a4da8353b5"); @@ -47,9 +47,9 @@ int main() { auto sealer = secretbox::from_key(key); bool ok = false; if (sealer) { - auto const tag = sealer->seal(nonce, {}, data); + auto const tag = sealer->seal(nonce, data); ok = tag && webcpp::crypto::constant_time_equal(*tag, expected_tag) && data == expected && - sealer->open(nonce, {}, data, expected_tag) && data == plaintext; + sealer->open(nonce, data, expected_tag) && data == plaintext; } auto const name = secretbox::backend_type::name; std::printf("secretbox_xchacha20poly1305 %s backend=%.*s\n", ok ? "ok" : "FAILED", diff --git a/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp index e0b1599f..f145a7e5 100644 --- a/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secretbox_xsalsa20poly1305_default/app.cpp @@ -8,8 +8,8 @@ // the tag and the ciphertext's first bytes against secretbox.exp, 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 a 24-byte nonce drawn at random for every message is safe. -#include #include +#include #include #include @@ -37,7 +37,7 @@ std::array from_hex(std::string_view hex) { } // namespace int main() { - using secretbox = webcpp::crypto::ciphers::secretbox<>; + using secretbox = webcpp::crypto::secret_key_encryption::secretbox<>; auto const key = from_hex<32>("1b27556473e985d462cd51197a9a46c76009549eac6474f206c4ee0844f68389"); auto const nonce = from_hex<24>("69696ee955b62b73cd62bda875fc73d68219e0036b7a0b37"); @@ -52,10 +52,10 @@ int main() { auto sealer = secretbox::from_key(key); bool ok = false; if (sealer) { - auto const tag = sealer->seal(nonce, {}, data); + auto const tag = sealer->seal(nonce, data); ok = tag && webcpp::crypto::constant_time_equal(*tag, expected_tag) && std::equal(expected_head.begin(), expected_head.end(), data.begin()) && - sealer->open(nonce, {}, data, expected_tag) && data == plaintext; + sealer->open(nonce, data, expected_tag) && data == plaintext; } auto const name = secretbox::backend_type::name; std::printf("secretbox %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()), From a47d977df603e6a3f750f021fbb041bffccbd7a8 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 18:57:42 -0300 Subject: [PATCH 23/44] crypto: libs/crypto with 3.2's fix round 1 --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 3b5629b4..d27e8f86 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 3b5629b45cff36a3a1db3e058d1eb1f68dd275ec +Subproject commit d27e8f868143c22dc28ce9e209e3163b7293d82e From 376fe4a5e915c8614774bf2dd1ba90478b442c42 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 20:08:53 -0300 Subject: [PATCH 24/44] crypto: libs/crypto with Task 3.3 and its fix round 1 --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index d27e8f86..83c8a581 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit d27e8f868143c22dc28ce9e209e3163b7293d82e +Subproject commit 83c8a5810c648e8fb4ca0a6b7023c1279f5f5c35 From 4840e57e4ea0353c103a218620b761c5f0d10c08 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 20:20:40 -0300 Subject: [PATCH 25/44] crypto: point libs/crypto at the throwing-getRandomValues fix (Task X1) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 83c8a581..138ab3cc 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 83c8a5810c648e8fb4ca0a6b7023c1279f5f5c35 +Subproject commit 138ab3cc0fbc89d2f4719f550a45cb307251cda9 From c5da5cf613289d6061a3fe4ea4949c759a8a5c40 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 20:43:00 -0300 Subject: [PATCH 26/44] crypto: libs/crypto with Task X1's lint fix --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 138ab3cc..0197c8c0 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 138ab3cc0fbc89d2f4719f550a45cb307251cda9 +Subproject commit 0197c8c0b7bf5945158269bec4a3194ad4e26d07 From 01bbc866c0a0d03cbb6f002eb55eab975d2dfea0 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 21:22:20 -0300 Subject: [PATCH 27/44] crypto: libs/crypto with Task X1's fix round 1 --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 0197c8c0..19d61286 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 0197c8c0b7bf5945158269bec4a3194ad4e26d07 +Subproject commit 19d61286e23d0def74222c7d45087617e58f0cf3 From f6c2394be653e9c7b06d2b660339a0c1e73fb271 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 21:49:24 -0300 Subject: [PATCH 28/44] crypto: point libs/crypto at libsodium drawing through crypto's entropy in the browser (Task X1b) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 19d61286..166d23be 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 19d61286e23d0def74222c7d45087617e58f0cf3 +Subproject commit 166d23be5796ef3e554c4971df2fd859a58f4bae From 1916bc2059eabf16c09f5dfb67e0b8abee1bea2e Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 22:47:14 -0300 Subject: [PATCH 29/44] crypto: libs/crypto with Task X1b's lint fix --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 166d23be..5a04d96d 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 166d23be5796ef3e554c4971df2fd859a58f4bae +Subproject commit 5a04d96dfe3d7149c896a88b53335a85f537107f From 9c7bfc4cf935b9b861aedc89795912d3dcdf963a Mon Sep 17 00:00:00 2001 From: R Date: Mon, 23 Nov 2026 23:50:40 -0300 Subject: [PATCH 30/44] crypto: libs/crypto with Task X1b's fix round 1 --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 5a04d96d..d5bda216 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 5a04d96dfe3d7149c896a88b53335a85f537107f +Subproject commit d5bda216e9e406f9b5bc8ef53d64da05a7ad91d9 From dbc7aa2e92c76c3aada6d99dae88f3c03f280b51 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 24 Nov 2026 00:15:49 -0300 Subject: [PATCH 31/44] crypto: libs/crypto with Task X1b's fix round 1 lint fix --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index d5bda216..bc3fd50d 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit d5bda216e9e406f9b5bc8ef53d64da05a7ad91d9 +Subproject commit bc3fd50d7e1290b07a997bfdd8e4fb6c31ebf1bf From 8e383588e5f23ed736a7b131fbc52964c5c65162 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 24 Nov 2026 00:28:09 -0300 Subject: [PATCH 32/44] crypto fixtures and guidelines: basic_chacha20_poly1305 and secp256k1's spelled-out names Task X5 (owner decision 14, design D12): the fixtures aead_not_a_family_on_emscripten (whose expected text also drops the secret-box families the refusal no longer lists), secp256k1_musig_default and secp256k1_silent_payments_default name ciphers::basic_chacha20_poly1305, musig::generate_nonce and make_previous_outputs_summary; the naming rule says that names taken from a C library are spelled out and a class template is named for its algorithm; libs/crypto points at the three X5 commits. --- CODING-GUIDELINES.md | 8 ++++++-- libs/crypto | 2 +- .../aead_not_a_family_on_emscripten.outcome | 2 +- .../aead_not_a_family_on_emscripten/app.cpp | 8 +++++--- .../crypto_jamfiles/secp256k1_musig_default/app.cpp | 6 +++--- .../secp256k1_silent_payments_default/app.cpp | 4 ++-- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 0f9e64e3..fb3cdf49 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7000,9 +7000,13 @@ decided and not built is in chapter 17. `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. + 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 (proposals). + 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 diff --git a/libs/crypto b/libs/crypto index bc3fd50d..378a5a38 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit bc3fd50d7e1290b07a997bfdd8e4fb6c31ebf1bf +Subproject commit 378a5a38b173b971fe7ac415458740531ca0d60d 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 0841b89e..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::from_key(key) ? 0 : 1; + return cipher::from_key(key) ? 0 : 1; } diff --git a/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp index 10ce90e1..21a3bd95 100644 --- a/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp @@ -7,7 +7,7 @@ // Aggregates two fixed key pairs' public keys with BIP 327's MuSig2 on MuSig2's default backend, // signs a message in its two rounds, verifies the aggregate as one BIP 340 signature, and prints // the backend that ran. The secrets are fixed: a real program draws its own. The nonces are drawn -// inside nonce_gen. +// inside generate_nonce. #include #include #include @@ -44,8 +44,8 @@ bool sign_and_verify(secp256k1::keypair const& first, secp256k1::keypair const& return false; } auto const message = repeated(0x5a); - auto first_nonce = musig::nonce_gen(first, *aggregate, message); - auto second_nonce = musig::nonce_gen(second, *aggregate, message); + auto first_nonce = musig::generate_nonce(first, *aggregate, message); + auto second_nonce = musig::generate_nonce(second, *aggregate, message); if (!first_nonce || !second_nonce) { return false; } diff --git a/tools/test/fixtures/crypto_jamfiles/secp256k1_silent_payments_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_silent_payments_default/app.cpp index 04d63b60..bdd3aef8 100644 --- a/tools/test/fixtures/crypto_jamfiles/secp256k1_silent_payments_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_silent_payments_default/app.cpp @@ -50,8 +50,8 @@ bool pay_and_scan(secp256k1::keypair const& scan_pair, secp256k1::keypair const& std::array const input_keys{*donor_key}; alignas(std::max_align_t) std::array summary_space{}; - auto const summary = - silent_payments::make_prevouts_summary(smallest_outpoint, {}, input_keys, summary_space); + auto const summary = silent_payments::make_previous_outputs_summary(smallest_outpoint, {}, + input_keys, summary_space); if (!summary) { return false; } From 7039928e2099d8e5473f1e7bf283856893d84345 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 24 Nov 2026 00:48:18 -0300 Subject: [PATCH 33/44] crypto: libs/crypto with Task X5's lint fix --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 378a5a38..d196e9c1 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 378a5a38b173b971fe7ac415458740531ca0d60d +Subproject commit d196e9c1c35b7daaba254cec9a377c4ec5ee500c From f558dd8fe86f4ce78152b5ff04f690a3de3da83e Mon Sep 17 00:00:00 2001 From: R Date: Tue, 24 Nov 2026 02:48:16 -0300 Subject: [PATCH 34/44] crypto: libs/crypto with Task X5's fix round 1 --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index d196e9c1..e2ae583e 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit d196e9c1c35b7daaba254cec9a377c4ec5ee500c +Subproject commit e2ae583edb44d13be1c56d7e524c6535e86d0786 From 5ea3fd3bb797defba7889c24d03bbb4f2be6d538 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 24 Nov 2026 03:13:45 -0300 Subject: [PATCH 35/44] crypto: libs/crypto with Task X5's fix round 2 --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index e2ae583e..5664a841 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit e2ae583edb44d13be1c56d7e524c6535e86d0786 +Subproject commit 5664a841d801a7033129db0bcff8d41b4003c74f From e4f6857019592908ab931e1a0c034b267e84f38f Mon Sep 17 00:00:00 2001 From: R Date: Tue, 24 Nov 2026 03:24:41 -0300 Subject: [PATCH 36/44] guidelines: crypto's chapter names its factories by their input and describes version 0.1 as it was --- CODING-GUIDELINES.md | 61 +++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index fb3cdf49..2ae484cb 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -6973,12 +6973,14 @@ 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, `constant_time_equal`, `erase_secret`, 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.** @@ -7020,10 +7022,11 @@ decided 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; the name of the input says where a secret comes from. 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 @@ -7144,8 +7147,8 @@ decided and not built is in chapter 17. **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. @@ -7196,16 +7199,16 @@ decided 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). @@ -7314,9 +7317,9 @@ decided 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; @@ -7381,9 +7384,9 @@ decided 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 @@ -7435,7 +7438,7 @@ decided 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 @@ -7491,7 +7494,7 @@ decided 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 From addb2e4bdf99df80148e6abf9c6053f5d1a51a33 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 24 Nov 2026 03:25:15 -0300 Subject: [PATCH 37/44] guidelines: crypto's values are typed, checked by concepts and made by factories named by their input --- CODING-GUIDELINES.md | 37 ++++++++++++++++++++++++++++++++----- libs/crypto | 2 +- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 2ae484cb..6a84e60d 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7026,7 +7026,7 @@ not built is in chapter 17. `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; the name of the input says where a secret comes from. + 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 @@ -7237,12 +7237,39 @@ 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 diff --git a/libs/crypto b/libs/crypto index 5664a841..63b7f66f 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 5664a841d801a7033129db0bcff8d41b4003c74f +Subproject commit 63b7f66fe75af8dfeb486161053f240e19ca5e99 From 732ff2b10622cfca11682aa6b3d2fcdca612d41c Mon Sep 17 00:00:00 2001 From: R Date: Tue, 24 Nov 2026 03:30:55 -0300 Subject: [PATCH 38/44] crypto: libs/crypto with Task 4.1's fix round 1 --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 63b7f66f..e7dc82e9 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 63b7f66fe75af8dfeb486161053f240e19ca5e99 +Subproject commit e7dc82e94ae1342a4aadeecebace56c331081f21 From 586b869bd6b0ca13c91f3f14525ff75d4e47cbd2 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 24 Nov 2026 03:40:59 -0300 Subject: [PATCH 39/44] crypto: libs/hash with origin/main merged into its uniform-types branch --- libs/hash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hash b/libs/hash index 59debe6e..659e50d7 160000 --- a/libs/hash +++ b/libs/hash @@ -1 +1 @@ -Subproject commit 59debe6e48c9395b656e2fcdc16230ae954d13e2 +Subproject commit 659e50d7001e4664a7d60911243ddee285e457cb From 71490721a3ee147194c1ca9e75371c68e6465c6f Mon Sep 17 00:00:00 2001 From: R Date: Tue, 24 Nov 2026 07:19:15 -0300 Subject: [PATCH 40/44] crypto: the Emscripten fixture of a heavy operation without threads names its completion token as the refusal reads it --- .../heavy_without_threads_on_emscripten/app.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 {}; From a16fe3fb3bb490735eedf4dfefaf3db5bbdea7cf Mon Sep 17 00:00:00 2001 From: R Date: Tue, 24 Nov 2026 07:25:30 -0300 Subject: [PATCH 41/44] guidelines: crypto's present-tense rules name public_key_combine, generate_nonce, constant_time_equal, the nonce and basic_chacha20_poly1305 --- CODING-GUIDELINES.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 6a84e60d..b02c99a7 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -8856,20 +8856,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 @@ -8904,8 +8904,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". @@ -8976,13 +8976,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 From 0ab0ace4f3999edd9f6c2d62eb2634e47c7c717c Mon Sep 17 00:00:00 2001 From: R Date: Tue, 24 Nov 2026 07:32:16 -0300 Subject: [PATCH 42/44] crypto: libs/crypto with Task 4.2's fix round 1 --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index e7dc82e9..e07d44a4 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit e7dc82e94ae1342a4aadeecebace56c331081f21 +Subproject commit e07d44a4bc64e0e835c7903421ca6a8167afe41a From 0db27087df067964efc52e91346055d54514f1f9 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 24 Nov 2026 07:58:03 -0300 Subject: [PATCH 43/44] crypto: libs/crypto with Task 4.2's fix round 2 --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index e07d44a4..07b3409c 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit e07d44a4bc64e0e835c7903421ca6a8167afe41a +Subproject commit 07b3409caea25dfaaee8748c8028279d3d3109a5 From 4ba0cc565567a74c1e7ee44074544431219e3a14 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 24 Nov 2026 08:20:57 -0300 Subject: [PATCH 44/44] libs/crypto, libs/hash: the gitlinks at the merges of crypto's uniform types and hash's constant_time_equal callers (3314a1d, 030e757) --- libs/crypto | 2 +- libs/hash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/crypto b/libs/crypto index 07b3409c..3314a1d1 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 07b3409caea25dfaaee8748c8028279d3d3109a5 +Subproject commit 3314a1d122220f960fc72920b239131ee314b6a3 diff --git a/libs/hash b/libs/hash index 659e50d7..030e7572 160000 --- a/libs/hash +++ b/libs/hash @@ -1 +1 @@ -Subproject commit 659e50d7001e4664a7d60911243ddee285e457cb +Subproject commit 030e7572e7f89120639fe807c717ae91353d87e1