wip: returning to cfg based dependency specification

This commit is contained in:
David Kotval 2024-03-01 13:54:05 -06:00
parent d98a8b11e7
commit b40ec7135e
4 changed files with 13 additions and 19 deletions

View file

@ -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"
@ -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"]

View file

@ -12,6 +12,7 @@ enum DalekBits {
Dalek64,
}
//TODO: remove debugging before merging
macro_rules! build_debug {
($($tokens: tt)*) => {
println!("cargo:warning={}", format!($($tokens)*))
@ -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"
@ -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}\"");
}

View file

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

View file

@ -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;
//------------------------------------------------------------------------