]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commitdiff
wincompat: fold random into genkey
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 26 May 2020 00:05:14 +0000 (18:05 -0600)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 26 May 2020 00:07:49 +0000 (18:07 -0600)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
src/genkey.c
src/wincompat/compat.h
src/wincompat/getrandom.c [deleted file]
src/wincompat/include/sys/ioctl.h [deleted file]
src/wincompat/include/sys/un.h [deleted file]

index d1bb643e427103fa87acc07ef348e1a4740bae49..ef7770bd8d41708184a03668e11e971f49a1b17f 100644 (file)
@@ -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[])
index 5decc6686eb59e0ae3c13b94cf1584899a1bd868..643c11d1d7c0809b210e243e35199ca8fbe8e38b 100644 (file)
@@ -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 (file)
index b064b04..0000000
+++ /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 (file)
index e69de29..0000000
diff --git a/src/wincompat/include/sys/un.h b/src/wincompat/include/sys/un.h
deleted file mode 100644 (file)
index e69de29..0000000