aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-05-25 18:05:14 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2020-05-25 18:07:49 -0600
commiteb4665ecf082033d986c64453e2becce19bc7af7 (patch)
treea105defb5f8849d5d12f330eaec0ccc3d59a1fb5
parentipc: split into separate files per-platform (diff)
downloadwireguard-tools-eb4665ecf082033d986c64453e2becce19bc7af7.tar.xz
wireguard-tools-eb4665ecf082033d986c64453e2becce19bc7af7.zip
wincompat: fold random into genkey
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--src/genkey.c8
-rw-r--r--src/wincompat/compat.h2
-rw-r--r--src/wincompat/getrandom.c12
-rw-r--r--src/wincompat/include/sys/ioctl.h0
-rw-r--r--src/wincompat/include/sys/un.h0
5 files changed, 6 insertions, 16 deletions
diff --git a/src/genkey.c b/src/genkey.c
index d1bb643..ef7770b 100644
--- a/src/genkey.c
+++ b/src/genkey.c
@@ -28,7 +28,7 @@
#include "encoding.h"
#include "subcommands.h"
-#ifndef WINCOMPAT
+#ifndef _WIN32
static inline bool __attribute__((__warn_unused_result__)) get_random_bytes(uint8_t *out, size_t len)
{
ssize_t ret = 0;
@@ -65,7 +65,11 @@ static inline bool __attribute__((__warn_unused_result__)) get_random_bytes(uint
return i == len;
}
#else
-#include "wincompat/getrandom.c"
+#include <ntsecapi.h>
+static inline bool __attribute__((__warn_unused_result__)) get_random_bytes(uint8_t *out, size_t len)
+{
+ return RtlGenRandom(out, len);
+}
#endif
int genkey_main(int argc, char *argv[])
diff --git a/src/wincompat/compat.h b/src/wincompat/compat.h
index 5decc66..643c11d 100644
--- a/src/wincompat/compat.h
+++ b/src/wincompat/compat.h
@@ -18,8 +18,6 @@
#undef min
#undef max
-#define WINCOMPAT
-
#define IFNAMSIZ 64
#define EAI_SYSTEM -99
diff --git a/src/wincompat/getrandom.c b/src/wincompat/getrandom.c
deleted file mode 100644
index b064b04..0000000
--- a/src/wincompat/getrandom.c
+++ /dev/null
@@ -1,12 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2015-2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
- */
-
-#include <stdbool.h>
-#include <ntsecapi.h>
-
-static inline bool __attribute__((__warn_unused_result__)) get_random_bytes(uint8_t *out, size_t len)
-{
- return RtlGenRandom(out, len);
-}
diff --git a/src/wincompat/include/sys/ioctl.h b/src/wincompat/include/sys/ioctl.h
deleted file mode 100644
index e69de29..0000000
--- a/src/wincompat/include/sys/ioctl.h
+++ /dev/null
diff --git a/src/wincompat/include/sys/un.h b/src/wincompat/include/sys/un.h
deleted file mode 100644
index e69de29..0000000
--- a/src/wincompat/include/sys/un.h
+++ /dev/null