Skip to content

Commit

Permalink
wip: returning to cfg based dependency specification
Browse files Browse the repository at this point in the history
  • Loading branch information
kotval committed Mar 1, 2024
1 parent d98a8b1 commit b40ec71
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
12 changes: 6 additions & 6 deletions curve25519-dalek/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ serde = { version = "1.0", default-features = false, optional = true, features =
zeroize = { version = "1", default-features = false, optional = true }

# Betrusted/Precursor dependency set, enabled by backend_u32e feature
log = { version = "0.4", optional = true}
engine25519-as = {git = "https://github.com/betrusted-io/engine25519-as.git", rev = "d249c967556b02ab5439eacb5078fa00c60b93d6", default-features = false, features = [], optional = true}
engine-25519 = { git = "https://github.com/betrusted-io/xous-engine-25519.git", rev = "63d3d1f30736022e791deaacf4dd62c00b42fe2e", optional = true}
utralib = {version = "0.1.24", default-features = false, optional = true}
[target.'cfg(curve25519_dalek_backend = "u32e_backend")'.dependencies]
log = { version = "0.4"}
engine25519-as = {git = "https://github.com/betrusted-io/engine25519-as.git", rev = "d249c967556b02ab5439eacb5078fa00c60b93d6", default-features = false, features = []}
engine-25519 = { git = "https://github.com/betrusted-io/xous-engine-25519.git", rev = "63d3d1f30736022e791deaacf4dd62c00b42fe2e"}
utralib = {version = "0.1.24", default-features = false}


[target.'cfg(target_arch = "x86_64")'.dependencies]
cpufeatures = "0.2.6"
Expand All @@ -72,8 +74,6 @@ default = ["alloc", "precomputed-tables", "zeroize"]
alloc = ["zeroize?/alloc"]
precomputed-tables = []
legacy_compatibility = []
fiat_backend = ["dep:fiat-crypto"]
u32e_backend = ["dep:engine25519-as","dep:engine-25519","dep:utralib","log","zeroize"]
group = ["dep:group", "rand_core"]
group-bits = ["group", "ff/bits"]

Expand Down
4 changes: 3 additions & 1 deletion curve25519-dalek/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum DalekBits {
Dalek64,
}

//TODO: remove debugging before merging
macro_rules! build_debug {
($($tokens: tt)*) => {
println!("cargo:warning={}", format!($($tokens)*))
Expand Down Expand Up @@ -71,7 +72,7 @@ fn main() {
},
//coprocessor for Precursor
Ok("u32e_backend") => {
if curve25519_dalek_bits != DalekBits::Dalek64{
if curve25519_dalek_bits != DalekBits::Dalek32{
panic!("u32e_backend only supports 32 bit bits");
}
"u32e_backend"
Expand All @@ -85,6 +86,7 @@ fn main() {
},
}
};
build_debug!("CARGO_CFG_CURVE25519_DALEK_BACKEND: {:?}", std::env::var("CARGO_CFG_CURVE25519_DALEK_BACKEND").as_deref());
build_debug!("curve25519_dalek_backend {:?}", curve25519_dalek_backend);
println!("cargo:rustc-cfg=curve25519_dalek_backend=\"{curve25519_dalek_backend}\"");
}
Expand Down
1 change: 1 addition & 0 deletions curve25519-dalek/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ mod test {
}

#[test]
#[cfg(curve25519_dalek_backend = "u32e_backend")]
fn make_vectors() {
// reminder to self: to create just this vector, run
// cargo test field::test::make_vectors
Expand Down
15 changes: 3 additions & 12 deletions curve25519-dalek/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,12 @@ pub(crate) mod macros;

//To consider upstreaming, we likely can't do this. Consider the "panic_on_sw_eval" feature
#[allow(unused_imports)]
#[cfg(any(test, curve25519_dalek_backend = "u32e_backend"))]
#[cfg(curve25519_dalek_backend = "u32e_backend")]
#[macro_use]
extern crate engine25519_as;
#[cfg(curve25519_dalek_backend = "u32e_backend")] //this is the binding for betrusted, so it should be gated
//with a "betrusted" flag, but we gate it with the backend
//flag for now. We'd need to refactor this to be
//make it easier to support other platforms,
//though there are no other platforms. For
//upstreaming this might be diserable, but for
//now, we'll leave it as a TODO.
#[cfg(curve25519_dalek_backend = "u32e_backend")]
extern crate engine_25519;

#[cfg(curve25519_dalek_backend = "u32e_backend")] //while this is specific to betrusted, any other
//use of this hardware would likely also need
//utralib, at least that would be easiest.
#[cfg(curve25519_dalek_backend = "u32e_backend")]
extern crate utralib;

//------------------------------------------------------------------------
Expand Down

0 comments on commit b40ec71

Please sign in to comment.