Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Run libursa tests on Ubuntu 20.04 #180

Merged
merged 8 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:

- name: Tests
run: cargo test --release

# disabled in AZP
#
# Portable:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ default = ["sharing"]
sharing = ["ursa_sharing"]

[dependencies]
ursa_sharing = { version = "0.1", path = "ursa_sharing", optional = true }
ursa_sharing = { version = "0.1", path = "ursa_sharing", optional = true }
2 changes: 1 addition & 1 deletion libursa/src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <dyn Fail>::iter_chain(&self.inner) {
if first {
first = false;
writeln!(f, "Error: {}", cause)?;
Expand Down
18 changes: 8 additions & 10 deletions libursa/src/kex/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ mod ecdh_secp256k1 {
use sha2::digest::generic_array::typenum::U32;
use sha2::Digest;
use zeroize::Zeroize;
const PUBLIC_UNCOMPRESSED_KEY_SIZE: usize = 65;

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct EcdhSecp256k1Impl;
Expand Down Expand Up @@ -227,20 +226,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()
);
}
}
4 changes: 2 additions & 2 deletions libursa/src/signatures/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -271,7 +271,7 @@ mod test {
assert!(result.is_ok());
assert!(result.unwrap());
}
Err(er) => assert!(false, er),
Err(er) => assert!(false, "{}", er),
}
}

Expand Down
6 changes: 3 additions & 3 deletions libursa/src/signatures/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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),
}
}

Expand Down