Repository navigation
Bench QUIC header protection masks - #3154
Merged
Merged
Conversation
rustls computes a 5-byte header protection mask for every QUIC packet (RFC 9001 §5.4): one AES-ECB block of a 16-byte sample under a key it keeps, or the first five bytes of a fresh ChaCha20 whose counter and nonce are the sample. Nothing benchmarked either shape: AES-ECB's rows expand the key on every call and start at 64 bytes, and ChaCha20's start at 64 bytes and have no aws-lc-rs row. Compare both with aws-lc-rs's aead::quic::HeaderProtectionKey::new_mask and with OpenSSL. 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.
rustls computes a 5-byte header protection mask for every QUIC packet (RFC 9001 §5.4). The rustls provider in #991 does it in one of two ways:
AesEcbit keeps for the life of the keys.ChaCha20whose counter and nonce are the sample, taking the first five bytes of its keystream.Nothing benchmarked either shape. The AES-ECB rows expand the key on every call and start at 64 bytes. The ChaCha20 rows start at 64 bytes and have no aws-lc-rs row, because aws-lc-rs exposes ChaCha20 only through
aead::quic::HeaderProtectionKey.This adds
bench/benches/primitives/quic_hp.rs, with three groups:quic-hp-aes-128,quic-hp-aes-256andquic-hp-chacha20. The id is the sample's 16 bytes. Each compares three implementations:HeaderProtectionKey::new_mask, with the key made once.Crypterfor AES, and a fresh ChaCha20Crypterper mask.The bench file is new and
main.rsgains two lines. It does not touchchacha20.rs, which #3148 extends.On Neoverse N2 (run 39861905763, this branch alone, default features):
quic-hp-aes-128/16quic-hp-aes-256/16quic-hp-chacha20/16Most of the AES time is
AesEcb::cryptzeroing a 2 KB scratch array and then wiping it, on every call. The hardware implementations never touch that scratch. Removing both locally on x86-64 takes the mask from 44 ns to 5 ns, against aws-lc-rs's 9 ns. A follow-up PR will prove what each implementation writes ofscratchand wipe only that.Generated by Claude Code