This is a pure-Rust platform-agnostic AES library, that is focused on reusability and optimal performance.
This library guarantees the best performance on the target_cpu (if correctly specified). This currently has 6
implementations, among which it automatically decides the best (most performant) using Cargo's target_feature flags.
The implementations and their requirements are:
- AES-NI (with Vector AES for 2- and 4- blocks) => requires a Nightly Compiler, the
nightlyfeature to be enabled, and compiling for x86(64) with theavx512fandvaestarget_feature flags set. - AES-NI (with Vector AES for 2-blocks) => requires a Nightly Compiler, the
nightlyfeature to be enabled, and compiling for x86(64) with thevaestarget_feature flag set. (althoughvaesis an AVX-512 feature, some AlderLake CPUs havevaeswithout AVX-512 support) - AES-NI => requires compiling for x86(64) with the
sse4.1andaestarget_feature flags set. - AES-Neon => requires compiling for AArch64 or ARM64EC or ARM-v8 with the
aestarget_feature flag set (ARM-v8 requires a Nightly compiler and thenightlyfeature to be enabled) . - AES-RV => Requires a Nightly compiler, the
nightlyfeature to be enabled and compiling for RISC-V RV64 or RV32 with thezkneandzkndtarget-features enabled (performance considerably improves with theunaligned-scalar-memtarget-feature enabled) - Software AES => fallback implementation based on Rijmen and Daemen's
optimizedimplementation (available on their website)
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.
Warning
Using the wrong target_feature flags may lead to the binary crashing due to an "Unknown Instruction" error. This
library uses these flags to use the CPU intrinsics to maximize performance. If you are unsure what target_features are
supported on your CPU, use the command
Using the nightly feature when not using a nightly compiler can lead to compile failures, so use this only if you
are using a nightly compiler.