From 370805ec9c84eabc078f65a61f3d77268e47c0b2 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sat, 6 Jan 2024 14:48:37 -0700 Subject: [PATCH] aes: enable ARMv8 backend by default; MSRV 1.72 Removes `cfg(aes_armv8)` and instead enables it by default. This means it "just works" without any additional configuration. The backend is MSRV 1.72, so for consistency's sake bumps the crate's MSRV to 1.72, i.e. the MSRV where it will work consistently on all platforms. We've done varying MSRVs for specific features in the past, but that gets complicated and confusing (e.g. if we were to say the crate's MSRV varies by target). Benchmarks: test aes128_decrypt_block ... bench: 839 ns/iter (+/- 32) = 19528 MB/s test aes128_decrypt_blocks ... bench: 858 ns/iter (+/- 58) = 19095 MB/s test aes128_encrypt_block ... bench: 839 ns/iter (+/- 34) = 19528 MB/s test aes128_encrypt_blocks ... bench: 855 ns/iter (+/- 57) = 19162 MB/s test aes128_new ... bench: 72 ns/iter (+/- 2) test aes192_decrypt_block ... bench: 997 ns/iter (+/- 47) = 16433 MB/s test aes192_decrypt_blocks ... bench: 1,002 ns/iter (+/- 56) = 16351 MB/s test aes192_encrypt_block ... bench: 990 ns/iter (+/- 31) = 16549 MB/s test aes192_encrypt_blocks ... bench: 1,003 ns/iter (+/- 32) = 16334 MB/s test aes192_new ... bench: 68 ns/iter (+/- 2) test aes256_decrypt_block ... bench: 1,163 ns/iter (+/- 34) = 14087 MB/s test aes256_decrypt_blocks ... bench: 1,151 ns/iter (+/- 65) = 14234 MB/s test aes256_encrypt_block ... bench: 1,166 ns/iter (+/- 38) = 14051 MB/s test aes256_encrypt_blocks ... bench: 1,155 ns/iter (+/- 81) = 14185 MB/s test aes256_new ... bench: 91 ns/iter (+/- 4) --- .github/workflows/aes.yml | 24 +++++++++++------------- aes/Cargo.toml | 2 +- aes/README.md | 4 ++-- aes/src/autodetect.rs | 2 +- aes/src/hazmat.rs | 14 +++----------- aes/src/lib.rs | 15 ++++++--------- 6 files changed, 24 insertions(+), 37 deletions(-) diff --git a/.github/workflows/aes.yml b/.github/workflows/aes.yml index a8ab83d8..f9edc7cb 100644 --- a/.github/workflows/aes.yml +++ b/.github/workflows/aes.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: rust: - - 1.65.0 # MSRV + - 1.72.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -73,7 +73,7 @@ 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 @@ -81,7 +81,7 @@ jobs: # 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: @@ -104,7 +104,7 @@ 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 @@ -112,7 +112,7 @@ jobs: # 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: @@ -137,7 +137,7 @@ 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 @@ -145,7 +145,7 @@ jobs: # 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: @@ -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 @@ -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: @@ -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 diff --git a/aes/Cargo.toml b/aes/Cargo.toml index a098bcaa..e872edac 100644 --- a/aes/Cargo.toml +++ b/aes/Cargo.toml @@ -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" diff --git a/aes/README.md b/aes/README.md index 3ca50e73..1783fe1a 100644 --- a/aes/README.md +++ b/aes/README.md @@ -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. @@ -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 diff --git a/aes/src/autodetect.rs b/aes/src/autodetect.rs index ac471fab..d273632e 100644 --- a/aes/src/autodetect.rs +++ b/aes/src/autodetect.rs @@ -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"))] diff --git a/aes/src/hazmat.rs b/aes/src/hazmat.rs index 4776bb4e..3d4def91 100644 --- a/aes/src/hazmat.rs +++ b/aes/src/hazmat.rs @@ -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"); @@ -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() { diff --git a/aes/src/lib.rs b/aes/src/lib.rs index 2b0c0530..f47557dc 100644 --- a/aes/src/lib.rs +++ b/aes/src/lib.rs @@ -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 @@ -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). @@ -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::*; @@ -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;