summaryrefslogtreecommitdiff
path: root/sysdep/linux
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2019-02-22 23:02:41 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2019-02-28 00:46:04 +0100
commite673eba119a1cdeaa6bfc69f954dc2ccfb521f63 (patch)
treec588bb8cb741644e71451f9f13322b3a7a7862bf /sysdep/linux
parent5f88b81612952029e4b1f08f64f62fb4cbf618c1 (diff)
wireguard: update libraryold/wireguard-upstream
Diffstat (limited to 'sysdep/linux')
-rw-r--r--sysdep/linux/wireguard.c8
-rw-r--r--sysdep/linux/wireguard.h10
2 files changed, 12 insertions, 6 deletions
diff --git a/sysdep/linux/wireguard.c b/sysdep/linux/wireguard.c
index 370b3dae..51da8ece 100644
--- a/sysdep/linux/wireguard.c
+++ b/sysdep/linux/wireguard.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1+
/*
- * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
+ * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
* Copyright (C) 2008-2012 Pablo Neira Ayuso <pablo@netfilter.org>.
*/
@@ -1688,7 +1688,7 @@ static void invert(fe o, const fe i)
memzero_explicit(c, sizeof(c));
}
-static void normalize_key(uint8_t *z)
+static void clamp_key(uint8_t *z)
{
z[31] = (z[31] & 127) | 64;
z[0] &= 248;
@@ -1701,7 +1701,7 @@ void wg_generate_public_key(wg_key public_key, const wg_key private_key)
fe a = { 1 }, b = { 9 }, c = { 0 }, d = { 1 }, e, f;
memcpy(z, private_key, sizeof(z));
- normalize_key(z);
+ clamp_key(z);
for (i = 254; i >= 0; --i) {
r = (z[i >> 3] >> (i & 7)) & 1;
@@ -1745,7 +1745,7 @@ void wg_generate_public_key(wg_key public_key, const wg_key private_key)
void wg_generate_private_key(wg_key private_key)
{
wg_generate_preshared_key(private_key);
- normalize_key(private_key);
+ clamp_key(private_key);
}
void wg_generate_preshared_key(wg_key preshared_key)
diff --git a/sysdep/linux/wireguard.h b/sysdep/linux/wireguard.h
index e9210a41..e7a1bbf0 100644
--- a/sysdep/linux/wireguard.h
+++ b/sysdep/linux/wireguard.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
/*
- * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
+ * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
*/
#ifndef WIREGUARD_H
@@ -16,6 +16,12 @@
typedef uint8_t wg_key[32];
typedef char wg_key_b64_string[((sizeof(wg_key) + 2) / 3) * 4 + 1];
+/* Cross platform __kernel_timespec */
+struct timespec64 {
+ int64_t tv_sec;
+ int64_t tv_nsec;
+};
+
typedef struct wg_allowedip {
uint16_t family;
union {
@@ -46,7 +52,7 @@ typedef struct wg_peer {
struct sockaddr_in6 addr6;
} endpoint;
- struct timespec last_handshake_time;
+ struct timespec64 last_handshake_time;
uint64_t rx_bytes, tx_bytes;
uint16_t persistent_keepalive_interval;