/* * Zero Memory * (C) 2012 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ #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 } }