diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 46ac8e65..17674165 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -26,30 +26,37 @@ jobs: - name: Build working-directory: ${{ matrix.workdir }} run: cargo build --verbose + if: always() - name: Format working-directory: ${{ matrix.workdir }} run: cargo fmt --all -- --check + if: always() - name: Docs working-directory: ${{ matrix.workdir }} run: cargo doc --no-deps + if: always() - name: Clippy working-directory: ${{ matrix.workdir }} run: cargo clippy --all -- -W clippy::not_unsafe_ptr_arg_deref -A clippy::many_single_char_names + if: always() - name: Check working-directory: ${{ matrix.workdir }} run: cargo check + if: always() - name: Tests working-directory: ${{ matrix.workdir }} run: cargo test --release + if: always() - name: Audit working-directory: ${{ matrix.workdir }} run: cargo audit + if: always() # disabled in AZP # diff --git a/Cargo.lock b/Cargo.lock index 9153e8a1..f53db55e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,9 +10,9 @@ checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" @@ -66,9 +66,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.72" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "cfg-if" @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.2.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" dependencies = [ "byteorder", "digest 0.9.0", @@ -119,7 +119,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.5", + "generic-array 0.14.6", ] [[package]] @@ -131,7 +131,7 @@ dependencies = [ "bitvec", "const-oid", "ff", - "generic-array 0.14.5", + "generic-array 0.14.6", "group", "rand_core 0.5.1", "subtle", @@ -218,9 +218,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.5" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", @@ -256,9 +256,9 @@ checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" [[package]] name = "k256" @@ -272,9 +272,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.112" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "memchr" @@ -295,9 +295,9 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ "autocfg", "num-traits", @@ -305,18 +305,18 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.9.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "opaque-debug" @@ -326,23 +326,35 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "openssl" -version = "0.10.38" +version = "0.10.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95" +checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" dependencies = [ "bitflags", "cfg-if", "foreign-types", "libc", "once_cell", + "openssl-macros", "openssl-sys", ] +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "openssl-sys" -version = "0.9.72" +version = "0.9.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" +checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" dependencies = [ "autocfg", "cc", @@ -377,30 +389,30 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.24" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.36" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.14" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] @@ -500,15 +512,15 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" [[package]] name = "serde" -version = "1.0.156" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" [[package]] name = "serde_bare" @@ -531,9 +543,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.94" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" +checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" dependencies = [ "itoa", "ryu", @@ -566,13 +578,13 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.85" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -589,18 +601,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.39" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.39" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" dependencies = [ "proc-macro2", "quote", @@ -609,15 +621,21 @@ dependencies = [ [[package]] name = "typenum" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" [[package]] name = "unicode-xid" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "ursa" @@ -744,9 +762,9 @@ dependencies = [ [[package]] name = "zeroize_derive" -version = "1.2.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65f1a51723ec88c66d5d1fe80c841f17f63587d6691901d66be9bec6c3b51f73" +checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" dependencies = [ "proc-macro2", "quote", diff --git a/libursa/Cargo.toml b/libursa/Cargo.toml index 38aaccb7..62a34824 100644 --- a/libursa/Cargo.toml +++ b/libursa/Cargo.toml @@ -2,12 +2,13 @@ name = "ursa" version = "0.3.7" authors = ["Hyperledger Ursa Contributors"] -description = "This is the shared crypto library for Hyperledger components." +description = "The Hyperledger Cryptographic library." license = "Apache-2.0" readme = "../README.md" repository = "https://github.com/hyperledger/ursa" documentation = "https://docs.rs/ursa" homepage = "https://crates.io/crates/ursa" +edition = "2021" keywords = ["cryptography", "aead", "hash", "signature", "zero-knowledge"] include = [ "src/bls/**/*.rs", @@ -177,7 +178,7 @@ license-file = ["../LICENSE", "0"] copyright = "2019, Hyperledger" depends = "$auto" extended-description = """\ -Rust written reliable, secure, easy-to-use, and pluggable cryptographic implementations.""" +Rust-written reliable, secure, easy-to-use, and pluggable cryptographic implementations.""" section = "admin" revision = "1" priority = "optional" diff --git a/libursa/src/bls/mod.rs b/libursa/src/bls/mod.rs index e8e9bd36..3098a8a8 100644 --- a/libursa/src/bls/mod.rs +++ b/libursa/src/bls/mod.rs @@ -1,5 +1,5 @@ -use errors::prelude::*; -use pair::{GroupOrderElement, Pair, PointG1, PointG2}; +use crate::errors::prelude::*; +use crate::pair::{GroupOrderElement, Pair, PointG1, PointG2}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; diff --git a/libursa/src/bn/openssl.rs b/libursa/src/bn/openssl.rs index 65f22c1a..5f64500d 100644 --- a/libursa/src/bn/openssl.rs +++ b/libursa/src/bn/openssl.rs @@ -1,4 +1,4 @@ -use errors::prelude::*; +use crate::errors::prelude::*; use int_traits::IntTraits; diff --git a/libursa/src/cl/constants.rs b/libursa/src/cl/constants.rs index 273ff994..b3e78510 100644 --- a/libursa/src/cl/constants.rs +++ b/libursa/src/cl/constants.rs @@ -1,4 +1,4 @@ -use bn::{BigNumber, BIGNUMBER_2}; +use crate::bn::{BigNumber, BIGNUMBER_2}; pub const LARGE_MASTER_SECRET: usize = 256; pub const LARGE_E_START: usize = 596; diff --git a/libursa/src/cl/hash.rs b/libursa/src/cl/hash.rs index 9a45574d..0ca2ad91 100644 --- a/libursa/src/cl/hash.rs +++ b/libursa/src/cl/hash.rs @@ -1,5 +1,5 @@ -use bn::BigNumber; -use errors::prelude::*; +use crate::bn::BigNumber; +use crate::errors::prelude::*; pub fn get_hash_as_int(nums: &[Vec<u8>]) -> UrsaCryptoResult<BigNumber> { trace!("Helpers::get_hash_as_int: >>> nums: {:?}", nums); diff --git a/libursa/src/cl/helpers.rs b/libursa/src/cl/helpers.rs index 126ab1c8..be46f279 100644 --- a/libursa/src/cl/helpers.rs +++ b/libursa/src/cl/helpers.rs @@ -1,8 +1,8 @@ use super::constants::*; -use bn::{BigNumber, BIGNUMBER_1}; -use cl::*; -use errors::prelude::*; -use pair::GroupOrderElement; +use crate::bn::{BigNumber, BIGNUMBER_1}; +use crate::cl::*; +use crate::errors::prelude::*; +use crate::pair::GroupOrderElement; use std::cmp::max; use std::collections::{HashMap, HashSet}; @@ -669,7 +669,7 @@ pub fn create_tau_list_values( #[cfg(test)] mod tests { use super::*; - use cl::{issuer, prover}; + use crate::cl::{issuer, prover}; #[test] fn encode_attribute_works() { diff --git a/libursa/src/cl/issuer.rs b/libursa/src/cl/issuer.rs index 0396bbe0..571ae9e7 100644 --- a/libursa/src/cl/issuer.rs +++ b/libursa/src/cl/issuer.rs @@ -1,11 +1,11 @@ -use bn::BigNumber; -use cl::constants::*; -use cl::hash::get_hash_as_int; -use cl::helpers::*; -use cl::*; -use errors::prelude::*; -use pair::*; -use utils::commitment::get_pedersen_commitment; +use crate::bn::BigNumber; +use crate::cl::constants::*; +use crate::cl::hash::get_hash_as_int; +use crate::cl::helpers::*; +use crate::cl::*; +use crate::errors::prelude::*; +use crate::pair::*; +use crate::utils::commitment::get_pedersen_commitment; use std::collections::{BTreeSet, HashMap, HashSet}; use std::iter::FromIterator; @@ -1416,8 +1416,8 @@ mod tests { use self::prover::mocks as prover_mocks; use self::prover::Prover; use super::*; - use cl::helpers::MockHelper; - use cl::issuer::{mocks, Issuer}; + use crate::cl::helpers::MockHelper; + use crate::cl::issuer::{mocks, Issuer}; #[test] fn generate_context_attribute_works() { diff --git a/libursa/src/cl/mod.rs b/libursa/src/cl/mod.rs index bc8b0fb5..f06e17ca 100755 --- a/libursa/src/cl/mod.rs +++ b/libursa/src/cl/mod.rs @@ -9,9 +9,9 @@ pub mod issuer; pub mod prover; pub mod verifier; -use bn::BigNumber; -use errors::prelude::*; -use pair::*; +use crate::bn::BigNumber; +use crate::errors::prelude::*; +use crate::pair::*; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; diff --git a/libursa/src/cl/prover.rs b/libursa/src/cl/prover.rs index 8c1f16db..83ac1ee0 100644 --- a/libursa/src/cl/prover.rs +++ b/libursa/src/cl/prover.rs @@ -1,11 +1,11 @@ use super::helpers::*; -use bn::BigNumber; -use cl::constants::*; -use cl::hash::get_hash_as_int; -use cl::*; -use errors::prelude::*; -use pair::*; -use utils::commitment::get_pedersen_commitment; +use crate::bn::BigNumber; +use crate::cl::constants::*; +use crate::cl::hash::get_hash_as_int; +use crate::cl::*; +use crate::errors::prelude::*; +use crate::pair::*; +use crate::utils::commitment::get_pedersen_commitment; use std::collections::{BTreeMap, BTreeSet, HashSet}; @@ -1902,7 +1902,7 @@ impl ProofBuilder { #[cfg(test)] mod tests { use super::*; - use cl::issuer; + use crate::cl::issuer; #[cfg(feature = "serde")] use serde_json::{self, json}; use std::time::Instant; diff --git a/libursa/src/cl/verifier.rs b/libursa/src/cl/verifier.rs index fadb5db4..9fd2a53e 100644 --- a/libursa/src/cl/verifier.rs +++ b/libursa/src/cl/verifier.rs @@ -1,9 +1,9 @@ -use bn::BigNumber; -use cl::constants::{ITERATION, LARGE_E_START_VALUE}; -use cl::hash::get_hash_as_int; -use cl::helpers::*; -use cl::*; -use errors::prelude::*; +use crate::bn::BigNumber; +use crate::cl::constants::{ITERATION, LARGE_E_START_VALUE}; +use crate::cl::hash::get_hash_as_int; +use crate::cl::helpers::*; +use crate::cl::*; +use crate::errors::prelude::*; use std::collections::hash_map::Entry; use std::collections::{BTreeSet, HashMap}; @@ -644,10 +644,10 @@ impl ProofVerifier { #[cfg(test)] mod tests { use super::*; - use cl::helpers::MockHelper; - use cl::issuer; - use cl::prover; - use cl::prover::mocks::*; + use crate::cl::helpers::MockHelper; + use crate::cl::issuer; + use crate::cl::prover; + use crate::cl::prover::mocks::*; #[test] fn sub_proof_request_builder_works() { diff --git a/libursa/src/errors/mod.rs b/libursa/src/errors/mod.rs index bffcb505..99334dbd 100644 --- a/libursa/src/errors/mod.rs +++ b/libursa/src/errors/mod.rs @@ -1,7 +1,7 @@ extern crate log; #[cfg(feature = "ffi")] -use ffi::ErrorCode; +use crate::ffi::ErrorCode; use std::cell::RefCell; use std::ffi::CString; @@ -14,7 +14,7 @@ use std::ptr; use failure::{Backtrace, Context, Fail}; #[cfg(feature = "ffi")] -use utils::ctypes; +use crate::utils::ctypes; #[cfg(feature = "ffi")] pub mod prelude { diff --git a/libursa/src/ffi/bls.rs b/libursa/src/ffi/bls.rs index b5366850..bca6ed28 100644 --- a/libursa/src/ffi/bls.rs +++ b/libursa/src/ffi/bls.rs @@ -1,7 +1,7 @@ -use bls::*; -use errors::prelude::*; +use crate::bls::*; +use crate::errors::prelude::*; -use ffi::ErrorCode; +use crate::ffi::ErrorCode; use std::os::raw::c_void; use std::slice; diff --git a/libursa/src/ffi/cl/issuer.rs b/libursa/src/ffi/cl/issuer.rs index 5bb60b81..c32ea777 100644 --- a/libursa/src/ffi/cl/issuer.rs +++ b/libursa/src/ffi/cl/issuer.rs @@ -1,9 +1,9 @@ -use cl::issuer::*; -use cl::*; -use errors::prelude::*; -use ffi::cl::{FFITailPut, FFITailTake, FFITailsAccessor}; -use ffi::ErrorCode; -use utils::ctypes::*; +use crate::cl::issuer::*; +use crate::cl::*; +use crate::errors::prelude::*; +use crate::ffi::cl::{FFITailPut, FFITailTake, FFITailsAccessor}; +use crate::ffi::ErrorCode; +use crate::utils::ctypes::*; use serde_json; use std::collections::HashSet; @@ -2012,9 +2012,9 @@ pub extern "C" fn ursa_cl_issuer_merge_revocation_registry_deltas( mod tests { use super::*; - use ffi::cl::issuer::mocks::*; - use ffi::cl::mocks::*; - use ffi::cl::prover::mocks::*; + use crate::ffi::cl::issuer::mocks::*; + use crate::ffi::cl::mocks::*; + use crate::ffi::cl::prover::mocks::*; use std::ptr; #[test] @@ -3025,7 +3025,7 @@ mod tests { pub mod mocks { use super::*; - use ffi::cl::mocks::*; + use crate::ffi::cl::mocks::*; use std::ffi::CString; use std::ptr; diff --git a/libursa/src/ffi/cl/mod.rs b/libursa/src/ffi/cl/mod.rs index 2d4429f7..4736df2b 100644 --- a/libursa/src/ffi/cl/mod.rs +++ b/libursa/src/ffi/cl/mod.rs @@ -1,9 +1,9 @@ -use cl::issuer::Issuer; -use cl::verifier::Verifier; -use cl::*; -use errors::prelude::*; -use ffi::ErrorCode; -use utils::ctypes::*; +use crate::cl::issuer::Issuer; +use crate::cl::verifier::Verifier; +use crate::cl::*; +use crate::errors::prelude::*; +use crate::ffi::ErrorCode; +use crate::utils::ctypes::*; use serde_json; use std::os::raw::{c_char, c_void}; @@ -1221,7 +1221,7 @@ impl RevocationTailsAccessor for FFITailsAccessor { mod tests { use super::*; - use ffi::cl::mocks::*; + use crate::ffi::cl::mocks::*; use std::ffi::CString; use std::ptr; diff --git a/libursa/src/ffi/cl/prover.rs b/libursa/src/ffi/cl/prover.rs index 36caaf8f..6d164dfb 100644 --- a/libursa/src/ffi/cl/prover.rs +++ b/libursa/src/ffi/cl/prover.rs @@ -1,8 +1,8 @@ -use cl::prover::*; -use cl::*; -use errors::prelude::*; -use ffi::ErrorCode; -use utils::ctypes::*; +use crate::cl::prover::*; +use crate::cl::*; +use crate::errors::prelude::*; +use crate::ffi::ErrorCode; +use crate::utils::ctypes::*; use serde_json; use std::os::raw::{c_char, c_void}; @@ -1261,9 +1261,9 @@ pub extern "C" fn ursa_cl_proof_free(proof: *const c_void) -> ErrorCode { mod tests { use super::*; - use ffi::cl::issuer::mocks::*; - use ffi::cl::mocks::*; - use ffi::cl::prover::mocks::*; + use crate::ffi::cl::issuer::mocks::*; + use crate::ffi::cl::mocks::*; + use crate::ffi::cl::prover::mocks::*; use std::ptr; // Master secret is now called link secret. @@ -2207,7 +2207,7 @@ mod tests { pub mod mocks { use super::*; - use ffi::cl::mocks::*; + use crate::ffi::cl::mocks::*; use std::ptr; pub fn _master_secret() -> *const c_void { diff --git a/libursa/src/ffi/cl/verifier.rs b/libursa/src/ffi/cl/verifier.rs index dd9f8d54..b1945921 100644 --- a/libursa/src/ffi/cl/verifier.rs +++ b/libursa/src/ffi/cl/verifier.rs @@ -1,8 +1,8 @@ -use cl::verifier::*; -use cl::*; -use errors::prelude::*; -use ffi::ErrorCode; -use utils::ctypes::*; +use crate::cl::verifier::*; +use crate::cl::*; +use crate::errors::prelude::*; +use crate::ffi::ErrorCode; +use crate::utils::ctypes::*; use std::os::raw::{c_char, c_void}; @@ -208,7 +208,7 @@ mod tests { use super::super::issuer::mocks::*; use super::super::prover::mocks::*; use super::mocks::*; - use ffi::cl::mocks::*; + use crate::ffi::cl::mocks::*; use std::ptr; // Master secret is now called link secret. diff --git a/libursa/src/ffi/encryption/mod.rs b/libursa/src/ffi/encryption/mod.rs index a507e710..6fed9dde 100644 --- a/libursa/src/ffi/encryption/mod.rs +++ b/libursa/src/ffi/encryption/mod.rs @@ -1,7 +1,7 @@ use super::ByteArray; +use crate::encryption::random_vec; +use crate::encryption::symm::prelude::*; use aead::{generic_array::typenum::Unsigned, Aead, NewAead}; -use encryption::random_vec; -use encryption::symm::prelude::*; use ffi_support::{ByteBuffer, ErrorCode, ExternError, FfiStr}; use std::ffi::CString; use std::str::FromStr; diff --git a/libursa/src/ffi/logger.rs b/libursa/src/ffi/logger.rs index 513c2baf..a01c859f 100644 --- a/libursa/src/ffi/logger.rs +++ b/libursa/src/ffi/logger.rs @@ -1,12 +1,12 @@ use std::os::raw::{c_char, c_void}; -use errors::prelude::*; -use ffi::ErrorCode; +use crate::errors::prelude::*; +use crate::ffi::ErrorCode; extern crate log; -use utils::ctypes::*; -use utils::logger::{EnabledCB, FlushCB, HLCryptoDefaultLogger, HLCryptoLogger, LogCB}; +use crate::utils::ctypes::*; +use crate::utils::logger::{EnabledCB, FlushCB, HLCryptoDefaultLogger, HLCryptoLogger, LogCB}; /// Set custom logger implementation. /// diff --git a/libursa/src/ffi/mod.rs b/libursa/src/ffi/mod.rs index 8704e0eb..6755005e 100644 --- a/libursa/src/ffi/mod.rs +++ b/libursa/src/ffi/mod.rs @@ -12,7 +12,7 @@ pub mod logger; ))] pub mod signatures; -use errors::prelude::*; +use crate::errors::prelude::*; use ffi_support::ByteBuffer; use std::os::raw::c_char; @@ -192,9 +192,9 @@ pub extern "C" fn ursa_get_current_error(error_json_p: *mut *const c_char) { mod tests { use super::*; - use ffi::cl::issuer::ursa_cl_credential_private_key_from_json; + use crate::ffi::cl::issuer::ursa_cl_credential_private_key_from_json; + use crate::utils::ctypes::*; use std::ptr; - use utils::ctypes::*; #[test] fn ursa_get_current_error_works() { diff --git a/libursa/src/ffi/signatures/ed25519.rs b/libursa/src/ffi/signatures/ed25519.rs index 864fef2a..0daddb20 100644 --- a/libursa/src/ffi/signatures/ed25519.rs +++ b/libursa/src/ffi/signatures/ed25519.rs @@ -146,9 +146,9 @@ // } use super::super::ByteArray; -use keys::{KeyGenOption, PrivateKey, PublicKey}; -use signatures::ed25519; -use signatures::prelude::*; +use crate::keys::{KeyGenOption, PrivateKey, PublicKey}; +use crate::signatures::ed25519; +use crate::signatures::prelude::*; use ffi_support::{ByteBuffer, ErrorCode, ExternError}; diff --git a/libursa/src/kex/mod.rs b/libursa/src/kex/mod.rs index 40aecbbc..ddca28dc 100644 --- a/libursa/src/kex/mod.rs +++ b/libursa/src/kex/mod.rs @@ -1,7 +1,7 @@ //! A suite of Diffie-Hellman key exchange methods. -use keys::{KeyGenOption, PrivateKey, PublicKey, SessionKey}; -use CryptoError; +use crate::keys::{KeyGenOption, PrivateKey, PublicKey, SessionKey}; +use crate::CryptoError; /// A Generic trait for key exchange schemes. Each scheme provides a way to generate keys and /// do a diffie-hellman computation diff --git a/libursa/src/kex/secp256k1.rs b/libursa/src/kex/secp256k1.rs index df3ec95d..128bde55 100644 --- a/libursa/src/kex/secp256k1.rs +++ b/libursa/src/kex/secp256k1.rs @@ -1,6 +1,6 @@ use super::*; -use CryptoError; +use crate::CryptoError; pub const PRIVATE_KEY_SIZE: usize = 32; pub const PUBLIC_KEY_SIZE: usize = 33; diff --git a/libursa/src/kex/x25519.rs b/libursa/src/kex/x25519.rs index 0ddd5ae5..19aa0b4b 100644 --- a/libursa/src/kex/x25519.rs +++ b/libursa/src/kex/x25519.rs @@ -6,7 +6,7 @@ use sha2::Digest; use x25519_dalek::{PublicKey as X25519PublicKey, StaticSecret}; use zeroize::Zeroize; -use CryptoError; +use crate::CryptoError; pub struct X25519Sha256; @@ -78,7 +78,7 @@ mod tests { #[cfg(any(feature = "ed25519", feature = "ed25519_asm"))] #[test] fn convert_from_sig_keys() { - use signatures::{ed25519::Ed25519Sha512, SignatureScheme}; + use crate::signatures::{ed25519::Ed25519Sha512, SignatureScheme}; let sig_scheme = Ed25519Sha512::new(); let (pk, sk) = sig_scheme.keypair(None).unwrap(); let res = Ed25519Sha512::ver_key_to_key_exchange(&pk); diff --git a/libursa/src/pair/amcl.rs b/libursa/src/pair/amcl.rs index 2bdac1c6..d7714b1a 100644 --- a/libursa/src/pair/amcl.rs +++ b/libursa/src/pair/amcl.rs @@ -1,4 +1,4 @@ -use errors::prelude::*; +use crate::errors::prelude::*; use amcl::bn254::big::BIG; diff --git a/libursa/src/sharing/shamir.rs b/libursa/src/sharing/shamir.rs index b5042d01..02bff3bd 100644 --- a/libursa/src/sharing/shamir.rs +++ b/libursa/src/sharing/shamir.rs @@ -9,10 +9,10 @@ //! Future work would be to use pedersen commitments or reed-solomon //! codes to check for corrupted shares. -use bn::BigNumber; +use crate::bn::BigNumber; use std::{cmp::Ordering, collections::BTreeSet}; -use {CryptoError, CryptoResult}; +use crate::{CryptoError, CryptoResult}; /// Represents an element in a finite field as [0, n) #[derive(Debug)] diff --git a/libursa/src/signatures/bls.rs b/libursa/src/signatures/bls.rs index 7c73c7fc..fd29a212 100644 --- a/libursa/src/signatures/bls.rs +++ b/libursa/src/signatures/bls.rs @@ -1,4 +1,5 @@ use super::SignatureScheme; +use crate::keys::{KeyGenOption, PrivateKey as UrsaPrivateKey, PublicKey as UrsaPublicKey}; /// Implements /// https://eprint.iacr.org/2018/483 and /// https://crypto.stanford.edu/~dabo/pubs/papers/BLSmultisig.html @@ -11,12 +12,11 @@ use amcl_wrapper::{ group_elem_g2::G2, types_g2::GroupG2_SIZE, }; -use keys::{KeyGenOption, PrivateKey as UrsaPrivateKey, PublicKey as UrsaPublicKey}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use sha2::Sha256; -use CryptoError; +use crate::CryptoError; pub const PRIVATE_KEY_SIZE: usize = MODBYTES; /// This is a simple alias so the consumer can just use PrivateKey::random() to generate a new one diff --git a/libursa/src/signatures/ed25519.rs b/libursa/src/signatures/ed25519.rs index 3efd9cd7..108258c3 100644 --- a/libursa/src/signatures/ed25519.rs +++ b/libursa/src/signatures/ed25519.rs @@ -1,6 +1,7 @@ pub const ALGORITHM_NAME: &str = "ED25519_SHA2_512"; use super::{KeyGenOption, SignatureScheme}; +use crate::keys::{PrivateKey, PublicKey}; #[cfg(any(feature = "x25519", feature = "x25519_asm"))] use ed25519_dalek::SecretKey as SK; use ed25519_dalek::{Keypair, PublicKey as PK, Signature, Signer, Verifier}; @@ -8,7 +9,6 @@ pub use ed25519_dalek::{ EXPANDED_SECRET_KEY_LENGTH as PRIVATE_KEY_SIZE, PUBLIC_KEY_LENGTH as PUBLIC_KEY_SIZE, SIGNATURE_LENGTH as SIGNATURE_SIZE, }; -use keys::{PrivateKey, PublicKey}; use rand::rngs::OsRng; use rand::SeedableRng; use rand_chacha::ChaChaRng; @@ -16,7 +16,7 @@ use sha2::Digest; use std::convert::TryFrom; use zeroize::Zeroize; -use CryptoError; +use crate::CryptoError; pub struct Ed25519Sha512; @@ -169,7 +169,7 @@ mod test { use self::Ed25519Sha512; use super::super::{SignatureScheme, Signer}; use super::*; - use keys::{KeyGenOption, PrivateKey, PublicKey}; + use crate::keys::{KeyGenOption, PrivateKey, PublicKey}; const MESSAGE_1: &[u8] = b"This is a dummy message for use with tests"; const SIGNATURE_1: &str = "451b5b8e8725321541954997781de51f4142e4a56bab68d24f6a6b92615de5eefb74134138315859a32c7cf5fe5a488bc545e2e08e5eedfd1fb10188d532d808"; diff --git a/libursa/src/signatures/mod.rs b/libursa/src/signatures/mod.rs index 7676b686..88076c22 100644 --- a/libursa/src/signatures/mod.rs +++ b/libursa/src/signatures/mod.rs @@ -21,8 +21,8 @@ pub mod prelude { pub use super::{SignatureScheme, Signer}; } -use keys::{KeyGenOption, PrivateKey, PublicKey}; -use CryptoError; +use crate::keys::{KeyGenOption, PrivateKey, PublicKey}; +use crate::CryptoError; pub trait SignatureScheme { fn new() -> Self; diff --git a/libursa/src/signatures/secp256k1.rs b/libursa/src/signatures/secp256k1.rs index 4fb870ac..e9a2c238 100644 --- a/libursa/src/signatures/secp256k1.rs +++ b/libursa/src/signatures/secp256k1.rs @@ -1,7 +1,6 @@ use super::*; use sha2::digest::generic_array::typenum::U32; -use CryptoError; #[cfg(feature = "serde")] use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer}; diff --git a/libursa/src/utils/commitment.rs b/libursa/src/utils/commitment.rs index c55e3dbc..34b3fab9 100644 --- a/libursa/src/utils/commitment.rs +++ b/libursa/src/utils/commitment.rs @@ -1,5 +1,5 @@ -use bn::{BigNumber, BigNumberContext}; -use errors::prelude::*; +use crate::bn::{BigNumber, BigNumberContext}; +use crate::errors::prelude::*; /// Generate a pedersen commitment to a given number /// diff --git a/libursa/src/utils/logger.rs b/libursa/src/utils/logger.rs index 4eb9fff2..57edbb2c 100644 --- a/libursa/src/utils/logger.rs +++ b/libursa/src/utils/logger.rs @@ -7,7 +7,7 @@ use log::{Metadata, Record}; use std::env; use std::io::Write; -use errors::prelude::*; +use crate::errors::prelude::*; use std::ffi::CString; use std::os::raw::{c_char, c_void};