Repository navigation
secure: constant_time_equal in a register (wasm timing on EPYC 9V74); the page's title fits the site - #3
Merged
Conversation
The site's assembly (tools/ci/assemble.py) refuses a library page whose title, with " - webcpp", is longer than 60 characters, so main's Site job (run 47116123227) never deployed: "secure: side-channel and secret-in-memory primitives for C++ - webcpp" is 69. The heading is now "secure: constant time and secrets in memory for C++" (60 with the suffix); the page's first paragraph keeps the longer description.
pinhopro
force-pushed
the
main-green-2
branch
from
December 3, 2026 19:02
33f7505 to
ef1d259
Compare
…is the asm statement on WebAssembly too crypto's constant-time lane on wasip2 failed on webcpp's main (run 47116123227): constant_time_equal read |t| 89.80, 104.33 and 119.54. A probe on sixteen hosted runners (2026-12-03) built the case as crypto's dudect does, under wasmtime 50.0.1 and natively, in variants. On all four AMD EPYC 9V74 runners and under wasmtime alone, three runs each, it read |t| 70 to 117: - zeros against random bytes (the case): over 10 on all four; - the same with the guard removed: the same; - a pair that differs only in its last byte against a nonzero pair: the same; - an equal random pair against one that differs in its last byte, whose result differs while its values look alike: 1 to 3; - the comparison with its accumulator in a register through an empty asm: 1 to 8. Natively, and on every other runner model (Xeon 6975P-C, 6973P-C, Platinum 8573C, EPYC 7763 and 9V45), every variant read 0 to 4. What leaked was the comparison's volatile accumulator. On wasm it is a store and a load of linear memory at each byte, which wasmtime compiles to the host's, and on that CPU the round trip of a nonzero value took longer than that of zero. The accumulator is now a register, passed through constant_time::value_barrier at each step, so the compiler still cannot know it has settled. On WebAssembly value_barrier is now the empty asm statement it is on GCC and clang: WebAssembly has the statement too (wasi-sdk 34 and Emscripten compile it at every width, as a local). Before, it fell back to the volatile round trip, which MSVC and MemorySanitizer keep. The doc comments and the blocks and guard pages say so. Confirmed on hosted runners, sixteen jobs, five runs of each case: with this change the case read |t| 0.9 to 2.9 under wasmtime on all five AMD EPYC 9V74 runners (25 runs), and 0.3 to 3.7 everywhere else, natively and under wasmtime. The old volatile accumulator, kept in the same probe as a control, still read 52 to 91 on those 9V74 runners under wasmtime.
pinhopro
force-pushed
the
main-green-2
branch
from
December 3, 2026 19:32
ef1d259 to
2db8872
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes for failures on webcpp's main CI (run 47116123227).
1. constant_time_equal leaked on wasip2 on AMD EPYC 9V74.
crypto's constant-time lane on wasip2 read |t| 89.80, 104.33 and 119.54 for
constant_time_equal.Probe: sixteen hosted runners, the case built as crypto's dudect builds it, under wasmtime 50.0.1 and natively, in variants. Only on the 9V74 runners, and only under wasmtime:
Cause: the
volatileaccumulator. On wasm it is a store and a load of linear memory at each byte, which wasmtime compiles to the host's. On that CPU, the round trip of a nonzero value took longer than that of zero.Fix:
constant_time::value_barrierat each step.value_barrieris now the empty asm statement, as on GCC and clang. WebAssembly has that statement: wasi-sdk 34 and Emscripten compile it at every width. Before, it fell back to thevolatileround trip, which MSVC and MemorySanitizer still use.Confirmed: with this change (probed at ef1d259, which differs from the final commit only by clang-format), the case read 0.9 to 2.9 under wasmtime on all five 9V74 runners (25 runs). It read 0.3 to 3.7 everywhere else. The old volatile form, kept in the same probe as a control, still read 52 to 91 there. The threshold is unchanged, and nothing is unjudged.
2. The page's title fits the site's 60 characters.
tools/ci/assemble.pyrefused "secure: side-channel and secret-in-memory primitives for C++ - webcpp" (69 characters), so the site never deployed. The new title is "secure: constant time and secrets in memory for C++" (60 with the suffix). I built the page locally with b2, and assemble.py's title check finds no fault.Verified: secure's tests and examples natively (Apple Clang) and on wasip2 (wasmtime), and the lint.
🤖 Generated with Claude Code