mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
fix AES dependencies so that the correct acceleration is enabled
This relies on a trick I was not aware of previously, which is that transitive dependencies absorb the additive set of features enabled within a crate. see https://doc.rust-lang.org/cargo/reference/features.html#feature-unification for the full description. but basically by referring to the feature required in "aes" despite not being used in the crate but pulled in by aes-gcm-siv, i can ensure that the transitive dependency is in fact used. I think this was always there but previously I just didn't understand it correctly or didn't use it right when I tried to deploy it, but this time I think I got it right.
This commit is contained in:
parent
9da1d1e17e
commit
75a9373fea
10 changed files with 58 additions and 23 deletions
|
|
@ -18,6 +18,7 @@ utralib = { version = "0.1.25", optional = true, default-features = false }
|
|||
rand_chacha = { version = "0.3.1", optional = true, default-features = false }
|
||||
cramium-hal = { path = "../libs/cramium-hal", optional = true, default-features = false }
|
||||
loader = { path = "../loader", optional = true, features = ["swap"] }
|
||||
aes = { path = "../services/aes", default-features = false, optional = true }
|
||||
|
||||
[target.'cfg(any(windows,unix))'.dev-dependencies]
|
||||
xous-kernel = { package = "xous", version = "0.9.66", features = [
|
||||
|
|
@ -44,8 +45,13 @@ critical-section = "1.1.1"
|
|||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ci)', 'cfg(baremetal)'] }
|
||||
|
||||
[features]
|
||||
vexii-test = [] # integration test for vexii, not a production configuration
|
||||
cramium-soc = ["utralib/cramium-soc", "rand_chacha", "raw-trng"]
|
||||
vexii-test = [] # integration test for vexii, not a production configuration
|
||||
cramium-soc = [
|
||||
"utralib/cramium-soc",
|
||||
"rand_chacha",
|
||||
"raw-trng",
|
||||
"aes/cramium-soc",
|
||||
]
|
||||
verilator-only = []
|
||||
cramium-fpga = ["utralib/cramium-fpga", "rand_chacha"]
|
||||
board-baosec = ["cramium-hal/kernel-baosec", "memmap-flash", "swap"]
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ xous-pl230 = { path = "../libs/xous-pl230", optional = true, features = [
|
|||
aes-gcm-siv = { version = "0.11.1", default-features = false, features = [
|
||||
"aes",
|
||||
], optional = true }
|
||||
aes = { path = "../services/aes", default-features = false, optional = true }
|
||||
crc = { version = "1.8.1", default-features = false }
|
||||
rand_chacha = { version = "0.3.1", optional = true, default-features = false }
|
||||
pio-proc = { version = "0.2.2", optional = true }
|
||||
|
|
@ -80,6 +81,8 @@ renode = [
|
|||
"sha2-loader",
|
||||
]
|
||||
cramium-soc = [
|
||||
"dep:aes",
|
||||
"aes/cramium-soc",
|
||||
"utralib/cramium-soc",
|
||||
# "cramium-hal/debug-print-usb",
|
||||
"debug-print",
|
||||
|
|
@ -113,7 +116,7 @@ secboot = []
|
|||
#default = ["debug-print"]
|
||||
|
||||
# swap flag
|
||||
swap = ["aes-gcm-siv"]
|
||||
swap = ["dep:aes-gcm-siv"]
|
||||
|
||||
# cramium target flags
|
||||
board-bringup = []
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "aes"
|
||||
version = "0.8.3"
|
||||
version = "0.8.4"
|
||||
authors = ["bunnie <bunnie@kosagi.com>"]
|
||||
edition = "2018"
|
||||
description = "AES library for Xous"
|
||||
|
|
@ -18,7 +18,6 @@ check-cfg = ["cfg(aes_compact)", "cfg(aes_force_soft)"]
|
|||
hazmat = [] # Expose cryptographically hazardous APIs
|
||||
cramium-soc = []
|
||||
vexii-test = []
|
||||
# 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 = ["cramium-soc"]
|
||||
precursor = []
|
||||
renode = []
|
||||
default = []
|
||||
|
|
|
|||
|
|
@ -25,19 +25,32 @@ pub type Block = GenericArray<u8, U16>;
|
|||
pub type Block8 = GenericArray<Block, U8>;
|
||||
|
||||
// vex patches
|
||||
#[cfg(all(target_arch = "riscv32", not(feature = "cramium-soc"), not(feature = "vexii-test")))]
|
||||
#[cfg(all(
|
||||
all(target_arch = "riscv32", not(feature = "cramium-soc"), not(feature = "vexii-test")),
|
||||
any(feature = "precursor", feature = "renode"),
|
||||
))]
|
||||
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(not(any(all(target_arch = "riscv32", feature = "cramium-soc"), feature = "vexii-test")))]
|
||||
#[cfg(not(any(
|
||||
all(target_arch = "riscv32", feature = "cramium-soc"),
|
||||
feature = "vexii-test",
|
||||
feature = "precursor",
|
||||
feature = "renode"
|
||||
)))]
|
||||
pub use soft::Aes128Soft as Aes128;
|
||||
#[cfg(not(any(all(target_arch = "riscv32", feature = "cramium-soc"), feature = "vexii-test")))]
|
||||
#[cfg(not(any(
|
||||
all(target_arch = "riscv32", feature = "cramium-soc"),
|
||||
feature = "vexii-test",
|
||||
feature = "precursor",
|
||||
feature = "renode"
|
||||
)))]
|
||||
pub use soft::Aes256Soft as Aes256;
|
||||
#[cfg(all(
|
||||
all(target_arch = "riscv32", not(feature = "cramium-soc"), not(feature = "vexii-test")),
|
||||
any(target_os = "none", target_os = "xous"),
|
||||
any(feature = "precursor", feature = "renode"),
|
||||
))]
|
||||
pub use vex::{Aes128, Aes256};
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ xous-swapper = { path = "../xous-swapper", optional = true }
|
|||
rand = { version = "0.8.5", features = ["getrandom"], optional = true }
|
||||
rand_chacha = { version = "0.3.1", optional = true }
|
||||
|
||||
aes = { path = "../aes", optional = true }
|
||||
aes = { path = "../aes", default-features = false, optional = true }
|
||||
|
||||
# aes testing
|
||||
[features]
|
||||
|
|
@ -36,6 +36,7 @@ cramium-soc = [
|
|||
"utralib/cramium-soc",
|
||||
"modals/cramium-soc",
|
||||
"usb-cramium/cramium-soc",
|
||||
"aes/cramium-soc",
|
||||
]
|
||||
board-baosec = [
|
||||
"modals/board-baosec",
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ subtle = { version = "2.4.1", default-features = false }
|
|||
#sha2 = {version = "0.9.5", default-features = false, features = []}
|
||||
sha2 = { version = "0.10.8" }
|
||||
digest = "0.10.7"
|
||||
aes = { path = "../aes" }
|
||||
aes = { path = "../aes", default-features = false, optional = true }
|
||||
# engine-25519 = { path = "../engine-25519" }
|
||||
byteorder = "1.4.3" # used by keywrap
|
||||
# hardware acceleration adaptations are inserted into a fork of the main branch.
|
||||
|
|
@ -74,7 +74,7 @@ hkdf = "0.12.4"
|
|||
#features = ["rand_core", "digest"]
|
||||
|
||||
[features]
|
||||
cramium-soc = ["utralib/cramium-soc"]
|
||||
cramium-soc = ["utralib/cramium-soc", "aes/cramium-soc"]
|
||||
board-baosec = [
|
||||
"utralib/cramium-soc",
|
||||
"ux-api/board-baosec",
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ rkyv = { version = "0.8.8", default-features = false, features = [
|
|||
] }
|
||||
trng = { path = "../trng", optional = true }
|
||||
spinor = { path = "../spinor", optional = true }
|
||||
aes = { path = "../aes" }
|
||||
aes = { path = "../aes", default-features = false }
|
||||
root-keys = { path = "../root-keys", optional = true }
|
||||
keystore-api = { path = "../../libs/keystore-api" }
|
||||
cipher = "0.4.2"
|
||||
|
|
@ -91,10 +91,10 @@ gen1 = [
|
|||
]
|
||||
gen2 = ["keystore", "keystore-api/gen2"]
|
||||
# gen 1 targets
|
||||
precursor = ["utralib/precursor", "sha2/precursor", "gen1"]
|
||||
precursor = ["utralib/precursor", "sha2/precursor", "gen1", "aes/precursor"]
|
||||
vexii-test = ["precursor-hal/vexii-test", "aes/vexii-test"]
|
||||
hosted = ["utralib/hosted", "sha2/hosted", "gen1"]
|
||||
renode = ["utralib/renode", "sha2/renode", "gen1"]
|
||||
renode = ["utralib/renode", "sha2/renode", "gen1", "aes/renode"]
|
||||
|
||||
# gen 2 targets
|
||||
board-baosec = [
|
||||
|
|
@ -104,6 +104,7 @@ board-baosec = [
|
|||
"cramium-hal/board-baosec",
|
||||
"modals/board-baosec",
|
||||
"keystore/board-baosec",
|
||||
"aes/cramium-soc",
|
||||
] # USB form factor token
|
||||
hosted-baosec = [
|
||||
"gen2",
|
||||
|
|
@ -117,6 +118,7 @@ board-baosor = [
|
|||
"cram-hal-service/board-baosor",
|
||||
"cramium-hal/board-baosor",
|
||||
"keystore/board-baosor",
|
||||
"aes/cramium-soc",
|
||||
] # Precursor form factor
|
||||
# board-dabao is not a valid target as it lacks external SPI flash
|
||||
|
||||
|
|
|
|||
|
|
@ -87,9 +87,14 @@ features = ["rand_core", "digest"]
|
|||
|
||||
[features]
|
||||
vexii-test = ["aes/vexii-test"]
|
||||
precursor = ["utralib/precursor", "sha2/precursor", "keystore-api/precursor"]
|
||||
precursor = [
|
||||
"utralib/precursor",
|
||||
"sha2/precursor",
|
||||
"keystore-api/precursor",
|
||||
"aes/precursor",
|
||||
]
|
||||
hosted = ["utralib/hosted", "sha2/hosted", "keystore-api/hosted"]
|
||||
renode = ["utralib/renode", "sha2/renode", "keystore-api/renode"]
|
||||
renode = ["utralib/renode", "sha2/renode", "keystore-api/renode", "aes/renode"]
|
||||
policy-menu = [
|
||||
"keystore-api/policy-menu",
|
||||
] # provisions for users to set their password retention policies (on the block for deprecation) (note: to re-enable you need to add "rootkeys menu" to the tokens.rs in the GAM)
|
||||
|
|
|
|||
|
|
@ -123,9 +123,9 @@ features = ["rand_core"]
|
|||
|
||||
[features]
|
||||
vexii-test = ["aes/vexii-test"]
|
||||
precursor = ["utralib/precursor", "sha2/precursor"]
|
||||
precursor = ["utralib/precursor", "sha2/precursor", "aes/precursor"]
|
||||
hosted = ["utralib/hosted", "sha2/hosted", "random-pick"]
|
||||
renode = ["utralib/renode", "sha2/renode"]
|
||||
renode = ["utralib/renode", "sha2/renode", "aes/renode"]
|
||||
debugprint = []
|
||||
spinortest = [
|
||||
] # for spinor testing. contra-indicated with PDDB, as it steals memory from the PDDB.
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ loader = { path = "../../loader", features = ["swap"], optional = true }
|
|||
aes-gcm-siv = { version = "0.11.1", default-features = false, features = [
|
||||
"aes",
|
||||
] }
|
||||
aes = { path = "../aes", default-features = false, optional = true }
|
||||
cramium-hal = { path = "../../libs/cramium-hal", optional = true, default-features = false }
|
||||
precursor-hal = { path = "../../libs/precursor-hal", optional = true, default-features = false }
|
||||
cramium-api = { path = "../../libs/cramium-api", optional = true, default-features = false }
|
||||
|
|
@ -30,7 +31,12 @@ utralib = { version = "0.1.25", optional = true, default-features = false }
|
|||
[target.'cfg(any(windows,unix))'.dependencies]
|
||||
|
||||
[features]
|
||||
cramium-soc = ["utralib/cramium-soc", "loader/cramium-soc", "cramium-api/std"]
|
||||
cramium-soc = [
|
||||
"utralib/cramium-soc",
|
||||
"loader/cramium-soc",
|
||||
"cramium-api/std",
|
||||
"aes/cramium-soc",
|
||||
]
|
||||
cramium-fpga = ["utralib/cramium-fpga"]
|
||||
board-baosec = ["cramium-hal/board-baosec", "cramium-soc"]
|
||||
board-baosor = ["cramium-hal/board-baosor", "cramium-soc"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue