Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1ca0890
tools: crypto's fixture of the memory option on Emscripten
Nov 17, 2026
ac6469c
libs/crypto: OpenSSL's memory functions as an option of the config (e…
Nov 17, 2026
df87921
libs/crypto: the memory option's counting resource and its proof that…
Nov 17, 2026
d12ae5a
libs/crypto: the memory option's test support documented, sized from …
Nov 17, 2026
3ba98e4
libs/crypto: the memory option's late, foreign, forgotten, replaced a…
Nov 17, 2026
c2a7164
libs/crypto: the memory option's install tests check their messages u…
Nov 17, 2026
ec11e18
tools: crypto's fixtures of the memory option's link errors
Nov 17, 2026
ed3a60b
libs/crypto: the memory option's link cases on MSVC, and <windows.h> …
Nov 17, 2026
0548362
libs/crypto: the memory option beside Asio's TLS, libdatachannel and …
Nov 17, 2026
4b28851
libs/crypto: the memory option's neighbours test records which of lib…
Nov 17, 2026
8988a7a
tools: crypto's fixture of the memory option's working Jamfile
Nov 17, 2026
36f75f4
libs/crypto: the memory option's page, example and tables
Nov 17, 2026
c860c79
libs/crypto: the memory option's changelog line, guide condition, exa…
Nov 17, 2026
2bea5a0
guidelines: crypto's memory option, built
Nov 17, 2026
0736b34
libs/crypto: the memory option's changelog line names openssl_memory_…
Nov 17, 2026
6f17a95
guidelines: crypto's chapter 17 heading names the memory option as bu…
Nov 17, 2026
e438f71
guidelines: crypto's later work no longer moves trystero onto the lib…
Nov 17, 2026
ee7fa40
tools: the memory option's fixture binds the error's message before p…
Nov 18, 2026
aa19ed6
tools: the memory_two_files fixture keeps its Jam comment to 80 columns
Nov 18, 2026
0e559a7
libs/crypto: the memory option's lint fixes ([[nodiscard]], no fluent…
Nov 18, 2026
846bea2
tools: the 0.1.0 release notes write libc++ as inline code, which doc…
Nov 18, 2026
c1a75fc
libs/crypto: the memory option's second thread calls OPENSSL_thread_s…
Nov 18, 2026
dd782b5
guidelines: crypto's memory option rules state the unrecoverable fail…
Nov 18, 2026
35dd7ed
libs/crypto: the memory option's final fixes (fail_init by OPENSSL_TH…
Nov 18, 2026
653dbd1
libs/crypto: the memory option's closing touch (base initialisation w…
Nov 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 117 additions & 82 deletions CODING-GUIDELINES.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/releases/0.1.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion libs/crypto
Submodule crypto updated 59 files
+2 −2 doc/changelog.adoc
+9 −2 doc/errors.adoc
+1 −1 doc/generated/backend-facts.adoc
+20 −0 doc/generated/backends-memory_option.adoc
+16 −0 doc/generated/jamfiles.adoc
+11 −0 doc/generated/matrix.adoc
+87 −0 doc/generated/messages.adoc
+7 −2 doc/generated/namespace-root.adoc
+6 −0 doc/generated/use-cases.adoc
+26 −0 doc/jamfile.adoc
+5 −0 doc/llms.txt
+141 −1 doc/memory.adoc
+4 −1 doc/root.adoc
+28 −3 doc/tables/crypto.json
+49 −12 doc/tables/generate.py
+83 −6 doc/tables/generate_test.py
+10 −0 example/Jamfile
+82 −0 example/openssl_memory.cpp
+1 −0 example/openssl_memory.expected
+225 −1 include/webcpp/crypto/backends/openssl.hpp
+20 −1 include/webcpp/crypto/config.hpp
+22 −2 include/webcpp/crypto/error.hpp
+1 −0 test/Jamfile
+15 −5 test/error_test.cpp
+2 −0 test/messages/Jamfile
+12 −0 test/messages/openssl_memory_not_linked/Jamfile
+17 −0 test/messages/openssl_memory_not_linked/openssl_memory_not_linked.cpp
+15 −0 test/messages/openssl_memory_on_webassembly/Jamfile
+17 −0 test/messages/openssl_memory_on_webassembly/openssl_memory_on_webassembly.cpp
+4 −0 test/msvc/Jamfile
+12 −0 test/msvc/memory_missing_definition_install/Jamfile
+15 −0 test/msvc/memory_missing_definition_install/app.cpp
+12 −0 test/msvc/memory_missing_definition_make/Jamfile
+23 −0 test/msvc/memory_missing_definition_make/app.cpp
+11 −0 test/msvc/memory_two_files/Jamfile
+25 −0 test/msvc/memory_two_files/main.cpp
+29 −0 test/msvc/memory_two_files/with.cpp
+11 −0 test/msvc/openssl_memory_not_linked/Jamfile
+14 −0 test/msvc/openssl_memory_not_linked/app.cpp
+74 −0 test/openssl_memory/Jamfile
+141 −0 test/openssl_memory/adapter_test.cpp
+103 −0 test/openssl_memory/everything_test.cpp
+97 −0 test/openssl_memory/fail_init_test.cpp
+79 −0 test/openssl_memory/fail_second_test.cpp
+33 −0 test/openssl_memory/foreign_test.cpp
+58 −0 test/openssl_memory/forgotten_test.cpp
+24 −0 test/openssl_memory/fresh_install_test.cpp
+217 −0 test/openssl_memory/handshake_test.cpp
+11 −0 test/openssl_memory/header_alone_test.cpp
+54 −0 test/openssl_memory/interpose_darwin.cpp
+88 −0 test/openssl_memory/interpose_linux.cpp
+19 −0 test/openssl_memory/interpose_windows.cpp
+37 −0 test/openssl_memory/late_test.cpp
+84 −0 test/openssl_memory/neighbours_test.cpp
+52 −0 test/openssl_memory/replaced_test.cpp
+23 −0 test/openssl_memory/second_install_test.cpp
+331 −0 test/openssl_memory/support.hpp
+10 −0 test/windows_h_after_test.cpp
+10 −0 test/windows_h_before_test.cpp
Original file line number Diff line number Diff line change
@@ -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 <define>WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE <library>/webcpp/crypto//openssl ;

