From 25c30f6cdea3f24f0b2c92105ba15e832270f007 Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 21 Nov 2024 01:39:35 +0800 Subject: [PATCH] add bodge to work around HW configuration in patches right now our patch set assumes a single HW configuration for cryptography accelerators. This isn't going to be true going forward. A more scalable approach to patching accelerators is going to be needed. For now, we're just falling back to software acceleration for the cramium target. --- xtask/src/builder.rs | 20 ++++++++++++++++++++ xtask/src/main.rs | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/xtask/src/builder.rs b/xtask/src/builder.rs index 90bca2651..13f1bc2ad 100644 --- a/xtask/src/builder.rs +++ b/xtask/src/builder.rs @@ -332,6 +332,26 @@ impl Builder { self.kernel = CrateSpec::Local("xous-kernel".to_string(), LoaderRegion::Ram); search_and_replace_in_file("services/aes/Cargo.toml", "default = []", "default = [\"cramium-soc\"]") .expect("couldn't patch AES"); + + // this is needed because we don't have an ed25519 accelerator on cramium targets + search_and_replace_in_file( + "Cargo.toml", + "[patch.crates-io.curve25519-dalek]", + "# [patch.crates-io.curve25519-dalek]", + ) + .expect("couldn't patch curve25519"); + search_and_replace_in_file( + "Cargo.toml", + "git = \"https://github.com/betrusted-io/curve25519-dalek.git\"", + "# git = \"https://github.com/betrusted-io/curve25519-dalek.git\"", + ) + .expect("couldn't patch curve25519"); + search_and_replace_in_file( + "Cargo.toml", + "branch = \"main\" # c25519", + "# branch = \"main\" # c25519", + ) + .expect("couldn't patch curve25519"); self } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 2b6c8c7a8..e1ce85181 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -201,6 +201,26 @@ fn main() -> Result<(), Box> { ) .expect("couldn't patch AES"); + // revert these just in case - but don't throw an error if the strings aren't found + builder::search_and_replace_in_file( + "Cargo.toml", + "# [patch.crates-io.curve25519-dalek]", + "[patch.crates-io.curve25519-dalek]", + ) + .ok(); + builder::search_and_replace_in_file( + "Cargo.toml", + "# git = \"https://github.com/betrusted-io/curve25519-dalek.git\"", + "git = \"https://github.com/betrusted-io/curve25519-dalek.git\"", + ) + .ok(); + builder::search_and_replace_in_file( + "Cargo.toml", + "# branch = \"main\" # c25519", + "branch = \"main\" # c25519", + ) + .ok(); + match builder::search_in_file("services/aes/Cargo.toml", "default = []") { Ok(false) => { return Err( @@ -635,6 +655,24 @@ fn main() -> Result<(), Box> { "default = []", ) .expect("couldn't patch AES"); + builder::search_and_replace_in_file( + "Cargo.toml", + "# [patch.crates-io.curve25519-dalek]", + "[patch.crates-io.curve25519-dalek]", + ) + .expect("couldn't patch curve25519"); + builder::search_and_replace_in_file( + "Cargo.toml", + "# git = \"https://github.com/betrusted-io/curve25519-dalek.git\"", + "git = \"https://github.com/betrusted-io/curve25519-dalek.git\"", + ) + .expect("couldn't patch curve25519"); + builder::search_and_replace_in_file( + "Cargo.toml", + "# branch = \"main\" # c25519", + "branch = \"main\" # c25519", + ) + .expect("couldn't patch curve25519"); } match builder::search_in_file("services/aes/Cargo.toml", "default = []") { Ok(false) => {