From 5b2f87537caa2273fa400bd3d020d37b25d2ead5 Mon Sep 17 00:00:00 2001 From: Nathan Nguyen Date: Thu, 13 May 2021 21:39:31 -0500 Subject: [PATCH 1/8] exclude libursa and libzmix Signed-off-by: Nathan Nguyen --- Cargo.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index de35ef83..0bf3bd18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,10 @@ crate-type = ["cdylib", "staticlib", "rlib"] lto = true [workspace] +exclude = [ + "libursa", + "libzmix", +] members = [ "ursa_accumulators", "ursa_core", @@ -35,4 +39,4 @@ default = ["sharing"] sharing = ["ursa_sharing"] [dependencies] -ursa_sharing = { version = "0.1", path = "ursa_sharing", optional = true } \ No newline at end of file +ursa_sharing = { version = "0.1", path = "ursa_sharing", optional = true } From 15d0d8158707abe0814260c1ab8c39846e57fca9 Mon Sep 17 00:00:00 2001 From: Nathan Nguyen Date: Thu, 13 May 2021 21:40:42 -0500 Subject: [PATCH 2/8] fix warnings Signed-off-by: Nathan Nguyen --- libursa/src/errors/mod.rs | 2 +- libursa/src/kex/secp256k1.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libursa/src/errors/mod.rs b/libursa/src/errors/mod.rs index 8e8e8257..bf863733 100644 --- a/libursa/src/errors/mod.rs +++ b/libursa/src/errors/mod.rs @@ -89,7 +89,7 @@ impl fmt::Display for UrsaCryptoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut first = true; - for cause in Fail::iter_chain(&self.inner) { + for cause in ::iter_chain(&self.inner) { if first { first = false; writeln!(f, "Error: {}", cause)?; diff --git a/libursa/src/kex/secp256k1.rs b/libursa/src/kex/secp256k1.rs index 8afd6511..2f091699 100644 --- a/libursa/src/kex/secp256k1.rs +++ b/libursa/src/kex/secp256k1.rs @@ -130,6 +130,7 @@ mod ecdh_secp256k1 { use sha2::digest::generic_array::typenum::U32; use sha2::Digest; use zeroize::Zeroize; + #[allow(dead_code)] const PUBLIC_UNCOMPRESSED_KEY_SIZE: usize = 65; #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] From 5a053e56e877224874ec7b6bba5645053743c044 Mon Sep 17 00:00:00 2001 From: Nathan Nguyen Date: Thu, 13 May 2021 21:44:19 -0500 Subject: [PATCH 3/8] fix secp256k1 compat test Signed-off-by: Nathan Nguyen --- libursa/src/kex/secp256k1.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libursa/src/kex/secp256k1.rs b/libursa/src/kex/secp256k1.rs index 2f091699..d56959d9 100644 --- a/libursa/src/kex/secp256k1.rs +++ b/libursa/src/kex/secp256k1.rs @@ -228,20 +228,19 @@ mod tests { #[test] fn secp256k1_compatibility() { - use libsecp256k1::{ - ecdh::SharedSecret, - key::{PublicKey, SecretKey}, + use k256::{ + {PublicKey, SecretKey}, + elliptic_curve::ecdh::diffie_hellman, }; let scheme = EcdhSecp256k1Sha256::new(); let (pk, sk) = scheme.keypair(None).unwrap(); - - let sk1 = SecretKey::from_slice(&sk[..]).unwrap(); - let pk1 = PublicKey::from_slice(&pk[..]).unwrap(); - let secret = SharedSecret::new(&pk1, &sk1); + let sk1 = SecretKey::from_bytes(&sk[..]).unwrap(); + let pk1 = PublicKey::from_sec1_bytes(&pk[..]).unwrap(); + let secret = diffie_hellman(sk1.secret_scalar(), pk1.as_affine()); assert_eq!( - secret.as_ref(), - scheme.compute_shared_secret(&sk, &pk).unwrap().as_ref() + secret.as_bytes().to_vec(), + scheme.compute_shared_secret(&sk, &pk).unwrap().as_ref().to_vec() ); } } From 9d62bf7e24baf7a8eb5a7f9af7db30cf703a0474 Mon Sep 17 00:00:00 2001 From: Nathan Nguyen Date: Thu, 13 May 2021 21:51:23 -0500 Subject: [PATCH 4/8] use 2021 edition-compatible format macros Signed-off-by: Nathan Nguyen --- libursa/src/signatures/ed25519.rs | 4 ++-- libursa/src/signatures/secp256k1.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libursa/src/signatures/ed25519.rs b/libursa/src/signatures/ed25519.rs index b65815c7..f1134509 100644 --- a/libursa/src/signatures/ed25519.rs +++ b/libursa/src/signatures/ed25519.rs @@ -262,7 +262,7 @@ mod test { assert!(result.is_ok()); assert!(result.unwrap()); } - Err(e) => assert!(false, e), + Err(e) => assert!(false, "{}", e), } let signer = Signer::new(&scheme, &s); match signer.sign(&MESSAGE_1) { @@ -271,7 +271,7 @@ mod test { assert!(result.is_ok()); assert!(result.unwrap()); } - Err(er) => assert!(false, er), + Err(er) => assert!(false, "{}", er), } } diff --git a/libursa/src/signatures/secp256k1.rs b/libursa/src/signatures/secp256k1.rs index 565a836a..e68d5ec6 100644 --- a/libursa/src/signatures/secp256k1.rs +++ b/libursa/src/signatures/secp256k1.rs @@ -472,7 +472,7 @@ mod test { assert!(result.is_ok()); assert!(result.unwrap()); } - Err(er) => assert!(false, er), + Err(er) => assert!(false, "{}", er), } let signer = Signer::new(&scheme, &s); @@ -482,10 +482,10 @@ mod test { assert!(result.is_ok()); assert!(result.unwrap()); } - Err(er) => assert!(false, er), + Err(er) => assert!(false, "{}", er), } } - Err(e) => assert!(false, e), + Err(e) => assert!(false, "{}", e), } } From d7861b248e0dc1c2397acca03ea37fc9fb0c9414 Mon Sep 17 00:00:00 2001 From: Nathan Nguyen Date: Thu, 13 May 2021 22:17:12 -0500 Subject: [PATCH 5/8] libursa-specific workflow Signed-off-by: Nathan Nguyen --- .github/workflows/rust.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e0c7fae1..4a8da637 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -40,6 +40,11 @@ jobs: - name: Tests run: cargo test --release + - name: Libursa Build + run: cargo build --verbose --manifest-path=libursa/Cargo.toml + + - name: Libursa Tests + run: cargo test --release --verbose --manifest-path=libursa/Cargo.toml # disabled in AZP # # Portable: From 3037e3ea62dc360d49e6998c000958fca7ec3a83 Mon Sep 17 00:00:00 2001 From: Nathan Nguyen Date: Thu, 13 May 2021 23:04:30 -0500 Subject: [PATCH 6/8] small fixes Signed-off-by: Nathan Nguyen --- .github/workflows/rust.yml | 2 +- libursa/src/kex/secp256k1.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 4a8da637..102c1553 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -44,7 +44,7 @@ jobs: run: cargo build --verbose --manifest-path=libursa/Cargo.toml - name: Libursa Tests - run: cargo test --release --verbose --manifest-path=libursa/Cargo.toml + run: cargo test --release --manifest-path=libursa/Cargo.toml # disabled in AZP # # Portable: diff --git a/libursa/src/kex/secp256k1.rs b/libursa/src/kex/secp256k1.rs index d56959d9..1f06e170 100644 --- a/libursa/src/kex/secp256k1.rs +++ b/libursa/src/kex/secp256k1.rs @@ -228,7 +228,7 @@ mod tests { #[test] fn secp256k1_compatibility() { - use k256::{ + use k256::{ {PublicKey, SecretKey}, elliptic_curve::ecdh::diffie_hellman, }; From f117f16de536bad0fc2669342237dfcbeb8fc807 Mon Sep 17 00:00:00 2001 From: Nathan Nguyen Date: Fri, 28 May 2021 23:48:56 -0500 Subject: [PATCH 7/8] remove dead code Signed-off-by: Nathan Nguyen --- libursa/src/kex/secp256k1.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/libursa/src/kex/secp256k1.rs b/libursa/src/kex/secp256k1.rs index 1f06e170..33105b52 100644 --- a/libursa/src/kex/secp256k1.rs +++ b/libursa/src/kex/secp256k1.rs @@ -130,8 +130,6 @@ mod ecdh_secp256k1 { use sha2::digest::generic_array::typenum::U32; use sha2::Digest; use zeroize::Zeroize; - #[allow(dead_code)] - const PUBLIC_UNCOMPRESSED_KEY_SIZE: usize = 65; #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct EcdhSecp256k1Impl; From fb640cd8c93df684ca8ca76f131714c5e6dbdf0d Mon Sep 17 00:00:00 2001 From: Nathan Nguyen Date: Fri, 28 May 2021 23:50:34 -0500 Subject: [PATCH 8/8] revert testing Signed-off-by: Nathan Nguyen --- .github/workflows/rust.yml | 6 ------ Cargo.toml | 4 ---- 2 files changed, 10 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 102c1553..2b769d93 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -39,12 +39,6 @@ jobs: - name: Tests run: cargo test --release - - - name: Libursa Build - run: cargo build --verbose --manifest-path=libursa/Cargo.toml - - - name: Libursa Tests - run: cargo test --release --manifest-path=libursa/Cargo.toml # disabled in AZP # # Portable: diff --git a/Cargo.toml b/Cargo.toml index 0bf3bd18..f6639e65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,10 +21,6 @@ crate-type = ["cdylib", "staticlib", "rlib"] lto = true [workspace] -exclude = [ - "libursa", - "libzmix", -] members = [ "ursa_accumulators", "ursa_core",