Repository navigation
perf(aes-gcm): run aws-lc's eight-way AES-192-GCM on aarch64 with SHA3 - #460
Merged
Merged
Conversation
Quest-Claim: 0f262f02a54fc184
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ch64 Valgrind hides SHA3, so ctgrind never reached the eight-way kernels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 7, 2026 08:01
|
Your OpenCode Go account is out of credit. Top it up, then re-trigger Pullfrog. OpenCode Go's response
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 10 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.

Problem
s2n-bignum's stitched aarch64 AES-GCM kernels take only 128- and 256-bit keys, so AES-192-GCM ran AES-CTR and GHASH in separate passes past
short's lengths. From 1200 B up, that took 1.04-1.09x aws-lc-rs's time on Neoverse N2 and 1.35-1.68x on Apple M2.Approach
admin/import-aws-lcimports aws-lc'saesv8_gcm_8x_enc_192andaesv8_gcm_8x_dec_192(fromaesv8-gcm-armv8-unroll8.pl) as naked functions, in both the linux and Apple flavors. The importer now strips"openssl/arm_arch.h"too and defines__ARM_MAX_ARCH__=8, which that source guards on. Every other import regenerates byte for byte, also in theregenerateshell.low::aarch64::aes_gcm::cipherruns them for AES-192 wheneverPmullTable::eight_way(SHA3, forEOR3) is set, as the 128/256 kernels pick their eight-way variants. They take the same round keys (13), the same 12-entry H table, and the same Xi and counter layout as the s2n-bignum kernels, so no new key or table state is needed. Without SHA3, AES-192 keeps the composed path.#[target_feature]on stable, so the wrapper starts with.arch_extension aes. The extension only adds to what the assembler accepts afterwards.kernels_match_composedgains a 400 B AAD, so the kernels also see one to a few blocks.aes192-gcmbench rows gainrind-dit-held, as the other AES-GCM groups have.admin/ct-qemugains--target aarch64-unknown-linux-gnu: qemu-aarch64-cpu max, the A64hint #82/#83marks, 64-bit trace records, and address randomization off. Act-qemu-aarch64dev shell and anaarch64-qemujob in the nightlyctgrind.yml, onubuntu-24.04-arm, run it. A newct_qemu_aes_gcmtest asserts the eight-way path and traces key and table setup, seal, open, and a non-96-bit IV for every key size, at lengths through the short path and the kernels' loop and tails. The armv7 marks module (low/arm/ct_qemu.rs) is shared with aarch64.Measurements
rind's time over aws-lc-rs's, interleaved A/B in one job per host (base =
main, head = this branch), from 1200 B up. Both sides time the same bench rows.At 16 KB on Apple, both libraries run the same aws-lc routine and measure 1.00-1.03x. What remains without the DIT hold is the per-call DIT toggle (about 45 ns on M4).
benchmarks/gaps.tomlalready records that gap for AES-128/256-GCM on kixtop (decided from moq-dev/rind#387). At 32 B nothing changed (shortstill runs).AES-128 and AES-256 stay on s2n-bignum. The latest kixtop report (
benchmarks/data/kixtop.json) puts them at 1.01-1.03x aws-lc-rs at 16 KB, per-call DIT included, so aws-lc doesn't beat the verified kernels by ~10%.Validation
cargo test --releaseforaes_gcmunit tests, Wycheprooftest_aes_gcm, and the aws-lc-rs crosschecks (aes_gcm,aes_gcm_any_iv,aes_gcm_every_length, which runs AES-192 in place at every length to 527 B). All pass.just ciandjust checkpass locally; the linux flavor assembles foraarch64-unknown-linux-gnu.admin/ctgrind unit --release aes_gcm) passes on GitHub's N2 runner but reaches only the composed fallback, since valgrind reports"sha3": 0to rind.admin/ct-qemu --target aarch64-unknown-linux-gnuon GitHub's arm64 runner (run): both planted leaks are caught, andct_qemu_aes_gcmtraces 81,100 records identically for both seeds. The armv7admin/ct-qemustill passes locally with the new plugin and script.admin/import-aws-lcregenerates every file byte for byte in theregenerateshell.Impact
aarch64-qemujob in the nightly ctgrind workflow. Dev shellct-qemu-aarch64. Theadmin/ct-qemutrace record grows from 8 to 12 bytes.Choices made without asking
aes_gcm_*_kernel. That kernel readsroundsat offset 240, which rind's keys lack, and no runner without SHA3 is available to measure it..arch_extension aesin the naked wrapper, rather than a nightly#[target_feature]on a naked function.admin/ct-qemuon aarch64, which also covers s2n-bignum's eight-way kernels, rather than by reading the routines.Alternatives
shortpath was slower on N2 (1.14-1.32x), per the quest.Follow-ups
Models
Size: M
Implementer: Claude Code, claude-opus-5-5, high effort
Review
Rewritten by
quest reviewafter each round.01a1b4f6-4f9d-78d0-b0b1-13bfa62f8c00, round 2The new QEMU validation closes the constant-time coverage gap, and no remaining defects were identified.rind/src/low/aarch64/aes_gcm.rs:310:[P2] Exercise both SHA3 kernels in a constant-time test;rind/src/low/aarch64/aes_gcm.rs:501 exercises both SHA3-gated AES-192 routines under QEMU in CI; the identical test and harness passed [the verified run](https://github.com/moq-dev/rind/actions/runs/42353088723), detecting both planted leaks and comparing 81,100 matching records.