From 1ca089029bff2ce3412694a89383b05181d565af Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 09:48:30 -0300 Subject: [PATCH 01/25] tools: crypto's fixture of the memory option on Emscripten --- .../openssl_memory_on_emscripten/Jamfile | 9 +++++++++ .../openssl_memory_on_emscripten/app.cpp | 9 +++++++++ .../openssl_memory_on_emscripten.outcome | 14 ++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 tools/test/fixtures/crypto_jamfiles/openssl_memory_on_emscripten/Jamfile create mode 100644 tools/test/fixtures/crypto_jamfiles/openssl_memory_on_emscripten/app.cpp create mode 100644 tools/test/fixtures/crypto_jamfiles/openssl_memory_on_emscripten/openssl_memory_on_emscripten.outcome diff --git a/tools/test/fixtures/crypto_jamfiles/openssl_memory_on_emscripten/Jamfile b/tools/test/fixtures/crypto_jamfiles/openssl_memory_on_emscripten/Jamfile new file mode 100644 index 00000000..0c6ec52b --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/openssl_memory_on_emscripten/Jamfile @@ -0,0 +1,9 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# tag::jamfile[] +exe app : app.cpp /webcpp/crypto//crypto : WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE ; +# end::jamfile[] diff --git a/tools/test/fixtures/crypto_jamfiles/openssl_memory_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/openssl_memory_on_emscripten/app.cpp new file mode 100644 index 00000000..6c80fb35 --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/openssl_memory_on_emscripten/app.cpp @@ -0,0 +1,9 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include + +int main() {} diff --git a/tools/test/fixtures/crypto_jamfiles/openssl_memory_on_emscripten/openssl_memory_on_emscripten.outcome b/tools/test/fixtures/crypto_jamfiles/openssl_memory_on_emscripten/openssl_memory_on_emscripten.outcome new file mode 100644 index 00000000..ac6e5fc3 --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/openssl_memory_on_emscripten/openssl_memory_on_emscripten.outcome @@ -0,0 +1,14 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# The compiler's line of the #error starts with the header's path on the machine, so the +# message is a contains: line. +[all] +targets: emscripten +build: fails +# tag::messages[] +contains: webcpp::crypto: WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE is an option of native programs, and this program is built for WebAssembly. Remove that define from the program's Jamfile. +# end::messages[] From ac6469c77c6076c72238ccf07708e1d242ecfac7 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 11:18:20 -0300 Subject: [PATCH 02/25] libs/crypto: OpenSSL's memory functions as an option of the config (errors 13 and 14, the adapter) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index ae937e57..ab1d78f4 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit ae937e5743ce78e97ac2e9983838eca69fbc3f15 +Subproject commit ab1d78f48fd571c1ab48116d64b9cbb66dc57193 From df87921620b907cc8d6057be9273529dc07729a5 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 11:33:30 -0300 Subject: [PATCH 03/25] libs/crypto: the memory option's counting resource and its proof that every allocation goes to it --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index ab1d78f4..3716e190 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit ab1d78f48fd571c1ab48116d64b9cbb66dc57193 +Subproject commit 3716e1908e2cea6951fa6bdde994766f503f5db7 From d12ae5a2aeddd259179735df9f6ff6283b1fbf67 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 12:29:42 -0300 Subject: [PATCH 04/25] libs/crypto: the memory option's test support documented, sized from 3.5.9's counts, and clean on Linux's clang-tidy --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 3716e190..15a7aafb 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 3716e1908e2cea6951fa6bdde994766f503f5db7 +Subproject commit 15a7aafb46c7d676e4f4ef1f24f7f3fa863c20e8 From 3ba98e443c110c81179afaa79a1eac2eb2f8b322 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 13:05:09 -0300 Subject: [PATCH 05/25] libs/crypto: the memory option's late, foreign, forgotten, replaced and failing installs --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 15a7aafb..74ae2da4 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 15a7aafb46c7d676e4f4ef1f24f7f3fa863c20e8 +Subproject commit 74ae2da4954eac5602c2592ed81868c93e0f5aad From c2a71646a961cc4469b39f61940de68346dc0c7f Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 13:59:58 -0300 Subject: [PATCH 06/25] libs/crypto: the memory option's install tests check their messages unconditionally, and fail_init pins OpenSSL 3.5.9's dead queue and unfreed blocks --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 74ae2da4..d20ce8dd 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 74ae2da4954eac5602c2592ed81868c93e0f5aad +Subproject commit d20ce8ddfdb0580f8f30bcd7f528761088d6be16 From ec11e187338050ece080b6fd555fee4eaded02f3 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 14:17:58 -0300 Subject: [PATCH 07/25] tools: crypto's fixtures of the memory option's link errors --- .../memory_missing_definition_install/Jamfile | 15 +++++++++++ .../memory_missing_definition_install/app.cpp | 14 ++++++++++ .../memory_missing_definition_install.outcome | 18 +++++++++++++ .../memory_missing_definition_make/Jamfile | 15 +++++++++++ .../memory_missing_definition_make/app.cpp | 23 ++++++++++++++++ .../memory_missing_definition_make.outcome | 18 +++++++++++++ .../crypto_jamfiles/memory_two_files/Jamfile | 14 ++++++++++ .../crypto_jamfiles/memory_two_files/main.cpp | 23 ++++++++++++++++ .../memory_two_files/memory_two_files.outcome | 12 +++++++++ .../crypto_jamfiles/memory_two_files/with.cpp | 26 +++++++++++++++++++ 10 files changed, 178 insertions(+) create mode 100644 tools/test/fixtures/crypto_jamfiles/memory_missing_definition_install/Jamfile create mode 100644 tools/test/fixtures/crypto_jamfiles/memory_missing_definition_install/app.cpp create mode 100644 tools/test/fixtures/crypto_jamfiles/memory_missing_definition_install/memory_missing_definition_install.outcome create mode 100644 tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/Jamfile create mode 100644 tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/app.cpp create mode 100644 tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/memory_missing_definition_make.outcome create mode 100644 tools/test/fixtures/crypto_jamfiles/memory_two_files/Jamfile create mode 100644 tools/test/fixtures/crypto_jamfiles/memory_two_files/main.cpp create mode 100644 tools/test/fixtures/crypto_jamfiles/memory_two_files/memory_two_files.outcome create mode 100644 tools/test/fixtures/crypto_jamfiles/memory_two_files/with.cpp diff --git a/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_install/Jamfile b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_install/Jamfile new file mode 100644 index 00000000..1695cf50 --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_install/Jamfile @@ -0,0 +1,15 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# The memory option given as spec section 7.3 says, in the requirements of the +# program's project with OpenSSL beside it, and openssl_memory_resource() not +# defined. +# tag::jamfile[] +project app + : requirements WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE /webcpp/crypto//openssl ; + +exe app : app.cpp /webcpp/crypto//crypto ; +# end::jamfile[] diff --git a/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_install/app.cpp b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_install/app.cpp new file mode 100644 index 00000000..b263040d --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_install/app.cpp @@ -0,0 +1,14 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Sets the memory option and installs OpenSSL's memory functions, but defines no +// webcpp::crypto::openssl_memory_resource(): the install odr-uses the adapter, which calls it, +// so the link fails naming the function (spec section 3.7). +#include + +int main() { + return webcpp::crypto::backends::openssl::install_memory_functions() ? 0 : 1; +} diff --git a/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_install/memory_missing_definition_install.outcome b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_install/memory_missing_definition_install.outcome new file mode 100644 index 00000000..efb4e054 --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_install/memory_missing_definition_install.outcome @@ -0,0 +1,18 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# The lines of each linker, measured on 2026-11-17: ld64 (Apple clang 21), GNU ld 2.44 (gcc +# 15.3, Debian 13). MSVC's link.exe is test/msvc/memory_missing_definition_*'s case. +[all] +targets: native +build: fails +# tag::messages[] +[native-darwin] +contains: Undefined symbols for architecture +contains: "webcpp::crypto::openssl_memory_resource()", referenced from: +[native-linux] +contains: undefined reference to `webcpp::crypto::openssl_memory_resource()' +# end::messages[] diff --git a/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/Jamfile b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/Jamfile new file mode 100644 index 00000000..1695cf50 --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/Jamfile @@ -0,0 +1,15 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# The memory option given as spec section 7.3 says, in the requirements of the +# program's project with OpenSSL beside it, and openssl_memory_resource() not +# defined. +# tag::jamfile[] +project app + : requirements WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE /webcpp/crypto//openssl ; + +exe app : app.cpp /webcpp/crypto//crypto ; +# end::jamfile[] 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 new file mode 100644 index 00000000..ab78b653 --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/app.cpp @@ -0,0 +1,23 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// 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 +// adapter's address, which odr-uses the adapter, so the link fails naming the function (spec +// section 3.7). +#include +#include +#include + +#include +#include + +int main() { + std::array const key{}; + auto const aead = webcpp::crypto::ciphers::gcm< + webcpp::crypto::ciphers::aes256>::make(key); + return aead ? 0 : 1; +} diff --git a/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/memory_missing_definition_make.outcome b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/memory_missing_definition_make.outcome new file mode 100644 index 00000000..efb4e054 --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/memory_missing_definition_make/memory_missing_definition_make.outcome @@ -0,0 +1,18 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# The lines of each linker, measured on 2026-11-17: ld64 (Apple clang 21), GNU ld 2.44 (gcc +# 15.3, Debian 13). MSVC's link.exe is test/msvc/memory_missing_definition_*'s case. +[all] +targets: native +build: fails +# tag::messages[] +[native-darwin] +contains: Undefined symbols for architecture +contains: "webcpp::crypto::openssl_memory_resource()", referenced from: +[native-linux] +contains: undefined reference to `webcpp::crypto::openssl_memory_resource()' +# end::messages[] diff --git a/tools/test/fixtures/crypto_jamfiles/memory_two_files/Jamfile b/tools/test/fixtures/crypto_jamfiles/memory_two_files/Jamfile new file mode 100644 index 00000000..638717d1 --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/memory_two_files/Jamfile @@ -0,0 +1,14 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# Two files of one program, one compiled with the memory option and one without, as a +# project that gives the define to one target alone builds them. +# tag::jamfile[] +obj with : with.cpp /webcpp/crypto//crypto /webcpp/crypto//openssl + : WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE ; + +exe app : main.cpp with /webcpp/crypto//crypto /webcpp/crypto//openssl ; +# end::jamfile[] diff --git a/tools/test/fixtures/crypto_jamfiles/memory_two_files/main.cpp b/tools/test/fixtures/crypto_jamfiles/memory_two_files/main.cpp new file mode 100644 index 00000000..5596f026 --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/memory_two_files/main.cpp @@ -0,0 +1,23 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// The 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. +#include +#include +#include + +#include +#include + +bool make_with_the_option(); + +int main() { + std::array const key{}; + auto const aead = webcpp::crypto::ciphers::gcm< + webcpp::crypto::ciphers::aes256>::make(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 new file mode 100644 index 00000000..85037855 --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/memory_two_files/memory_two_files.outcome @@ -0,0 +1,12 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# 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 +# (backends/openssl.hpp's #pragma detect_mismatch), libs/crypto/test/msvc/memory_two_files. +[all] +targets: native +build: succeeds diff --git a/tools/test/fixtures/crypto_jamfiles/memory_two_files/with.cpp b/tools/test/fixtures/crypto_jamfiles/memory_two_files/with.cpp new file mode 100644 index 00000000..da1df856 --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/memory_two_files/with.cpp @@ -0,0 +1,26 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// The file of memory_two_files compiled with the memory option: it defines the program's +// resource, and makes AES-256-GCM on OpenSSL under the option. +#include +#include +#include + +#include +#include +#include + +std::pmr::memory_resource& webcpp::crypto::openssl_memory_resource() noexcept { + return *std::pmr::new_delete_resource(); +} + +bool make_with_the_option() { + std::array const key{}; + return webcpp::crypto::ciphers::gcm< + webcpp::crypto::ciphers::aes256>::make(key) + .has_value(); +} From ed3a60bbeec9271ee476a0525f2d9cd4ba7e9b36 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 14:17:58 -0300 Subject: [PATCH 08/25] libs/crypto: the memory option's link cases on MSVC, and beside the option --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index d20ce8dd..7ec7fde9 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit d20ce8ddfdb0580f8f30bcd7f528761088d6be16 +Subproject commit 7ec7fde9d68c8380f2cdae1c93dec721c16e9700 From 0548362c29429811f2639effe4dc071b1a99a9b8 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 14:52:05 -0300 Subject: [PATCH 09/25] libs/crypto: the memory option beside Asio's TLS, libdatachannel and a TLS 1.3 handshake --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 7ec7fde9..136f12bb 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 7ec7fde9d68c8380f2cdae1c93dec721c16e9700 +Subproject commit 136f12bb9ac67bee2d41abc15d2c6603f0aa91df From 4b288514b9a82c051561e35d86960f53152e9963 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 16:05:46 -0300 Subject: [PATCH 10/25] libs/crypto: the memory option's neighbours test records which of libdatachannel's static initialisers it links --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 136f12bb..de1f9915 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 136f12bb9ac67bee2d41abc15d2c6603f0aa91df +Subproject commit de1f991511825386a8208084aae8e85bdde47af1 From 8988a7aea100c24f3a55d0bb4ef0bc3780780876 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 17:19:05 -0300 Subject: [PATCH 11/25] tools: crypto's fixture of the memory option's working Jamfile --- .../crypto_jamfiles/memory_option/Jamfile | 15 ++++++ .../crypto_jamfiles/memory_option/app.cpp | 49 +++++++++++++++++++ .../memory_option/memory_option.outcome | 13 +++++ 3 files changed, 77 insertions(+) create mode 100644 tools/test/fixtures/crypto_jamfiles/memory_option/Jamfile create mode 100644 tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp create mode 100644 tools/test/fixtures/crypto_jamfiles/memory_option/memory_option.outcome diff --git a/tools/test/fixtures/crypto_jamfiles/memory_option/Jamfile b/tools/test/fixtures/crypto_jamfiles/memory_option/Jamfile new file mode 100644 index 00000000..a84b041d --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/memory_option/Jamfile @@ -0,0 +1,15 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# The memory option as spec section 7.3 gives it: the define and OpenSSL in the +# requirements of the program's project, so that every target of the program +# gets both. +# tag::jamfile[] +project app + : requirements WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE /webcpp/crypto//openssl ; + +exe app : app.cpp /webcpp/crypto//crypto ; +# end::jamfile[] diff --git a/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp b/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp new file mode 100644 index 00000000..dbedb9d8 --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp @@ -0,0 +1,49 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// 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. +#include +#include + +#include +#include +#include +#include + +// Declared by crypto under WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE, defined once here. Never +// destroyed: OpenSSL frees through it after main returns. +std::pmr::memory_resource& webcpp::crypto::openssl_memory_resource() noexcept { + // Never deleted, on purpose; a new that fails this early ends the program, which has no + // resource for OpenSSL. + // NOLINTNEXTLINE(cppcoreguidelines-owning-memory,bugprone-unhandled-exception-at-new) + static auto* const resource = new std::pmr::synchronized_pool_resource; + return *resource; +} + +int main() { + auto const installed = webcpp::crypto::backends::openssl::install_memory_functions(); + if (!installed) { + std::printf("install: %s\n", installed.error().message().c_str()); + return 1; + } + std::array const key{}; + std::array const iv{}; + std::array data{}; + auto aead = webcpp::crypto::ciphers::aes256_gcm::make(key); + if (!aead) { + std::printf("make: %s\n", aead.error().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 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()); + return ok ? 0 : 1; +} diff --git a/tools/test/fixtures/crypto_jamfiles/memory_option/memory_option.outcome b/tools/test/fixtures/crypto_jamfiles/memory_option/memory_option.outcome new file mode 100644 index 00000000..3d2bc54c --- /dev/null +++ b/tools/test/fixtures/crypto_jamfiles/memory_option/memory_option.outcome @@ -0,0 +1,13 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +[all] +targets: native +build: succeeds +run: app +# tag::output[] +aes256_gcm ok backend=openssl +# end::output[] From 36f75f496fbf9a916d43780e3aac896937977f46 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 17:19:05 -0300 Subject: [PATCH 12/25] libs/crypto: the memory option's page, example and tables --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index de1f9915..a3f35313 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit de1f991511825386a8208084aae8e85bdde47af1 +Subproject commit a3f3531386c60a4d3fa9865272d3c202bded2442 From c860c7901dd78536927ffdba386b85d50c98eef2 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 18:50:59 -0300 Subject: [PATCH 13/25] libs/crypto: the memory option's changelog line, guide condition, example tags and use-case Jamfile --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index a3f35313..d4f404a3 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit a3f3531386c60a4d3fa9865272d3c202bded2442 +Subproject commit d4f404a3f3306ce11bc37d18f985c4185f4eea82 From 2bea5a0f5655e6e2fc1398047ee8b5d2e0376beb Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 18:53:35 -0300 Subject: [PATCH 14/25] guidelines: crypto's memory option, built Chapter 15's crypto entry gains OpenSSL's memory option as stream M built it: native only and refused on every WebAssembly target, the defaults told by their three addresses, its tests and fixtures; the allocation rule states the option and the error values 13 and 14 are the option's. Chapter 17's block leaves and chapter 16's crypto line drops it. Chapter 19 records that a libcrypto DLL is refused where the specification has a Windows branch. --- CODING-GUIDELINES.md | 179 ++++++++++++++++++++++++++----------------- 1 file changed, 109 insertions(+), 70 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 43264225..ca17142b 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -6921,8 +6921,9 @@ cryptography over widely used C libraries that webcpp builds from their sources: AES-GCM and the AES block cipher, a `random_device` on the system's generator, a constant-time `equal`, and secp256k1's BIP340 Schnorr and ECDSA signatures, ECDH, strict DER and the x-only tweak. Version 0.1 is the -proposal's increments 1 and 2, as the owner set them on 2026-11-14; what is -decided and not built is in chapter 17. +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.** @@ -7097,9 +7098,9 @@ decided and not built is in chapter 17. **Errors and exceptions.** - **Every operation that can fail returns `boost::system::result` or - `result`; the category `webcpp.crypto` declares the values 1 to 12, - fixed and never reused, and 13 and 14 are reserved for OpenSSL's memory - option.** The owner's rule that every library works with exceptions on and + `result`; the category `webcpp.crypto` declares the values 1 to 14, + fixed and never reused; 13 and 14, reserved in 0.1, are OpenSSL's memory + option's.** The owner's rule that every library works with exceptions on and off; a value once given is never given again. Source: `include/webcpp/crypto/error.hpp` (libs/crypto); a ruling of the plan's revision of 2026-11-14 (proposals, `reference/plan.md`). @@ -7208,16 +7209,100 @@ decided and not built is in chapter 17. the user gives; no seal, open, `encrypt`, `fill`, signature, `ecdh` or verification allocates on any backend; OpenSSL's `make` allocates its context through OpenSSL's own allocator, which its page states and - `allocation_openssl` counts.** The owner's allocators decision, with - OpenSSL's departure accepted on 2026-10-11 until its memory option. + `allocation_openssl` counts, unless the program takes OpenSSL's memory + option (below), which sends every allocation of OpenSSL's to the program's + resource, natively.** The owner's allocators decision, with OpenSSL's + departure accepted on 2026-10-11; the option serves a program that wants + OpenSSL's allocations in its own resource. Source: `libraries/crypto/openspec/changes/genesis/design.md` D17 - (proposals); `test/support/counting.hpp` (libs/crypto). + (proposals); `test/support/counting.hpp`, `test/openssl_memory/Jamfile` + (libs/crypto). - **Key schedules inside webcpp's objects are wiped on destruction and on move by stores through a `volatile` pointer followed by `std::atomic_signal_fence(std::memory_order_seq_cst)`.** The optimiser cannot drop these stores, where it can drop a `memset`. Source: `include/webcpp/crypto/detail/wipe.hpp` (libs/crypto). +**OpenSSL's memory option (built after 0.1.0; plan Tasks 15, 16 and 33).** + +- **`WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE` sends every allocation of + OpenSSL in the process to a `std::pmr::memory_resource`; the program gives + it with `/webcpp/crypto//openssl` in its project's requirements, + and `config.hpp` refuses it with an `#error` on every WebAssembly target, + Emscripten, wasip2 and wasip3, and without OpenSSL linked.** The owner's + decision of 2026-10-11 made `CRYPTO_set_mem_functions` an option of the + config, so that a program that wants OpenSSL's allocations in its own + allocator can say so; the library beside the define keeps every target that + gets it linked with OpenSSL. The owner's decision of 2026-11-17 made it + native only: on WebAssembly a program's default backend is BearSSL, which + allocates nothing, and the option's tests are native designs. + Source: `include/webcpp/crypto/config.hpp`, `doc/memory.adoc` + (libs/crypto); `libraries/crypto/openspec/changes/genesis/reference/spec.md` + section 3.7 and `design.md` D16 (proposals). +- **Under the option the program defines + `webcpp::crypto::openssl_memory_resource()` once, a `noexcept` function that + returns a `std::pmr::memory_resource&`, and calls + `backends::openssl::install_memory_functions()` as the first statement of + `main`; webcpp never installs from a static initialiser.** OpenSSL's hook + carries no user data, so any other form would keep the resource in a global + variable of webcpp's, which the rulebook forbids; static initialisation + order is unspecified and cannot return an error. + Source: `include/webcpp/crypto/backends/openssl.hpp`, + `example/openssl_memory.cpp` (libs/crypto). +- **The program's resource is never destroyed, is thread-safe wherever + OpenSSL may run on two threads, and is reached without an exception; the + example makes it with `new` and never deletes it.** OpenSSL frees through it + after `main`. + Source: `example/openssl_memory.cpp` (libs/crypto). +- **`install_memory_functions()` only reads OpenSSL's state until its guards + pass: webcpp's adapter already in place is a success that changes nothing, + 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 + 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 + outside the resource. The defaults are told by their three addresses alone, + so a libcrypto DLL, which webcpp never builds, is refused (chapter 19). + Source: `include/webcpp/crypto/backends/openssl.hpp` (libs/crypto). +- **The adapter is three `extern "C"`, `inline`, `noexcept` functions of + external linkage, each block headed by its size and aligned to the larger + of `alignof(std::max_align_t)` and `__STDCPP_DEFAULT_NEW_ALIGNMENT__`; with + exceptions each call into the resource sits in a `try` whose `catch (...)` + returns null.** OpenSSL calls them as C functions and frees without a size; + no exception may cross OpenSSL. + Source: `include/webcpp/crypto/backends/openssl.hpp` (libs/crypto). +- **On MSVC `backends/openssl.hpp` carries + `#pragma detect_mismatch("webcpp_crypto_openssl_memory", ...)`, `"resource"` + with the option and `"openssl"` without it.** Two files of one program + compiled one with the option and one without then fail with LNK2038. + Source: `include/webcpp/crypto/backends/openssl.hpp`, + `test/msvc/memory_two_files` (libs/crypto). +- **Two allocations stay outside the resource, the C library's `FILE` while + OpenSSL reads its configuration file and OpenSSL's secure heap; a resource + that fails during the first `make` leaves OpenSSL unusable for the rest of + the process; the program's code that uses the backend lives in one module; + the page states each.** No hook of OpenSSL's reaches the first two; OpenSSL + keeps a failed initialisation; a second module has its own copy of the + adapter, whose address the guard does not recognise. + Source: `doc/memory.adoc` (libs/crypto). +- **The option's programs are native, in `test/openssl_memory`, each declared + with exceptions and without by the rule `memory-run`: `adapter`; + `everything`, `late`, `foreign`, `fresh_install`, `forgotten`, `replaced`, + `second_install`, `fail_second`, `fail_init` and `handshake`, which count + 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_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 + included; a forgotten definition fails the link, and the project's form the + page shows is built and run. + Source: `test/openssl_memory/Jamfile` (libs/crypto); + `tools/test/fixtures/crypto_jamfiles/` (webcpp). + **Build.** - **BearSSL, libsecp256k1 and ctaes are pinned submodules under @@ -8382,10 +8467,10 @@ What webcpp does not have yet, and the chapters that mention it: webcpp::asio (chapter 15's trystero entry). Authenticated encryption and randomness are webcpp::crypto's, and the relays' WebSockets Beast's. Trystero can then retain its protocol over those shared facilities. -- **crypto after 0.1** (chapter 17): OpenSSL's memory option, constant time - checked, sizes and throughput measured, the browser lane, the CI's nightly - level, NIST CAVP's vectors, ChaCha20-Poly1305, Botan, and trystero's code on - the library (its sealers, its random and its signer). +- **crypto after 0.1** (chapter 17): constant time checked, sizes and + throughput measured, the browser lane, the CI's nightly level, NIST CAVP's + vectors, ChaCha20-Poly1305, Botan, and trystero's code on the library (its + sealers, its random and its signer). - **The libraries web developers use most,** brought to C++: a JavaScript interpreter (QuickJS), libp2p, HTTP fetch. - **The site, increments 2 to 8.** Increment 1 is done: the site's @@ -8446,66 +8531,12 @@ each with its decisions as decided. While a proposal is open, its own change that builds it moves its decisions into chapter 14 or 15. Their conflicts with chapters 1 to 13 are in chapter 19. -### crypto, after 0.1 (accepted 2026-10-11; increments 1 and 2 built in 0.1.0, chapter 15) +### crypto, after 0.1 (accepted 2026-10-11; increments 1 and 2 built in 0.1.0, and the memory option after it, chapter 15) The plan (`reference/plan.md`, revised on 2026-11-14) built version 0.1 from -its increments 1 and 2; the owner deferred the rest, kept as written and -re-read before it runs. What 0.1 built is in chapter 15; what follows is -decided and not built. - -**OpenSSL's memory option (plan Tasks 15, 16 and 33).** - -- **`WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE` sends every allocation of - OpenSSL in the process to a `std::pmr::memory_resource`; the program gives - it with `/webcpp/crypto//openssl` in its project's requirements, and - `config.hpp` refuses it on Emscripten and without OpenSSL linked.** The - owner's decision of 2026-10-11 made `CRYPTO_set_mem_functions` an option of - the config, so that a program that wants OpenSSL's allocations in its own - allocator can say so; the library beside the define keeps every target that - gets it linked with OpenSSL. - Source: `libraries/crypto/openspec/changes/genesis/reference/spec.md` - section 3.7 (proposals). -- **Under the option the program defines - `webcpp::crypto::openssl_memory_resource()` once, a `noexcept` function that - returns a `std::pmr::memory_resource&`, and calls - `backends::openssl::install_memory_functions()` as the first statement of - `main`; webcpp never installs from a static initialiser.** OpenSSL's hook - carries no user data, so any other form would keep the resource in a global - variable of webcpp's, which the rulebook forbids; static initialisation - order is unspecified and cannot return an error. - Source: `libraries/crypto/openspec/changes/genesis/design.md` D16 - (proposals). -- **The program's resource is never destroyed, is thread-safe wherever - OpenSSL may run on two threads, and is reached without an exception.** - OpenSSL frees through it after `main`. - Source: `libraries/crypto/openspec/changes/genesis/design.md` D16 - (proposals). -- **`install_memory_functions()` only reads OpenSSL's state until its guards - pass: webcpp's adapter already in place is a success that changes nothing, - another party's functions 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 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 outside the resource. - The two values are 13 and 14, reserved in 0.1. - Source: `libraries/crypto/openspec/changes/genesis/reference/spec.md` - sections 2.9 and 3.7 (proposals). -- **The adapter is three `extern "C"`, `inline`, `noexcept` functions of - external linkage, each block headed by its size and aligned to the larger - of `alignof(std::max_align_t)` and `__STDCPP_DEFAULT_NEW_ALIGNMENT__`; with - exceptions each call into the resource sits in a `try` whose `catch (...)` - returns null.** OpenSSL calls them as C functions and frees without a size; - no exception may cross OpenSSL. - Source: `libraries/crypto/openspec/changes/genesis/reference/spec.md` - section 3.7 (proposals). -- **On MSVC `backends/openssl.hpp` carries - `#pragma detect_mismatch("webcpp_crypto_openssl_memory", ...)`, `"resource"` - with the option and `"openssl"` without it.** Two files of one program - compiled one with the option and one without then fail with LNK2038. - Source: `libraries/crypto/openspec/changes/genesis/reference/spec.md` - section 3.7 (proposals). +its increments 1 and 2, and OpenSSL's memory option after it; the owner +deferred the rest, kept as written and re-read before it runs. What is built +is in chapter 15; what follows is decided and not built. **Constant time (plan Task 20).** @@ -9727,6 +9758,14 @@ says what the tree does. unsupported policy's inline namespace, since they honoured every setting; the tree puts them inside it, since natively the policy decides a data channel's `max_packet_life_time` of 0 (webrtc `871a4ef`). +- **crypto.** The genesis specification's section 3.7 and its plan's Task + 15 give OpenSSL's memory option a Windows branch that tells a libcrypto + DLL's default functions by `GetModuleHandleExW` and `GetProcAddress`, and + Task 16 measures the MSVC shared link. The tree compares the three + addresses alone: webcpp builds OpenSSL static only, so the branch could + never run in a test, and a libcrypto DLL (a program built without b2) is + refused with `memory_functions_refused`, which the page says. Serving such + a program takes the plan's branch back, never measured. - **asio.** The 2026-11-03 amendment reconciles default turn limit 100, supported targets, source-built TLS, private configuration/allocation fixes and guide order. Proposal source snapshots must name the final committed From 0736b3405f73d597fdeedc9391fa25d4dfefb721 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 20:06:56 -0300 Subject: [PATCH 15/25] libs/crypto: the memory option's changelog line names openssl_memory_resource, and generate_test's docstring keeps to 100 columns --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index d4f404a3..6540ae25 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit d4f404a3f3306ce11bc37d18f985c4185f4eea82 +Subproject commit 6540ae25fec9b58e89fcd6f1207a300af4ef58a9 From 6f17a954a4748f71ad6eedd3f873f8f0765fd6cf Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 20:06:56 -0300 Subject: [PATCH 16/25] guidelines: crypto's chapter 17 heading names the memory option as built after 0.1 --- CODING-GUIDELINES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index ca17142b..7f8ac59b 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -8531,7 +8531,7 @@ each with its decisions as decided. While a proposal is open, its own change that builds it moves its decisions into chapter 14 or 15. Their conflicts with chapters 1 to 13 are in chapter 19. -### crypto, after 0.1 (accepted 2026-10-11; increments 1 and 2 built in 0.1.0, and the memory option after it, chapter 15) +### crypto, after 0.1 (accepted 2026-10-11; increments 1 and 2 built in 0.1.0 and the memory option built after 0.1, chapter 15) The plan (`reference/plan.md`, revised on 2026-11-14) built version 0.1 from its increments 1 and 2, and OpenSSL's memory option after it; the owner From e438f710f76cf3a9cb5689b854e0d1efd9af45e8 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 20:07:03 -0300 Subject: [PATCH 17/25] guidelines: crypto's later work no longer moves trystero onto the library The owner dropped plan Tasks 31 and 32 on 2026-11-17: chapter 16's crypto line drops trystero's code on the library, and chapter 17's block "trystero's migration (increment 3)" leaves. --- CODING-GUIDELINES.md | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 7f8ac59b..2fb68e22 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -8469,8 +8469,7 @@ What webcpp does not have yet, and the chapters that mention it: Trystero can then retain its protocol over those shared facilities. - **crypto after 0.1** (chapter 17): constant time checked, sizes and throughput measured, the browser lane, the CI's nightly level, NIST CAVP's - vectors, ChaCha20-Poly1305, Botan, and trystero's code on the library (its - sealers, its random and its signer). + vectors, ChaCha20-Poly1305 and Botan. - **The libraries web developers use most,** brought to C++: a JavaScript interpreter (QuickJS), libp2p, HTTP fetch. - **The site, increments 2 to 8.** Increment 1 is done: the site's @@ -8632,18 +8631,6 @@ is in chapter 15; what follows is decided and not built. Source: `libraries/crypto/openspec/changes/genesis/reference/spec.md` section 3.6, and `design.md` D9 and D17 (proposals). -**trystero's migration (increment 3).** - -- **trystero moves onto the library: `ciphers::aes256_gcm` with its 16-byte - IVs replaces its native and browser sealers, `random_device::fill` its - `random`, `curves::secp256k1::keypair` its signer, and its direct use of - OpenSSL goes.** 0.1 built only its build's half: trystero links - `/third_party//secp256k1`, its code unchanged. Errors are values, so a - system without entropy fails the operation that needed the bytes with - `entropy_unavailable` where trystero aborts today. - Source: `libraries/crypto/openspec/changes/genesis/design.md` Migration - Plan (proposals). - **Open questions for the owner.** - Gate O2: the nightly level, built by Task 25b. From ee7fa4013d952e4a42ec3594519672aa5616429f Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 22:23:09 -0300 Subject: [PATCH 18/25] tools: the memory option's fixture binds the error's message before printing it, with no fluent chain --- tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp b/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp index dbedb9d8..c97c87ed 100644 --- a/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp @@ -15,6 +15,7 @@ #include #include #include +#include // Declared by crypto under WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE, defined once here. Never // destroyed: OpenSSL frees through it after main returns. @@ -29,7 +30,8 @@ std::pmr::memory_resource& webcpp::crypto::openssl_memory_resource() noexcept { int main() { auto const installed = webcpp::crypto::backends::openssl::install_memory_functions(); if (!installed) { - std::printf("install: %s\n", installed.error().message().c_str()); + std::string const message = installed.error().message(); + std::printf("install: %s\n", message.c_str()); return 1; } std::array const key{}; @@ -37,7 +39,8 @@ int main() { std::array data{}; auto aead = webcpp::crypto::ciphers::aes256_gcm::make(key); if (!aead) { - std::printf("make: %s\n", aead.error().message().c_str()); + std::string const message = aead.error().message(); + std::printf("make: %s\n", message.c_str()); return 1; } auto const tag = aead->seal(iv, {}, data); From aa19ed62c0950d9374f3536617fd0ecf8bc8c4a5 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 22:23:09 -0300 Subject: [PATCH 19/25] tools: the memory_two_files fixture keeps its Jam comment to 80 columns --- tools/test/fixtures/crypto_jamfiles/memory_two_files/Jamfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/test/fixtures/crypto_jamfiles/memory_two_files/Jamfile b/tools/test/fixtures/crypto_jamfiles/memory_two_files/Jamfile index 638717d1..e6872eec 100644 --- a/tools/test/fixtures/crypto_jamfiles/memory_two_files/Jamfile +++ b/tools/test/fixtures/crypto_jamfiles/memory_two_files/Jamfile @@ -4,8 +4,8 @@ # accompanying file LICENSE_1_0.txt or copy at # https://www.boost.org/LICENSE_1_0.txt) -# Two files of one program, one compiled with the memory option and one without, as a -# project that gives the define to one target alone builds them. +# Two files of one program, one compiled with the memory option and one without, +# as a project that gives the define to one target alone builds them. # tag::jamfile[] obj with : with.cpp /webcpp/crypto//crypto /webcpp/crypto//openssl : WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE ; From 0e559a7a4053997c78730750bf15780723ced7cd Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 22:23:09 -0300 Subject: [PATCH 20/25] libs/crypto: the memory option's lint fixes ([[nodiscard]], no fluent chain, Jam comment width) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 6540ae25..6e10da6c 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 6540ae25fec9b58e89fcd6f1207a300af4ef58a9 +Subproject commit 6e10da6cbf687e52e04c2cb523533dc8668568dc From 846bea2d2ab9150661a87bf17266066872246e2c Mon Sep 17 00:00:00 2001 From: R Date: Tue, 17 Nov 2026 23:03:17 -0300 Subject: [PATCH 21/25] tools: the 0.1.0 release notes write libc++ as inline code, which doc-check requires --- doc/releases/0.1.0.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/releases/0.1.0.adoc b/doc/releases/0.1.0.adoc index 008e4dda..219ef1d6 100644 --- a/doc/releases/0.1.0.adoc +++ b/doc/releases/0.1.0.adoc @@ -67,7 +67,7 @@ None. == Tools and build * Fixed emscripten release programs linking unoptimized; they now link at `-O3`. -* Fixed WASI release programs carrying wasi-sdk's libc++ debug information, most of their size; they now link with `--strip-debug`. +* Fixed WASI release programs carrying wasi-sdk's `libc++` debug information, most of their size; they now link with `--strip-debug`. * Fixed clean CMake consumer audits rejecting system libraries and phony dependency rules. * Changed CI to consume verified prepared environments without rebuilding images in PR jobs. * Added verified archive caches and isolated container availability from unrelated CI lanes. From c1a75fcbfaad10f6f275d94fe797edc774eae20d Mon Sep 17 00:00:00 2001 From: R Date: Wed, 18 Nov 2026 04:52:51 -0300 Subject: [PATCH 22/25] libs/crypto: the memory option's second thread calls OPENSSL_thread_stop for Windows --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 6e10da6c..98497729 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 6e10da6cbf687e52e04c2cb523533dc8668568dc +Subproject commit 98497729392c08cbe5ec92823f20b9ed8a900109 From dd782b55397c426f463b3d3a7a3237998b00a3e2 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 18 Nov 2026 05:03:46 -0300 Subject: [PATCH 23/25] guidelines: crypto's memory option rules state the unrecoverable failure on a threaded OpenSSL, OPENSSL_thread_stop on Windows and fail_init_threads --- CODING-GUIDELINES.md | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 2fb68e22..9df9d776 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7280,17 +7280,26 @@ and not built is in chapter 17. Source: `include/webcpp/crypto/backends/openssl.hpp`, `test/msvc/memory_two_files` (libs/crypto). - **Two allocations stay outside the resource, the C library's `FILE` while - OpenSSL reads its configuration file and OpenSSL's secure heap; a resource - that fails during the first `make` leaves OpenSSL unusable for the rest of - the process; the program's code that uses the backend lives in one module; - the page states each.** No hook of OpenSSL's reaches the first two; OpenSSL - keeps a failed initialisation; a second module has its own copy of the - adapter, whose address the guard does not recognise. - Source: `doc/memory.adoc` (libs/crypto). + OpenSSL reads its configuration file and OpenSSL's secure heap; the + resource must serve OpenSSL's initialisation: one that fails there leaves + OpenSSL unusable for the rest of the process on an OpenSSL built without + threads, and on one built with threads (MSVC's only build) the call never + returns; on Windows a thread that used OpenSSL calls + `OPENSSL_thread_stop()` before it ends, or its blocks stay in the resource; + the program's code that uses the backend lives in one module; the page + states each.** No hook of OpenSSL's reaches the first two; OpenSSL keeps a + failed initialisation, and with threads reports the failure through an + error queue that needs the initialisation running, which it re-enters; the + static libcrypto on Windows is never told that a thread ends; a second + module has its own copy of the adapter, whose address the guard does not + recognise. + Source: `doc/memory.adoc`, `example/openssl_memory.cpp`, + `test/openssl_memory/fail_init_test.cpp` (libs/crypto). - **The option's programs are native, in `test/openssl_memory`, each declared with exceptions and without by the rule `memory-run`: `adapter`; `everything`, `late`, `foreign`, `fresh_install`, `forgotten`, `replaced`, - `second_install`, `fail_second`, `fail_init` and `handshake`, which count + `second_install`, `fail_second`, `fail_init`, `fail_init_threads` (the + same program on an OpenSSL built with threads) and `handshake`, which count 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`, From 35dd7edc33bfe31b28f8eea2429aeb22acc7d0b2 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 18 Nov 2026 05:03:46 -0300 Subject: [PATCH 24/25] libs/crypto: the memory option's final fixes (fail_init by OPENSSL_THREADS, the Windows thread cost, the page's and Doc Comments' precision) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 98497729..07b8b711 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 98497729392c08cbe5ec92823f20b9ed8a900109 +Subproject commit 07b8b711f84101a68084a2c1f9ddff1c8daac779 From 653dbd107dad76a5b5c2064c44fe87c7e148b0cb Mon Sep 17 00:00:00 2001 From: R Date: Wed, 18 Nov 2026 10:35:25 -0300 Subject: [PATCH 25/25] libs/crypto: the memory option's closing touch (base initialisation wording, OPENSSL_thread_stop on every path of the example) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 07b8b711..cc2b8010 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 07b8b711f84101a68084a2c1f9ddff1c8daac779 +Subproject commit cc2b80105ddad2849eb85a94817d92043cc5243f