diff --git a/Cargo.lock b/Cargo.lock index 9c9ab5116..08f8cc740 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -501,7 +501,6 @@ dependencies = [ "digest", "engine-25519", "engine25519-as", - "rand 0.7.3", "rand_core 0.5.1", "subtle", "zeroize", @@ -596,6 +595,7 @@ dependencies = [ [[package]] name = "engine25519-as" version = "0.1.0" +source = "git+https://github.com/betrusted-io/engine25519-as.git?rev=6681e73c1fdc4a460b5ef9f9c7c91aef546d00f3#6681e73c1fdc4a460b5ef9f9c7c91aef546d00f3" [[package]] name = "enum_dispatch" diff --git a/Cargo.toml b/Cargo.toml index 639df5193..a518428e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,4 +90,6 @@ lto = "fat" [patch.crates-io] xous = {path = "xous-rs"} xous-macros = {path = "macros"} + +[patch."https://github.com/betrusted-io/xous-engine-25519.git"] engine-25519 = {path = "services/engine-25519"} \ No newline at end of file diff --git a/services/engine-25519/src/api.rs b/services/engine-25519/src/api.rs index 450412204..40cb2ca29 100644 --- a/services/engine-25519/src/api.rs +++ b/services/engine-25519/src/api.rs @@ -41,25 +41,6 @@ pub struct Job { pub window: Option, } -pub enum EngineError { - InternalError, - UnsupportedFeature, - ServerNotFound, - EngineBusy, - IllegalOpcode, - UnknownError, -} - -// a trait for plugging into external crates -// mainly, this just wraps xous::Error into something more informative, and is -// a vestige of an attempt to do a differnt type of integration to the Dalek -// crates that did not work out very well, but it seemed a shame to throw -// away the more descriptive custom error types. -pub trait XousEngine25519 { - fn new() -> Self; - fn run_job(&mut self, job: Job) -> Result<[u32; RF_SIZE_IN_U32], EngineError>; -} - #[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)] pub(crate) enum Opcode { /// Runs a job, if the server is not already occupied diff --git a/services/engine-25519/src/lib.rs b/services/engine-25519/src/lib.rs index 6a1267b00..169121435 100644 --- a/services/engine-25519/src/lib.rs +++ b/services/engine-25519/src/lib.rs @@ -149,24 +149,3 @@ fn engine_cb_server(sid0: usize, sid1: usize, sid2: usize, sid3: usize) { } xous::destroy_server(sid).unwrap(); } - - -impl XousEngine25519 for Engine25519 { - fn new() -> Self { - Engine25519::new() - } - fn run_job(&mut self, job: Job) -> Result<[u32; RF_SIZE_IN_U32], EngineError> { - match self.spawn_job(job) { - Ok(r) => Ok(r), - Err(e) => match e { - xous::Error::InternalError => Err(EngineError::InternalError), - xous::Error::InvalidSyscall => Err(EngineError::UnsupportedFeature), - xous::Error::ServerNotFound => Err(EngineError::ServerNotFound), - xous::Error::ServerQueueFull => Err(EngineError::EngineBusy), - xous::Error::InvalidString => Err(EngineError::IllegalOpcode), - _ => Err(EngineError::UnknownError), - } - } - } -} - diff --git a/services/shellchat/src/cmds/engine.rs b/services/shellchat/src/cmds/engine.rs index c985b0985..9a316506c 100644 --- a/services/shellchat/src/cmds/engine.rs +++ b/services/shellchat/src/cmds/engine.rs @@ -8,6 +8,10 @@ use num_traits::*; use core::sync::atomic::{AtomicU32, Ordering}; static CB_ID: AtomicU32 = AtomicU32::new(0); +// these vectors come from running `cargo test field::test::make_vectors` inside +// https://github.com/betrusted-io/curve25519-dalek. The output file is originally called `test_vectors.bin`. +// a portion of this vector set involves random numbers in addition to deterministic corner cases, +// therefore, every invocation will create a slightly different set of vectors #[export_name = "engine_vectors"] pub static ENGINE_VECTORS: &[u8; 15652] = include_bytes!("engine25519_vectors.bin");