mirror of
https://github.com/saymrwulf/betrusted-curve25519-dalek-source.git
synced 2026-09-05 20:30:54 +00:00
Merge branch 'cfg_fix' into update_to_v4
This commit is contained in:
commit
e8fdef83b4
3 changed files with 19 additions and 9 deletions
|
|
@ -56,25 +56,26 @@ subtle = { version = "2.3.0", default-features = false }
|
|||
serde = { version = "1.0", default-features = false, optional = true, features = ["derive"] }
|
||||
zeroize = { version = "1", default-features = false, optional = true }
|
||||
|
||||
# Betrusted/Precursor dependency set
|
||||
[target.'cfg(curve25519_dalek_backend = "u32e_backend")'.dependencies]
|
||||
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.0"} # this is bogus -- must be patched in the invoking build environment TODO: if this builds, it seems a crate has been released as version 0.1.23 that could replace this
|
||||
# Betrusted/Precursor dependency set, enabled by backend_u32e feature
|
||||
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.0", optional = true} # this is bogus -- must be patched in the invoking build environment TODO: if this builds, it seems a crate has been released as version 0.1.23 that could replace this
|
||||
|
||||
[target.'cfg(target_arch = "x86_64")'.dependencies]
|
||||
cpufeatures = "0.2.6"
|
||||
|
||||
[target.'cfg(curve25519_dalek_backend = "fiat")'.dependencies]
|
||||
fiat-crypto = { version = "0.2.1", default-features = false }
|
||||
fiat-crypto = { version = "0.2.1", default-features = false , optional = true}
|
||||
|
||||
[features]
|
||||
default = ["alloc", "precomputed-tables", "zeroize"]
|
||||
alloc = ["zeroize?/alloc"]
|
||||
precomputed-tables = []
|
||||
legacy_compatibility = []
|
||||
backend_fiat = ["dep:fiat-crypto"]
|
||||
backend_u32e = ["dep:engine25519-as","dep:engine-25519","dep:utralib"]
|
||||
group = ["dep:group", "rand_core"]
|
||||
group-bits = ["group", "ff/bits"]
|
||||
|
||||
[target.'cfg(all(not(curve25519_dalek_backend = "fiat"), not(curve25519_dalek_backend = "serial"), target_arch = "x86_64", not(curve25519_dalek_backend = "u32e_backend")))'.dependencies]
|
||||
# TODO: clean this up as you can't select deps like this
|
||||
[target.'cfg(all(not(curve25519_dalek_backend = "fiat"), not(curve25519_dalek_backend = "serial"), target_arch = "x86_64"))'.dependencies]
|
||||
curve25519-dalek-derive = { version = "0.1", path = "../curve25519-dalek-derive" }
|
||||
|
|
|
|||
|
|
@ -12,6 +12,12 @@ enum DalekBits {
|
|||
Dalek64,
|
||||
}
|
||||
|
||||
macro_rules! build_debug {
|
||||
($($tokens: tt)*) => {
|
||||
println!("cargo:warning={}", format!($($tokens)*))
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let target_triplet = std::env::var("TARGET").unwrap();
|
||||
let platform = platforms::Platform::find(&target_triplet).unwrap();
|
||||
|
|
@ -21,6 +27,8 @@ fn main() {
|
|||
Ok("64") => DalekBits::Dalek64,
|
||||
_ => deterministic::determine_curve25519_dalek_bits(),
|
||||
};
|
||||
build_debug!("CARGO_CFG_CURVE25519_DALEK_BITS: {:?}", std::env::var("CARGO_CFG_CURVE25519_DALEK_BITS").as_deref());
|
||||
build_debug!("curve25519_dalek_bits {:?}", curve25519_dalek_bits);
|
||||
|
||||
match curve25519_dalek_bits {
|
||||
DalekBits::Dalek64 => println!("cargo:rustc-cfg=curve25519_dalek_bits=\"64\""),
|
||||
|
|
@ -77,6 +85,7 @@ fn main() {
|
|||
},
|
||||
}
|
||||
};
|
||||
build_debug!("curve25519_dalek_backend {:?}", curve25519_dalek_backend);
|
||||
println!("cargo:rustc-cfg=curve25519_dalek_backend=\"{curve25519_dalek_backend}\"");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ pub(crate) const SQRT_M1: FieldElement2625 = FieldElement2625::from_limbs([
|
|||
|
||||
/// `APLUS2_OVER_FOUR` is (A+2)/4. (This is used internally within the Montgomery ladder.)
|
||||
/// The u32e backend uses hardware acceleration for this.
|
||||
#[cfg(not(curve_dalek_backend = "u32e_backend"))]
|
||||
#[cfg(not(curve25519_dalek_backend = "u32e_backend"))]
|
||||
pub(crate) const APLUS2_OVER_FOUR: FieldElement2625 =
|
||||
FieldElement2625::from_limbs([121666, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue