Enable wireguard-rs to build on stable.

WireGuard Rust targets the latest nightly compiler,
primarily for security and speed reasons.

The recommended way to build WireGuard Rust is still with latest nightly.
This commit is contained in:
Mathias Hall-Andersen
2020-05-22 18:01:15 +02:00
parent 16f21989b4
commit 16ede0f37d
6 changed files with 207 additions and 174 deletions

View File

@@ -1,5 +1,4 @@
#![feature(test)]
#![feature(weak_into_raw)]
#![cfg_attr(feature = "unstable", feature(test))]
extern crate alloc;

View File

@@ -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);
}

View File

@@ -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

View File

@@ -11,6 +11,7 @@ use rand::Rng;
use super::*;
#[cfg(feature = "unstable")]
extern crate test;
const SIZE_MSG: usize = 1024;