From 3ae1c58d46cfa4fef5212c0d23d3b68b1399214b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Garillot?= Date: Fri, 12 Jun 2020 18:46:08 -0400 Subject: [PATCH] test DH as well --- Cargo.toml | 2 +- src/keypair.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2204012..8e6ca88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,4 +33,4 @@ hex = "0.4.2" lazy_static = "1.4.0" serde_json = "1.0" proptest = "0.10.0" -rand = "0.7" \ No newline at end of file +rand = "0.7" diff --git a/src/keypair.rs b/src/keypair.rs index e49df75..b660ee1 100644 --- a/src/keypair.rs +++ b/src/keypair.rs @@ -237,5 +237,15 @@ mod tests { prop_assert_eq!(&X25519KeyPair::public_from_private(sk), pk); } + + #[test] + fn test_x25519_dh(kp1 in X25519KeyPair::uniform_keypair_strategy(), + kp2 in X25519KeyPair::uniform_keypair_strategy()) { + + let dh1 = X25519KeyPair::diffie_hellman(kp1.public().clone(), kp2.private().clone()); + let dh2 = X25519KeyPair::diffie_hellman(kp2.public().clone(), kp1.private().clone()); + + prop_assert_eq!(dh1,dh2); + } } }