Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 33 additions & 2 deletions CODING-GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7004,6 +7004,24 @@ and not built is in chapter 17.
contents being read.** Hash2's `digest<N>::operator==` is `memcmp`; a size
is public.
Source: `include/webcpp/crypto/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
`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
constant time on Apple silicon; a program does nothing. The guard's cost is
measured from a release build by `bench/collect.py --timing` and published
beside the throughput, and the constant-time lane sets no DIT of its own: it
measures what a program gets.
Source: `libraries/crypto/openspec/changes/data-independent-timing/design.md`
D1 to D7 (proposals); `include/webcpp/crypto/detail/timing.hpp`,
`test/timing_coverage_<backend>_test.cpp` (libs/crypto).
- **`<windows.h>` is reached only through `detail/windows.hpp`, which defines
`NOMINMAX` and `WIN32_LEAN_AND_MEAN` only when absent and undefines only
what it defined, and every header writes `(max)()`, `(min)()` and
Expand Down Expand Up @@ -7312,8 +7330,20 @@ and not built is in chapter 17.
recognise.
Source: `doc/memory.adoc`, `example/openssl_memory.cpp`,
`test/openssl_memory/fail_init_test.cpp` (libs/crypto).
- **A resource given to crypto fails by throwing, never by returning null:
`allocate` is declared never to return null (`returns_nonnull` in libc++
and libstdc++), so an optimiser removes any check of its result and a null
is written through in a release build; without exceptions a resource that
cannot allocate ends the process, as `std::pmr`'s own resources do.** The
adapter checks no result of `allocate` and turns what a resource throws
into OpenSSL's null only with exceptions.
Source: `doc/memory.adoc`, `include/webcpp/crypto/backends/openssl.hpp`
(libs/crypto).
- **The option's programs are native, in `test/openssl_memory`, each declared
with exceptions and without by the rule `memory-run`: `adapter`;
with exceptions and without by the rule `memory-run`, except `fail_second`
and `fail_init`, which run with exceptions only, since a resource that cannot
allocate ends the process without them and OpenSSL sees no failure:
`adapter`;
`everything`, `late`, `foreign`, `fresh_install`, `forgotten`, `replaced`,
`second_install`, `fail_second`, `fail_init`, `fail_init_threads` (the
same program on an OpenSSL built with threads) and `handshake`, which count
Expand Down Expand Up @@ -8616,7 +8646,8 @@ increments 1 and 2, whose state is first.
wasmtime's code. The cause is measured: Apple silicon's DIT (data-independent
timing), which wasmtime does not set; with DIT set in wasmtime's main thread,
an experiment and not the lane, the case reads |t| 1.5 to 2.1. The native
dudect programs set DIT themselves; the WebAssembly cannot. The page's
dudect programs no longer set DIT: the library sets it in each call on
64-bit ARM (chapter 15); the WebAssembly cannot set it. The page's
constant-time table and `crypto.json` record it as an open finding, not a
pass, and the lane prints its value without judging it. Valgrind,
MemorySanitizer and dudect are not run on wasip3 or Emscripten, which the
Expand Down
2 changes: 1 addition & 1 deletion libs/crypto
Submodule crypto updated 58 files
+8 −2 AGENTS.md
+16 −5 bench/Jamfile
+334 −19 bench/collect.py
+226 −0 bench/timing.cpp
+53 −16 doc/backends.adoc
+1 −1 doc/changelog.adoc
+2 −2 doc/generated/constant-time.adoc
+5 −5 doc/generated/namespace-ciphers.adoc
+4 −4 doc/generated/namespace-curves.adoc
+1 −1 doc/llms.txt
+12 −4 doc/memory.adoc
+231 −182 doc/performance.adoc
+515 −480 doc/performance.json
+1 −1 doc/tables/crypto.json
+9 −10 doc/x25519.adoc
+21 −11 include/webcpp/crypto/backends/openssl.hpp
+4 −0 include/webcpp/crypto/ciphers/aead.hpp
+6 −0 include/webcpp/crypto/ciphers/aes.hpp
+9 −0 include/webcpp/crypto/ciphers/gcm.hpp
+12 −0 include/webcpp/crypto/curves/ed25519.hpp
+3 −0 include/webcpp/crypto/curves/ed25519/formats.hpp
+24 −0 include/webcpp/crypto/curves/secp256k1.hpp
+5 −0 include/webcpp/crypto/curves/secp256k1/ellswift.hpp
+5 −0 include/webcpp/crypto/curves/secp256k1/formats.hpp
+18 −0 include/webcpp/crypto/curves/secp256k1/musig.hpp
+6 −0 include/webcpp/crypto/curves/secp256k1/silent_payments.hpp
+8 −0 include/webcpp/crypto/curves/secp256k1/tweak.hpp
+5 −0 include/webcpp/crypto/curves/x25519.hpp
+3 −0 include/webcpp/crypto/curves/x25519/formats.hpp
+5 −0 include/webcpp/crypto/curves/x25519/kx.hpp
+189 −0 include/webcpp/crypto/detail/timing.hpp
+6 −1 include/webcpp/crypto/equal.hpp
+4 −0 include/webcpp/crypto/hybrid/box.hpp
+3 −0 include/webcpp/crypto/hybrid/sealed_box.hpp
+5 −0 include/webcpp/crypto/pem.hpp
+34 −2 test/Jamfile
+7 −5 test/constant_time/Jamfile
+28 −103 test/constant_time/dudect.hpp
+1 −1 test/constant_time/dudect_secp256k1_test.cpp
+6 −2 test/constant_time/dudect_sodium_test.cpp
+1 −1 test/constant_time/dudect_test.cpp
+9 −3 test/openssl_memory/Jamfile
+29 −13 test/openssl_memory/adapter_test.cpp
+12 −7 test/openssl_memory/support.hpp
+6 −2 test/secp256k1_allocation_test.cpp
+23 −12 test/support/aead_checks.hpp
+270 −0 test/support/timing_coverage.hpp
+284 −0 test/support/timing_seam.hpp
+53 −0 test/timing_coverage_bearssl_test.cpp
+44 −0 test/timing_coverage_ctaes_test.cpp
+57 −0 test/timing_coverage_openssl_test.cpp
+923 −0 test/timing_coverage_secp256k1_test.cpp
+499 −0 test/timing_coverage_sodium_test.cpp
+124 −0 test/timing_mock_test.cpp
+90 −0 test/timing_sodium_test.cpp
+236 −0 test/timing_test.cpp
+137 −0 test/timing_unseamed_test.cpp
+12 −4 test/wipe_objects_test.cpp
Loading
Loading