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.
This commit is contained in:
bunnie 2024-11-21 01:39:35 +08:00
parent ec409fedc0
commit 25c30f6cde
2 changed files with 58 additions and 0 deletions

View file

@ -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
}

View file

@ -201,6 +201,26 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
)
.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<dyn std::error::Error>> {
"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) => {