Repository navigation
bench: AES-GCM encryption with a reused key - #1406
Merged
Merged
Conversation
The AES-GCM benchmarks set up a key for each message, so they never reach the encryption with the powers of the hash subkey that a key gets after 32 messages, the one a TLS or QUIC connection's key uses. Measure encryption in place and from two pieces (a TLS 1.3 record) with a key reused across messages, at sizes that leave some blocks after the last 16 (600, 1350 and 4000 bytes), next to OpenSSL's context and aws-lc-rs's key, also set up once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FoYWDDEDFq1DFev5X7n2aq
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.
Part of #1228. This PR only adds benchmarks. It changes no library code.
Why
Every AES-GCM benchmark sets up a new key for each message. On x86-64 with AVX-512 and VAES, a key switches to the
_preparedfunctions once it has been used for 32 messages of at least 256 bytes (POWERS_AFTER). Those functions read precomputed powers of the hash subkey. They are what a TLS or QUIC connection's key uses (see the rustls analysis in #991), yet no benchmark reaches them today. Changes to them, such as #1404, therefore show nothing in the Benchmarks check.What
Two new groups, measured at
REUSED_SIZES= 600, 1350 and 4000 bytes. These sizes leave 5, 4 and 10 blocks after the last group of 16, and are above the 32-block short path:aes-128-gcm-encrypt-reused-key:encrypt_in_place.aes-128-gcm-encrypt-two-pieces-reused-key:encryptfrom a TLS 1.3 record's payload and its content-type byte.Each runs next to OpenSSL (one
CipherCtxkeyed once and given a new nonce per message) and aws-lc-rs (oneLessSafeKey). Before the timings, the outputs and tags are checked against OpenSSL's.Results on main
Measured on a VAES/AVX-512 machine (criterion medians):
cargo fmt --check,cargo clippy --all-targets -D warnings(inbench/) andci/check_arch_gates.pypass.🤖 Generated with Claude Code
https://claude.ai/code/session_01FoYWDDEDFq1DFev5X7n2aq
Generated by Claude Code