blob: d8c4384353eb5b0ea17a917d429c6ce7bccb42d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/*
* Zero Memory
* (C) 2012 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#include <botan/mem_ops.h>
#if defined(BOTAN_TARGET_OS_HAS_RTLSECUREZEROMEMORY)
#include <windows.h>
#elif defined(BOTAN_TARGET_OS_HAS_MEMSET_S)
#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>
#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<volatile byte*>(ptr);
for(size_t i = 0; i != n; ++i)
p[i] = 0;
#endif
}
}
|