[core] SecureZeroMemory() on _WIN32
#include <string.h>
-#if !defined(HAVE_MEMSET_S) && !defined(HAVE_EXPLICIT_BZERO) && !defined(HAVE_EXPLICIT_MEMSET)
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include <WinBase.h>
+/*(Windows XP and later provide SecureZeroMemory())*/
+#define HAVE_SECUREZEROMEMORY
+#endif
+
+#if !defined(HAVE_MEMSET_S) \
+ && !defined(HAVE_EXPLICIT_BZERO) \
+ && !defined(HAVE_EXPLICIT_MEMSET) \
+ && !defined(HAVE_SECUREZEROMEMORY)
# if defined(HAVE_WEAK_SYMBOLS)
/* it seems weak functions are never inlined, even for static builds */
@@ -33,7 +42,8 @@ static void* safe_memset(void *s, int c, size_t n)
return s;
}
-#endif /* !defined(HAVE_MEMSET_S) && !defined(HAVE_EXPLICIT_BZERO) */
+
+#endif
void safe_memclear(void *s, size_t n) {
@@ -43,6 +53,8 @@ void safe_memclear(void *s, size_t n) {
explicit_bzero(s, n);
#elif defined(HAVE_EXPLICIT_MEMSET)
explicit_memset(s, 0, n);
+#elif defined(HAVE_SECUREZEROMEMORY)
+ SecureZeroMemory(s, n);
#else
safe_memset(s, 0, n);
#endif
