From 5fd3c7adffa9fe705e493f81def04d9d57db4442 Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 7 Jan 2015 12:59:33 +0000 Subject: Use RtlSecureZeroMemory or memset_s if available --- src/lib/utils/zero_mem.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/lib') diff --git a/src/lib/utils/zero_mem.cpp b/src/lib/utils/zero_mem.cpp index e812ced0c..833b54aca 100644 --- a/src/lib/utils/zero_mem.cpp +++ b/src/lib/utils/zero_mem.cpp @@ -7,14 +7,27 @@ #include +#if defined(BOTAN_TARGET_OS_HAS_RTLSECUREZEROMEMORY) + #include +#elif defined(BOTAN_TARGET_OS_HAS_MEMSET_S) + #define __STDC_WANT_LIB_EXT1__ 1 + #include +#endif + namespace Botan { void zero_mem(void* ptr, size_t n) { +#if defined(BOTAN_TARGET_OS_HAS_RTLSECUREZEROMEMORY) + ::RtlSecureZeroMemory(ptr, n); +#elif defined(BOTAN_TARGET_OS_HAS_MEMSET_S) + ::memset_s(ptr, n, 0, n); +#else volatile byte* p = reinterpret_cast(ptr); for(size_t i = 0; i != n; ++i) p[i] = 0; +#endif } } -- cgit v1.2.3