Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 82 additions & 1 deletion .github/workflows/aes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ defaults:
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Dwarnings"
# NOTE: The mirror number changes with each version so keep these in sync
SDE_FULL_VERSION_MIRROR: "859732"
SDE_FULL_VERSION: "9.58.0-2025-06-16"

# Cancels CI jobs when new commits are pushed to a PR branch
concurrency:
Expand Down Expand Up @@ -102,6 +105,85 @@ jobs:
- run: cargo test --target ${{ matrix.target }} --features hazmat
- run: cargo test --target ${{ matrix.target }} --all-features

# Tests for the VAES AVX backend
vaes256:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
rust: stable
RUSTFLAGS: "-Dwarnings --cfg aes_avx256"
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: ${{ matrix.RUSTFLAGS }}
steps:
- uses: actions/checkout@v4
- name: Install Intel SDE
run: |
curl -JLO "https://downloadmirror.intel.com/${{ env.SDE_FULL_VERSION_MIRROR }}/sde-external-${{ env.SDE_FULL_VERSION }}-lin.tar.xz"
tar xvf sde-external-${{ env.SDE_FULL_VERSION }}-lin.tar.xz -C /opt
echo "/opt/sde-external-${{ env.SDE_FULL_VERSION }}-lin" >> $GITHUB_PATH
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
# NOTE: Write a `.cargo/config.toml` to configure the target for VAES
# NOTE: We use intel-sde as the runner since not all GitHub CI hosts support AVX512
- name: write .cargo/config.toml
shell: bash
run: |
cd ../aes/..
mkdir -p .cargo
echo '[target.${{ matrix.target }}]' > .cargo/config.toml
echo 'runner = "sde64 -future --"' >> .cargo/config.toml
- run: ${{ matrix.deps }}
- run: cargo test --target ${{ matrix.target }}
- run: cargo test --target ${{ matrix.target }} --features hazmat
- run: cargo test --target ${{ matrix.target }} --all-features

# Tests for the VAES AVX512 backend
vaes512:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
rust: stable
RUSTFLAGS: "-Dwarnings --cfg aes_avx512"
- target: x86_64-unknown-linux-gnu
rust: stable
RUSTFLAGS: "-Dwarnings --cfg aes_avx256 --cfg aes_avx512"
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: ${{ matrix.RUSTFLAGS }}
steps:
- uses: actions/checkout@v4
- name: Install Intel SDE
run: |
curl -JLO "https://downloadmirror.intel.com/${{ env.SDE_FULL_VERSION_MIRROR }}/sde-external-${{ env.SDE_FULL_VERSION }}-lin.tar.xz"
tar xvf sde-external-${{ env.SDE_FULL_VERSION }}-lin.tar.xz -C /opt
echo "/opt/sde-external-${{ env.SDE_FULL_VERSION }}-lin" >> $GITHUB_PATH
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
# NOTE: Write a `.cargo/config.toml` to configure the target for VAES
# NOTE: We use intel-sde as the runner since not all GitHub CI hosts support AVX512
- name: write .cargo/config.toml
shell: bash
run: |
cd ../aes/..
mkdir -p .cargo
echo '[target.${{ matrix.target }}]' > .cargo/config.toml
echo 'runner = "sde64 -future --"' >> .cargo/config.toml
- run: ${{ matrix.deps }}
- run: cargo test --target ${{ matrix.target }}
- run: cargo test --target ${{ matrix.target }} --features hazmat
- run: cargo test --target ${{ matrix.target }} --all-features

# Tests for CPU feature autodetection with fallback to portable software implementation
autodetect:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -165,7 +247,6 @@ jobs:
- run: cargo test --target ${{ matrix.target }}
- run: cargo test --target ${{ matrix.target }} --all-features


# Cross-compiled tests
cross:
strategy:
Expand Down
2 changes: 1 addition & 1 deletion aes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ hazmat = [] # Expose cryptographically hazardous APIs

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ["cfg(aes_compact)", "cfg(aes_force_soft)"]
check-cfg = ["cfg(aes_compact)", "cfg(aes_force_soft)", "cfg(aes_avx256)", "cfg(aes_avx512)"]

[package.metadata.docs.rs]
all-features = true
Expand Down
33 changes: 7 additions & 26 deletions aes/src/armv8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ use cipher::{
};
use core::fmt;

pub(crate) mod features {
cpufeatures::new!(features_aes, "aes");
pub(crate) mod aes {
pub use super::features_aes::*;
}
}

impl_backends!(
enc_name = Aes128BackEnc,
dec_name = Aes128BackDec,
Expand Down Expand Up @@ -86,18 +93,6 @@ macro_rules! define_aes_impl {
decrypt: $name_back_dec,
}

impl $name {
#[inline(always)]
pub(crate) fn get_enc_backend(&self) -> &$name_back_enc {
&self.encrypt
}

#[inline(always)]
pub(crate) fn get_dec_backend(&self) -> &$name_back_dec {
&self.decrypt
}
}

impl KeySizeUser for $name {
type KeySize = $key_size;
}
Expand Down Expand Up @@ -182,13 +177,6 @@ macro_rules! define_aes_impl {
backend: $name_back_enc,
}

impl $name_enc {
#[inline(always)]
pub(crate) fn get_enc_backend(&self) -> &$name_back_enc {
&self.backend
}
}

impl KeySizeUser for $name_enc {
type KeySize = $key_size;
}
Expand Down Expand Up @@ -248,13 +236,6 @@ macro_rules! define_aes_impl {
backend: $name_back_dec,
}

impl $name_dec {
#[inline(always)]
pub(crate) fn get_dec_backend(&self) -> &$name_back_dec {
&self.backend
}
}

impl KeySizeUser for $name_dec {
type KeySize = $key_size;
}
Expand Down
Loading