diff --git a/library/entropy_poll.c b/library/entropy_poll.c index b5024c83fa..f90167ca82 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 +#if _WIN32_WINNT >= 0x0501 /* _WIN32_WINNT_WINXP */ #include int mbedtls_platform_entropy_poll(void *data, unsigned char *output, size_t len, @@ -76,6 +74,9 @@ int mbedtls_platform_entropy_poll(void *data, unsigned char *output, size_t len, 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 147bc1a371..db80447a31 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 #include diff --git a/library/x509_crt.c b/library/x509_crt.c index b3bcdaf669..30e9668b24 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 #else #include @@ -1539,6 +1536,7 @@ int mbedtls_x509_crt_parse_path(mbedtls_x509_crt *chain, const char *path) { 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 @@ int mbedtls_x509_crt_parse_path(mbedtls_x509_crt *chain, const char *path) 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 @@ find_parent: #elif (defined(__MINGW32__) || defined(__MINGW64__)) && _WIN32_WINNT >= 0x0600 #include #include +#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() */