From c7419e7cdffc8c8d54dd918b03ed2c497fe7ca42 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Fri, 27 Feb 2015 16:11:30 +0000 Subject: Try to ensure the compiler cannot optimise away attempts to erase secrets from memory --- include/axolotl/memory.hh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 include/axolotl/memory.hh (limited to 'include/axolotl/memory.hh') diff --git a/include/axolotl/memory.hh b/include/axolotl/memory.hh new file mode 100644 index 0000000..7749c54 --- /dev/null +++ b/include/axolotl/memory.hh @@ -0,0 +1,17 @@ +#include + +namespace axolotl { + +/** Clear the memory held in the buffer */ +void unset( + volatile void * buffer, std::size_t buffer_length +); + +/** Clear the memory backing an object */ +template +void unset(T & value) { + unset(reinterpret_cast(&value), sizeof(T)); +} + + +} // namespace axolotl -- cgit v1.2.3