commit the other half of the AES patch

this creates a feature flag for cramium-soc targets. This
should be unset for builds that don't target cramium-soc,
and this discipline is managed by xtask.
This commit is contained in:
bunnie 2024-05-05 16:20:50 +08:00
parent 70ec91d917
commit 02640db931
2 changed files with 12 additions and 5 deletions

View file

@ -11,5 +11,9 @@ cipher = "0.4.2"
zeroize = { version = "1.6.0", optional = true, default_features = false }
[features]
hazmat = [] # Expose cryptographically hazardous APIs
hazmat = [] # Expose cryptographically hazardous APIs
cramium-soc = []
# Note: this default line should always be empty. If it has the 'cramium-soc' feature
# checkd in, then AES acceleration gets disabled for all targets. This hack only exists
# because in the MPW version of the silicon, HW AES in broken on the RV32.
default = []

View file

@ -25,17 +25,20 @@ pub type Block = GenericArray<u8, U16>;
pub type Block8 = GenericArray<Block, U8>;
// vex patches
#[cfg(target_arch = "riscv32")]
#[cfg(all(target_arch = "riscv32", not(feature = "cramium-soc")))]
mod vex;
// Note that we can't use 'feature' flags (for precursor, renode, hosted) because the AES
// library is patched into functions that are oblivious to these features.
// so this library has to fall back on the legacy method of determining which build target
// is being specified.
#[cfg(all(not(target_arch = "riscv32"), not(target_os = "none"), not(target_os = "xous"),))]
#[cfg(not(all(target_arch = "riscv32", not(feature = "cramium-soc"))))]
pub use soft::Aes128Soft as Aes128;
#[cfg(all(not(target_arch = "riscv32"), not(target_os = "none"), not(target_os = "xous"),))]
#[cfg(not(all(target_arch = "riscv32", not(feature = "cramium-soc"))))]
pub use soft::Aes256Soft as Aes256;
#[cfg(all(target_arch = "riscv32", any(target_os = "none", target_os = "xous"),))]
#[cfg(all(
all(target_arch = "riscv32", not(feature = "cramium-soc")),
any(target_os = "none", target_os = "xous"),
))]
pub use vex::{Aes128, Aes256};
/// Size of an AES block (128-bits; 16-bytes)