Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aes: enable ARMv8 backend by default; MSRV 1.72 #395

Merged
merged 1 commit into from
Jan 7, 2024
Merged
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
24 changes: 11 additions & 13 deletions .github/workflows/aes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
matrix:
rust:
- 1.65.0 # MSRV
- 1.72.0 # MSRV
- stable
target:
- thumbv7em-none-eabi
Expand Down Expand Up @@ -73,15 +73,15 @@ jobs:
include:
# 32-bit Linux
- target: i686-unknown-linux-gnu
rust: 1.65.0 # MSRV
rust: 1.72.0 # MSRV
deps: sudo apt update && sudo apt install gcc-multilib
- target: i686-unknown-linux-gnu
rust: stable
deps: sudo apt update && sudo apt install gcc-multilib

# 64-bit Linux
- target: x86_64-unknown-linux-gnu
rust: 1.65.0 # MSRV
rust: 1.72.0 # MSRV
- target: x86_64-unknown-linux-gnu
rust: stable
steps:
Expand All @@ -104,15 +104,15 @@ jobs:
include:
# 32-bit Linux
- target: i686-unknown-linux-gnu
rust: 1.65.0 # MSRV
rust: 1.72.0 # MSRV
deps: sudo apt update && sudo apt install gcc-multilib
- target: i686-unknown-linux-gnu
rust: stable
deps: sudo apt update && sudo apt install gcc-multilib

# 64-bit Linux
- target: x86_64-unknown-linux-gnu
rust: 1.65.0 # MSRV
rust: 1.72.0 # MSRV
- target: x86_64-unknown-linux-gnu
rust: stable
steps:
Expand All @@ -137,15 +137,15 @@ jobs:
include:
# 32-bit Linux
- target: i686-unknown-linux-gnu
rust: 1.65.0 # MSRV
rust: 1.72.0 # MSRV
deps: sudo apt update && sudo apt install gcc-multilib
- target: i686-unknown-linux-gnu
rust: stable
deps: sudo apt update && sudo apt install gcc-multilib

# 64-bit Linux
- target: x86_64-unknown-linux-gnu
rust: 1.65.0 # MSRV
rust: 1.72.0 # MSRV
- target: x86_64-unknown-linux-gnu
rust: stable
steps:
Expand All @@ -167,13 +167,13 @@ jobs:
include:
# ARM64
- target: aarch64-unknown-linux-gnu
rust: 1.65.0 # MSRV
rust: 1.72.0 # MSRV
- target: aarch64-unknown-linux-gnu
rust: stable

# PPC32
- target: powerpc-unknown-linux-gnu
rust: 1.65.0 # MSRV
rust: 1.72.0 # MSRV
- target: powerpc-unknown-linux-gnu
rust: stable
runs-on: ubuntu-latest
Expand Down Expand Up @@ -211,13 +211,11 @@ jobs:

