mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
fix up the build system warts & integration with dalek crates
we are at least now only requiring users to use our patched curve25519-dalek crate, which now builds cleanly in both xous and std environments, but the higher-level crates can be directly used from crates.io
This commit is contained in:
parent
6efdb7e0db
commit
e39c2200cd
5 changed files with 7 additions and 41 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -501,7 +501,6 @@ dependencies = [
|
||||||
"digest",
|
"digest",
|
||||||
"engine-25519",
|
"engine-25519",
|
||||||
"engine25519-as",
|
"engine25519-as",
|
||||||
"rand 0.7.3",
|
|
||||||
"rand_core 0.5.1",
|
"rand_core 0.5.1",
|
||||||
"subtle",
|
"subtle",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
|
|
@ -596,6 +595,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "engine25519-as"
|
name = "engine25519-as"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/betrusted-io/engine25519-as.git?rev=6681e73c1fdc4a460b5ef9f9c7c91aef546d00f3#6681e73c1fdc4a460b5ef9f9c7c91aef546d00f3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "enum_dispatch"
|
name = "enum_dispatch"
|
||||||
|
|
|
||||||
|
|
@ -90,4 +90,6 @@ lto = "fat"
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
xous = {path = "xous-rs"}
|
xous = {path = "xous-rs"}
|
||||||
xous-macros = {path = "macros"}
|
xous-macros = {path = "macros"}
|
||||||
|
|
||||||
|
[patch."https://github.com/betrusted-io/xous-engine-25519.git"]
|
||||||
engine-25519 = {path = "services/engine-25519"}
|
engine-25519 = {path = "services/engine-25519"}
|
||||||
|
|
@ -41,25 +41,6 @@ pub struct Job {
|
||||||
pub window: Option<u8>,
|
pub window: Option<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
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)]
|
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||||
pub(crate) enum Opcode {
|
pub(crate) enum Opcode {
|
||||||
/// Runs a job, if the server is not already occupied
|
/// Runs a job, if the server is not already occupied
|
||||||
|
|
|
||||||
|
|
@ -149,24 +149,3 @@ fn engine_cb_server(sid0: usize, sid1: usize, sid2: usize, sid3: usize) {
|
||||||
}
|
}
|
||||||
xous::destroy_server(sid).unwrap();
|
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),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,10 @@ use num_traits::*;
|
||||||
use core::sync::atomic::{AtomicU32, Ordering};
|
use core::sync::atomic::{AtomicU32, Ordering};
|
||||||
static CB_ID: AtomicU32 = AtomicU32::new(0);
|
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"]
|
#[export_name = "engine_vectors"]
|
||||||
pub static ENGINE_VECTORS: &[u8; 15652] = include_bytes!("engine25519_vectors.bin");
|
pub static ENGINE_VECTORS: &[u8; 15652] = include_bytes!("engine25519_vectors.bin");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue