aboutsummaryrefslogtreecommitdiffstats
path: root/src/wireguard
diff options
context:
space:
mode:
Diffstat (limited to 'src/wireguard')
-rw-r--r--src/wireguard/handshake/noise.rs7
-rw-r--r--src/wireguard/router/tests/bench.rs11
-rw-r--r--src/wireguard/router/tests/tests.rs1
3 files changed, 14 insertions, 5 deletions
diff --git a/src/wireguard/handshake/noise.rs b/src/wireguard/handshake/noise.rs
index beb99c2..4141cb9 100644
--- a/src/wireguard/handshake/noise.rs
+++ b/src/wireguard/handshake/noise.rs
@@ -1,7 +1,7 @@
use std::time::Instant;
// DH
-use x25519_dalek::{PublicKey, StaticSecret, SharedSecret};
+use x25519_dalek::{PublicKey, SharedSecret, StaticSecret};
// HASH & MAC
use blake2::Blake2s;
@@ -215,7 +215,7 @@ mod tests {
}
// Computes an X25519 shared secret.
-//
+//
// This function wraps dalek to add a zero-check.
// This is not recommended by the Noise specification,
// but implemented in the kernel with which we strive for absolute equivalent behavior.
@@ -290,7 +290,6 @@ pub(super) fn create_initiation<R: RngCore + CryptoRng, O>(
// (C, k) := Kdf2(C, DH(S_priv, S_pub))
-
let (ck, key) = KDF2!(&ck, &peer.ss);
// msg.timestamp := Aead(k, 0, Timestamp(), H)
@@ -360,7 +359,7 @@ pub(super) fn consume_initiation<'a, O>(
let peer = device.lookup_pk(&PublicKey::from(pk))?;
// check for zero shared-secret (see "shared_secret" note).
-
+
if peer.ss.ct_eq(&[0u8; 32]).into() {
return Err(HandshakeError::InvalidSharedSecret);
}
diff --git a/src/wireguard/router/tests/bench.rs b/src/wireguard/router/tests/bench.rs
index f025dc9..948a156 100644
--- a/src/wireguard/router/tests/bench.rs
+++ b/src/wireguard/router/tests/bench.rs
@@ -1,13 +1,21 @@
+#[cfg(feature = "unstable")]
extern crate test;
use super::*;
-use std::net::IpAddr;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::sync::Arc;
+// only used in benchmark
+#[cfg(feature = "unstable")]
+use std::net::IpAddr;
+
+// only used in benchmark
+#[cfg(feature = "unstable")]
use num_cpus;
+
+#[cfg(feature = "unstable")]
use test::Bencher;
//
@@ -78,6 +86,7 @@ fn profiler_start(name: &str) {
}
}
+#[cfg(feature = "unstable")]
#[bench]
fn bench_router_outbound(b: &mut Bencher) {
// 10 GB transmission per iteration
diff --git a/src/wireguard/router/tests/tests.rs b/src/wireguard/router/tests/tests.rs
index 6819644..f6205d5 100644
--- a/src/wireguard/router/tests/tests.rs
+++ b/src/wireguard/router/tests/tests.rs
@@ -11,6 +11,7 @@ use rand::Rng;
use super::*;
+#[cfg(feature = "unstable")]
extern crate test;
const SIZE_MSG: usize = 1024;