exe app : app.cpp /webcpp/crypto//crypto ;
# end::jamfile[]
Original file line number Diff line number Diff line change
@@ -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 <webcpp/crypto/backends/openssl.hpp>

int main() {
return webcpp::crypto::backends::openssl::install_memory_functions() ? 0 : 1;
}
Original file line number Diff line number Diff line change
@@ -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[]
Original file line number Diff line number Diff line change
@@ -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 <define>WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE <library>/webcpp/crypto//openssl ;

exe app : app.cpp /webcpp/crypto//crypto ;
# end::jamfile[]
Original file line number Diff line number Diff line change
@@ -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 <webcpp/crypto/backends/openssl.hpp>
#include <webcpp/crypto/ciphers/aes.hpp>
#include <webcpp/crypto/ciphers/gcm.hpp>

#include <array>
#include <cstdint>

int main() {
std::array<std::uint8_t, 32> const key{};
auto const aead = webcpp::crypto::ciphers::gcm<
webcpp::crypto::ciphers::aes256<webcpp::crypto::backends::openssl>>::make(key);
return aead ? 0 : 1;
}
Original file line number Diff line number Diff line change
@@ -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[]
15 changes: 15 additions & 0 deletions tools/test/fixtures/crypto_jamfiles/memory_option/Jamfile
Original file line number Diff line number Diff line change
@@ -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 <define>WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE <library>/webcpp/crypto//openssl ;

exe app : app.cpp /webcpp/crypto//crypto ;
# end::jamfile[]
52 changes: 52 additions & 0 deletions tools/test/fixtures/crypto_jamfiles/memory_option/app.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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 <webcpp/crypto/backends/openssl.hpp>
#include <webcpp/crypto/ciphers/aes256_gcm.hpp>

#include <array>
#include <cstdint>
#include <cstdio>
#include <memory_resource>
#include <string>

// 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::string const message = installed.error().message();
std::printf("install: %s\n", message.c_str());
return 1;
}
std::array<std::uint8_t, 32> const key{};
std::array<std::uint8_t, 12> const iv{};
std::array<std::uint8_t, 16> data{};
auto aead = webcpp::crypto::ciphers::aes256_gcm::make(key);
if (!aead) {
std::string const message = aead.error().message();
std::printf("make: %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<std::uint8_t, 16>{};
auto const name = webcpp::crypto::ciphers::aes256_gcm::backend_type::name;
std::printf("aes256_gcm %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast<int>(name.size()),
name.data());
return ok ? 0 : 1;
}
Original file line number Diff line number Diff line change
@@ -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[]
14 changes: 14 additions & 0 deletions tools/test/fixtures/crypto_jamfiles/memory_two_files/Jamfile
Original file line number Diff line number Diff line change
@@ -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
: <define>WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE ;

exe app : main.cpp with /webcpp/crypto//crypto /webcpp/crypto//openssl ;
# end::jamfile[]
23 changes: 23 additions & 0 deletions tools/test/fixtures/crypto_jamfiles/memory_two_files/main.cpp
Original file line number Diff line number Diff line change
@@ -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 <webcpp/crypto/backends/openssl.hpp>
#include <webcpp/crypto/ciphers/aes.hpp>
#include <webcpp/crypto/ciphers/gcm.hpp>

#include <array>
#include <cstdint>

bool make_with_the_option();

int main() {
std::array<std::uint8_t, 32> const key{};
auto const aead = webcpp::crypto::ciphers::gcm<
webcpp::crypto::ciphers::aes256<webcpp::crypto::backends::openssl>>::make(key);
return aead && make_with_the_option() ? 0 : 1;
}
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions tools/test/fixtures/crypto_jamfiles/memory_two_files/with.cpp
Original file line number Diff line number Diff line change
@@ -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 <webcpp/crypto/backends/openssl.hpp>
#include <webcpp/crypto/ciphers/aes.hpp>
#include <webcpp/crypto/ciphers/gcm.hpp>

#include <array>
#include <cstdint>
#include <memory_resource>

std::pmr::memory_resource& webcpp::crypto::openssl_memory_resource() noexcept {
return *std::pmr::new_delete_resource();
}

bool make_with_the_option() {
std::array<std::uint8_t, 32> const key{};
return webcpp::crypto::ciphers::gcm<
webcpp::crypto::ciphers::aes256<webcpp::crypto::backends::openssl>>::make(key)
.has_value();
}
Original file line number Diff line number Diff line change
@@ -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 : <define>WEBCPP_CRYPTO_OPENSSL_MEMORY_RESOURCE ;
# end::jamfile[]
Original file line number Diff line number Diff line change
@@ -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 <webcpp/crypto/config.hpp>

int main() {}
Original file line number Diff line number Diff line change
@@ -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[]
Loading