From 1e8f1e3b54deb4c92a425c4b38699299365946e7 Mon Sep 17 00:00:00 2001 From: sayantn Date: Sat, 21 Dec 2024 23:00:50 +0530 Subject: [PATCH] Disable AES-Neon in big-endian ARM due to rust-lang/stdarch#1484 --- README.md | 12 ++++++------ src/lib.rs | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index db16cc0..3f9d92a 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,16 @@ implementations, among which it automatically decides the best (most performant) - AES-NI (with Vector AES for 2-blocks) => requires a Nightly Compiler, the `nightly` feature to be enabled, and compiling for x86(64) with the `vaes` target_feature flag set. - AES-NI => requires compiling for x86(64) with the `sse4.1` and `aes` target_feature flags set. -- AES-Neon => requires compiling for AArch64 or ARM64EC or ARM-v8 with the `aes` target_feature flag set (ARM-v8 - requires a Nightly compiler and the `nightly` feature to be enabled) . +- AES-Neon => requires compiling for little-endian AArch64 or ARM64EC or ARM-v8 with the `aes` target_feature flag set ( + ARM-v8 requires a Nightly compiler and the `nightly` feature to be enabled). - AES-RV => Requires a Nightly compiler, the `nightly` feature to be enabled and compiling for RISC-V RV64 or RV32 with the `zkne` and `zknd` target-features enabled (performance considerably improves with the `unaligned-scalar-mem` target-feature enabled) - Software AES => fallback implementation based on Rijmen and Daemen's `optimized` implementation (available - on [their website](https://web.archive.org/web/20050828204927/http://www.iaik.tu-graz.ac.at/research/krypto/AES/old/%7Erijmen/rijndael/)) -- Constant-time Software AES => Much slower than Software AES, but is constant-time, which can be important in some scenarios. - Enabled by the `constant-time` feature. It is worth noting that all the accelerated AES implementations are constant-time, so this - only comes into play when no accelerated version is found. + on [their website](https://web.archive.org/web/20050828204927/http://www.iaik.tu-graz.ac.at/research/krypto/AES/old/%7Erijmen/rijndael/)). +- Constant-time Software AES => Much slower than Software AES, but is constant-time, which can be important in some + scenarios. Enabled by the `constant-time` feature. It is worth noting that all the accelerated AES implementations are + constant-time, so this only comes into play when no accelerated version is found. If you are unsure about the target_feature flags to set, use `target_cpu=native` (if not cross-compiling) in the `RUSTFLAGS` environment variable, and use the `nightly` feature only if you are using a nightly compiler. diff --git a/src/lib.rs b/src/lib.rs index eed359c..7eaf1fe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,8 @@ feature = "nightly", target_arch = "arm", target_feature = "v8", - target_feature = "aes" + target_feature = "aes", + target_endian = "little" // https://github.com/rust-lang/stdarch/issues/1484 ), feature(stdarch_arm_neon_intrinsics) )] @@ -55,7 +56,8 @@ cfg_if! { target_arch = "arm64ec", all(feature = "nightly", target_arch = "arm", target_feature = "v8") ), - target_feature = "aes" + target_feature = "aes", + target_endian = "little" // https://github.com/rust-lang/stdarch/issues/1484 ))] { mod aes_arm; pub use aes_arm::AesBlock;