# ARMv8 cross-compiled tests for AES intrinsics
armv8:
env:
RUSTFLAGS: "-Dwarnings --cfg aes_armv8"
strategy:
matrix:
include:
- target: aarch64-unknown-linux-gnu
rust: 1.72.0 # MSRV for `aes_armv8`
rust: 1.72.0 # MSRV
runs-on: ubuntu-latest
# Cross mounts only current package, i.e. by default it ignores workspace's Cargo.toml
defaults:
Expand Down Expand Up @@ -245,6 +243,6 @@ jobs:
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.65.0 # MSRV
toolchain: 1.72.0 # MSRV
components: clippy
- run: cargo clippy --features hazmat -- -D warnings
2 changes: 1 addition & 1 deletion aes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Pure Rust implementation of the Advanced Encryption Standard (a.k
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.65"
rust-version = "1.72"
readme = "README.md"
documentation = "https://docs.rs/aes"
repository = "https://github.com/RustCrypto/block-ciphers"
Expand Down
4 changes: 2 additions & 2 deletions aes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ using a portable implementation based on bitslicing.

## Minimum Supported Rust Version

Rust **1.65** or higher.
Rust **1.72** or higher.

Minimum supported Rust version can be changed in future releases, but it will
be done with a minor version bump.
Expand Down Expand Up @@ -75,7 +75,7 @@ dual licensed as above, without any additional terms or conditions.
[docs-image]: https://docs.rs/aes/badge.svg
[docs-link]: https://docs.rs/aes/
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
[rustc-image]: https://img.shields.io/badge/rustc-1.65+-blue.svg
[rustc-image]: https://img.shields.io/badge/rustc-1.72+-blue.svg
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260039-block-ciphers
[build-image]: https://github.com/RustCrypto/block-ciphers/workflows/aes/badge.svg?branch=master&event=push
Expand Down
2 changes: 1 addition & 1 deletion aes/src/autodetect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use cipher::{
use core::fmt;
use core::mem::ManuallyDrop;

#[cfg(all(target_arch = "aarch64", aes_armv8))]
#[cfg(target_arch = "aarch64")]
use crate::armv8 as intrinsics;

#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
Expand Down
14 changes: 3 additions & 11 deletions aes/src/hazmat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@

use crate::{soft::fixslice::hazmat as soft, Block, Block8};

#[cfg(all(target_arch = "aarch64", aes_armv8, not(aes_force_soft)))]
#[cfg(all(target_arch = "aarch64", not(aes_force_soft)))]
use crate::armv8::hazmat as intrinsics;

#[cfg(all(any(target_arch = "x86_64", target_arch = "x86"), not(aes_force_soft)))]
use crate::ni::hazmat as intrinsics;

#[cfg(all(
any(
target_arch = "x86",
target_arch = "x86_64",
all(target_arch = "aarch64", aes_armv8)
),
any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"),
not(aes_force_soft)
))]
cpufeatures::new!(aes_intrinsics, "aes");
Expand All @@ -34,11 +30,7 @@ cpufeatures::new!(aes_intrinsics, "aes");
macro_rules! if_intrinsics_available {
($body:expr) => {{
#[cfg(all(
any(
target_arch = "x86",
target_arch = "x86_64",
all(target_arch = "aarch64", aes_armv8)
),
any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"),
not(aes_force_soft)
))]
if aes_intrinsics::get() {
Expand Down
15 changes: 6 additions & 9 deletions aes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@
//! ## ARMv8 intrinsics (Rust 1.61+)
//! On `aarch64` targets including `aarch64-apple-darwin` (Apple M1) and Linux
//! targets such as `aarch64-unknown-linux-gnu` and `aarch64-unknown-linux-musl`,
//! support for using AES intrinsics provided by the ARMv8 Cryptography Extensions
//! is available when using Rust 1.61 or above, and can be enabled using the
//! `aes_armv8` configuration flag.
//! support for using AES intrinsics provided by the ARMv8 Cryptography Extensions.
//!
//! On Linux and macOS, when the `aes_armv8` flag is enabled support for AES
//! intrinsics is autodetected at runtime. On other platforms the `aes`
//! target feature must be enabled via RUSTFLAGS.
//! On Linux and macOS, support for ARMv8 AES intrinsics is autodetected at
//! runtime. On other platforms the `aes` target feature must be enabled via
//! RUSTFLAGS.
//!
//! ## `x86`/`x86_64` intrinsics (AES-NI)
//! By default this crate uses runtime detection on `i686`/`x86_64` targets
Expand Down Expand Up @@ -101,7 +99,6 @@
//!
//! You can modify crate using the following configuration flags:
//!
//! - `aes_armv8`: enable ARMv8 AES intrinsics (Rust 1.61+).
//! - `aes_force_soft`: force software implementation.
//! - `aes_compact`: reduce code size at the cost of slower performance
//! (affects only software backend).
Expand Down Expand Up @@ -131,7 +128,7 @@ mod soft;
use cfg_if::cfg_if;

cfg_if! {
if #[cfg(all(target_arch = "aarch64", aes_armv8, not(aes_force_soft)))] {
if #[cfg(all(target_arch = "aarch64", not(aes_force_soft)))] {
mod armv8;
mod autodetect;
pub use autodetect::*;
Expand Down Expand Up @@ -212,7 +209,7 @@ mod tests {
}
}

#[cfg(all(target_arch = "aarch64", aes_armv8, not(aes_force_soft)))]
#[cfg(all(target_arch = "aarch64", not(aes_force_soft)))]
{
use super::armv8;

Expand Down