Skip to content

Benchmarks: RSA key loading from the CRT values (rsa_from_crt) - #1352

Merged
reaperhulk merged 1 commit into
mainfrom
rsa-from-crt-bench
Oct 8, 2026
Merged

reaperhulk merged 1 commit into
mainfrom
rsa-from-crt-bench

Conversation

@alex

@alex alex commented Oct 8, 2026

Copy link
Copy Markdown
Member

From the rustls provider analysis in #991. rustls's verified-garbage provider loads server keys with PrivateKey::from_crt, and the analysis there measured it at 0.14–0.48 of aws-lc-rs's speed. No benchmark covered key loading, so this PR adds one to measure that and the cheaper key check that follows (#1343, then its implementation).

Change

New group rsa_from_crt in bench/benches/primitives/rsa.rs, at 2048, 3072 and 4096 bits. Each iteration loads one key from all of (n, e, d, p, q, dP, dQ, qInv), as from a PKCS #1 RSAPrivateKey:

  • verified-garbage: PrivateKey::from_crt
  • aws-lc-rs: RsaKeyPair::from_components, which checks the key as it loads it
  • OpenSSL: Rsa::from_private_components, which checks nothing

The group is gated like the rest of rsa.rs. It only adds a group to the existing USES = ["rsa"] file, and touches no library code.

Numbers today

Measured locally on a Sapphire Rapids Xeon, VG_CPU_FEATURES=avx,avx2,avx512f,bmi2,adx, with OPENSSL_ia32cap=":~0x200000" (no AVX512_IFMA anywhere). Times are means:

bytes verified-garbage aws-lc-rs OpenSSL (no check)
256 744 µs 148 µs 1.5 µs
384 2.24 ms 259 µs 1.9 µs
512 4.92 ms 511 µs 2.0 µs

from_crt costs about one private-key operation because it checks the key with the operation on 0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PqW9NMssoiBx9i4PpksckL


Generated by Claude Code

verified-garbage's PrivateKey::from_crt next to aws-lc-rs's
RsaKeyPair::from_components, which checks the key, and OpenSSL's
Rsa::from_private_components, which checks nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PqW9NMssoiBx9i4PpksckL
alex pushed a commit that referenced this pull request Oct 8, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PqW9NMssoiBx9i4PpksckL
@reaperhulk
reaperhulk added this pull request to the merge queue Oct 8, 2026
Merged via the queue into main with commit 5b6f791 Oct 8, 2026
39 checks passed
@reaperhulk
reaperhulk deleted the rsa-from-crt-bench branch October 8, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants