Skip to content

Commit c545533

Browse files
committed
Revert #482: "aes: implement VAES AVX and AVX512 backends"
This reverts commit ad83428. This implementation uses assembly, but the relevant intrinsics will be stable in Rust 1.89, and we have a PR open to use them: #491 For a cleaner history, this reverts the assembly implementation so the intrinsics-based implementation can be cleanly applied to an ASM-free codebase, rather than as a replacement for the ASM.
1 parent 1f7c695 commit c545533

File tree

23 files changed

+739
-5007
lines changed

23 files changed

+739
-5007
lines changed

.github/workflows/aes.yml

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ defaults:
1616
env:
1717
CARGO_INCREMENTAL: 0
1818
RUSTFLAGS: "-Dwarnings"
19-
SDE_FULL_VERSION: "9.53.0-2025-03-16"
2019

2120
jobs:
2221
# Builds for no_std platforms
@@ -69,7 +68,7 @@ jobs:
6968
env:
7069
CARGO_INCREMENTAL: 0
7170
RUSTDOCFLAGS: "-C target-feature=+aes,+ssse3"
72-
RUSTFLAGS: "-Dwarnings -C target-feature=+aes,+ssse3 --cfg aes_avx512_disable --cfg aes_avx256_disable"
71+
RUSTFLAGS: "-Dwarnings -C target-feature=+aes,+ssse3"
7372
strategy:
7473
matrix:
7574
include:
@@ -98,80 +97,6 @@ jobs:
9897
- run: cargo test --target ${{ matrix.target }} --features hazmat
9998
- run: cargo test --target ${{ matrix.target }} --all-features
10099

101-
# Tests for the VAES AVX backend
102-
vaes256:
103-
runs-on: ubuntu-latest
104-
env:
105-
CARGO_INCREMENTAL: 0
106-
RUSTFLAGS: "-Dwarnings --cfg aes_avx512_disable"
107-
strategy:
108-
matrix:
109-
include:
110-
- target: x86_64-unknown-linux-gnu
111-
rust: 1.89.0-beta.2
112-
steps:
113-
- uses: actions/checkout@v4
114-
- name: Install Intel SDE
115-
run: |
116-
curl -JLO "https://downloadmirror.intel.com/850782/sde-external-${{ env.SDE_FULL_VERSION }}-lin.tar.xz"
117-
tar xvf sde-external-${{ env.SDE_FULL_VERSION }}-lin.tar.xz -C /opt
118-
echo "/opt/sde-external-${{ env.SDE_FULL_VERSION }}-lin" >> $GITHUB_PATH
119-
- uses: RustCrypto/actions/cargo-cache@master
120-
- uses: dtolnay/rust-toolchain@master
121-
with:
122-
toolchain: ${{ matrix.rust }}
123-
targets: ${{ matrix.target }}
124-
# NOTE: Write a `.cargo/config.toml` to configure the target for VAES
125-
# NOTE: We use intel-sde as the runner since not all GitHub CI hosts support AVX512
126-
- name: write .cargo/config.toml
127-
shell: bash
128-
run: |
129-
cd ../aes/..
130-
mkdir -p .cargo
131-
echo '[target.${{ matrix.target }}]' > .cargo/config.toml
132-
echo 'runner = "sde64 -future --"' >> .cargo/config.toml
133-
- run: ${{ matrix.deps }}
134-
- run: cargo test --target ${{ matrix.target }}
135-
- run: cargo test --target ${{ matrix.target }} --features hazmat
136-
- run: cargo test --target ${{ matrix.target }} --all-features
137-
138-
# Tests for the VAES AVX512 backend
139-
vaes512:
140-
runs-on: ubuntu-latest
141-
env:
142-
CARGO_INCREMENTAL: 0
143-
strategy:
144-
matrix:
145-
include:
146-
- target: x86_64-unknown-linux-gnu
147-
rust: 1.89.0-beta.2
148-
steps:
149-
- uses: actions/checkout@v4
150-
- name: Install Intel SDE
151-
run: |
152-
curl -JLO "https://downloadmirror.intel.com/850782/sde-external-${{ env.SDE_FULL_VERSION }}-lin.tar.xz"
153-
tar xvf sde-external-${{ env.SDE_FULL_VERSION }}-lin.tar.xz -C /opt
154-
echo "/opt/sde-external-${{ env.SDE_FULL_VERSION }}-lin" >> $GITHUB_PATH
155-
- uses: RustCrypto/actions/cargo-cache@master
156-
- uses: dtolnay/rust-toolchain@master
157-
with:
158-
toolchain: ${{ matrix.rust }}
159-
targets: ${{ matrix.target }}
160-
# NOTE: Write a `.cargo/config.toml` to configure the target for VAES
161-
# NOTE: We use intel-sde as the runner since not all GitHub CI hosts support AVX512
162-
- name: write .cargo/config.toml
163-
shell: bash
164-
run: |
165-
cd ../aes/..
166-
mkdir -p .cargo
167-
echo '[target.${{ matrix.target }}]' > .cargo/config.toml
168-
echo 'runner = "sde64 -future --"' >> .cargo/config.toml
169-
- run: ${{ matrix.deps }}
170-
- run: cargo test --target ${{ matrix.target }}
171-
- run: cargo test --target ${{ matrix.target }} --features hazmat
172-
- run: cargo test --target ${{ matrix.target }} --all-features
173-
174-
175100
# Tests for CPU feature autodetection with fallback to portable software implementation
176101
autodetect:
177102
runs-on: ubuntu-latest

aes/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ hazmat = [] # Expose cryptographically hazardous APIs
3131

3232
[lints.rust.unexpected_cfgs]
3333
level = "warn"
34-
check-cfg = ["cfg(aes_compact)", "cfg(aes_force_soft)", "cfg(aes_avx256_disable)", "cfg(aes_avx512_disable)"]
34+
check-cfg = ["cfg(aes_compact)", "cfg(aes_force_soft)"]
3535

3636
[package.metadata.docs.rs]
3737
all-features = true

aes/src/armv8.rs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ use cipher::{
2525
};
2626
use core::fmt;
2727

28-
pub(crate) mod features {
29-
cpufeatures::new!(features_aes, "aes");
30-
pub(crate) mod aes {
31-
pub use super::features_aes::*;
32-
}
33-
}
34-
3528
impl_backends!(
3629
enc_name = Aes128BackEnc,
3730
dec_name = Aes128BackDec,
@@ -93,6 +86,18 @@ macro_rules! define_aes_impl {
9386
decrypt: $name_back_dec,
9487
}
9588

89+
impl $name {
90+
#[inline(always)]
91+
pub(crate) fn get_enc_backend(&self) -> &$name_back_enc {
92+
&self.encrypt
93+
}
94+
95+
#[inline(always)]
96+
pub(crate) fn get_dec_backend(&self) -> &$name_back_dec {
97+
&self.decrypt
98+
}
99+
}
100+
96101
impl KeySizeUser for $name {
97102
type KeySize = $key_size;
98103
}
@@ -177,6 +182,13 @@ macro_rules! define_aes_impl {
177182
backend: $name_back_enc,
178183
}
179184

185+
impl $name_enc {
186+
#[inline(always)]
187+
pub(crate) fn get_enc_backend(&self) -> &$name_back_enc {
188+
&self.backend
189+
}
190+
}
191+
180192
impl KeySizeUser for $name_enc {
181193
type KeySize = $key_size;
182194
}
@@ -236,6 +248,13 @@ macro_rules! define_aes_impl {
236248
backend: $name_back_dec,
237249
}
238250

251+
impl $name_dec {
252+
#[inline(always)]
253+
pub(crate) fn get_dec_backend(&self) -> &$name_back_dec {
254+
&self.backend
255+
}
256+
}
257+
239258
impl KeySizeUser for $name_dec {
240259
type KeySize = $key_size;
241260
}

0 commit comments

Comments
 (0)