Merge pull request #7792 from robUx4/win32_winnt
diff --git a/library/entropy_poll.c b/library/entropy_poll.c
index b5024c8..f90167c 100644
--- a/library/entropy_poll.c
+++ b/library/entropy_poll.c
@@ -48,10 +48,8 @@
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
-#if !defined(_WIN32_WINNT)
-#define _WIN32_WINNT 0x0400
-#endif
#include <windows.h>
+#if _WIN32_WINNT >= 0x0501 /* _WIN32_WINNT_WINXP */
#include <wincrypt.h>
int mbedtls_platform_entropy_poll(void *data, unsigned char *output, size_t len,
@@ -76,6 +74,9 @@
return 0;
}
+#else /* !_WIN32_WINNT_WINXP */
+#error Entropy not available before Windows XP, use MBEDTLS_NO_PLATFORM_ENTROPY
+#endif /* !_WIN32_WINNT_WINXP */
#else /* _WIN32 && !EFIX64 && !EFI32 */
/*
diff --git a/library/net_sockets.c b/library/net_sockets.c
index 147bc1a..db80447 100644
--- a/library/net_sockets.c
+++ b/library/net_sockets.c
@@ -49,11 +49,6 @@
#define IS_EINTR(ret) ((ret) == WSAEINTR)
-#if !defined(_WIN32_WINNT)
-/* Enables getaddrinfo() & Co */
-#define _WIN32_WINNT 0x0501
-#endif
-
#include <ws2tcpip.h>
#include <winsock2.h>
diff --git a/library/x509_crt.c b/library/x509_crt.c
index b3bcdaf..30e9668 100644
--- a/library/x509_crt.c
+++ b/library/x509_crt.c
@@ -60,9 +60,6 @@
#if defined(MBEDTLS_HAVE_TIME)
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
#define WIN32_LEAN_AND_MEAN
-#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0600
-#endif
#include <windows.h>
#else
#include <time.h>
@@ -1539,6 +1536,7 @@
{
int ret = 0;
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
+#if _WIN32_WINNT >= 0x0501 /* _WIN32_WINNT_XP */
int w_ret;
WCHAR szDir[MAX_PATH];
char filename[MAX_PATH];
@@ -1601,6 +1599,9 @@
cleanup:
FindClose(hFind);
+#else /* !_WIN32_WINNT_XP */
+#error mbedtls_x509_crt_parse_path not available before Windows XP
+#endif /* !_WIN32_WINNT_XP */
#else /* _WIN32 */
int t_ret;
int snp_ret;
@@ -2704,6 +2705,9 @@
#elif (defined(__MINGW32__) || defined(__MINGW64__)) && _WIN32_WINNT >= 0x0600
#include <winsock2.h>
#include <ws2tcpip.h>
+#else
+/* inet_pton() is not supported, fallback to software version */
+#define MBEDTLS_TEST_SW_INET_PTON
#endif
#elif defined(__sun)
/* Solaris requires -lsocket -lnsl for inet_pton() */