Repository navigation
Conversation
The VAES encrypt/decrypt paths read the `aes` variant of the inner union (the AES-NI round keys) and call the AES-NI single-block routines, but `KeyInit::new` only initializes that variant when the `aes` CPU feature is detected. On a CPU or hypervisor that reports VAES without AES-NI, the cipher was keyed through the soft backend and then encrypted through VAES reading the uninitialized `aes` variant. Require `aes` (and `avx2` for the 256-bit backend, which `vaes` implies as a target feature) in the VAES feature tokens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
|
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.
KeyInit::newinitializes theaes(AES-NI) variant of the inner union only when theaesCPU feature is detected, and thesoftvariant otherwise. The VAES encrypt/decrypt paths are selected by thevaes256/vaes512tokens alone, and they readself.inner.aes.enc_rk/dec_rkand call the AES-NI single-block routines.So on a CPU (or a VM whose hypervisor masks CPUID bits) that reports VAES (and AVX-512 state for the 512-bit path) without AES-NI, the cipher is keyed through the soft backend and then encrypted through VAES reading the uninitialized
aesvariant. The union has norepr, so depending on layout this either runs AES rounds over a soft-schedule-derived key (silently wrong output; the instructions still execute when the CPUID bit is masked) or reads uninitialized memory. Bare-metal CPUs with VAES also have AES-NI, so this matters mainly under virtualization or confidential-computing guests where the host influences CPUID.This makes the VAES tokens also require
aes, plusavx2for the 256-bit backend (vaesimpliesaes,avxandavx2as target features), so the VAES paths can only run when the AES-NI round keys were initialized.Tested:
cargo test -p aes --target x86_64-apple-darwin, clippy (--lib --tests,-D warnings) andcargo check --target x86_64-unknown-linux-gnu. There is no regression test, because the tokens come fromcpufeaturesand can't be forced without a test-only constructor; happy to add one if you'd like that shape. I left the CHANGELOG for the release.🤖 Generated with Claude Code