aboutsummaryrefslogtreecommitdiff
path: root/src/memory.cpp
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-02-27 16:11:30 +0000
committerMark Haines <mark.haines@matrix.org>2015-02-27 16:11:30 +0000
commitc7419e7cdffc8c8d54dd918b03ed2c497fe7ca42 (patch)
tree6fd1bf8666863e36ab4729ec0f1ca8438e88e745 /src/memory.cpp
parentb3496b0aa16b8c4f9974ed54fca59ef631f83705 (diff)
Try to ensure the compiler cannot optimise away attempts to erase secrets from memory
Diffstat (limited to 'src/memory.cpp')
-rw-r--r--src/memory.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/memory.cpp b/src/memory.cpp
new file mode 100644
index 0000000..14c95dd
--- /dev/null
+++ b/src/memory.cpp
@@ -0,0 +1,11 @@
+#include "axolotl/memory.hh"
+
+void axolotl::unset(
+ volatile void * buffer, std::size_t buffer_length
+) {
+ volatile char * pos = reinterpret_cast<volatile char *>(buffer);
+ volatile char * end = pos + buffer_length;
+ while (pos != end) {
+ *(pos++) = 0;
+ }
+}