From 7193b89fe567327bb78f4c61c887b2e2fad2ed51 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 26 Oct 2017 10:21:06 +0100 Subject: Scrub keys from memory just before scope end. Partially implements #74. Securely erases keys from memory after they are no longer needed. Might have a performance impact, which I haven't measured (perf measurements aren't generally reliable on laptops). Thanks to @stoffu for the suggestion to specialize the pod_to_hex/hex_to_pod functions. Using overloads + SFINAE instead generalizes it so other types can be marked as scrubbed without adding more boilerplate. --- src/crypto/crypto.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/crypto/crypto.h') diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h index abdea0165..0ce5e6d7a 100644 --- a/src/crypto/crypto.h +++ b/src/crypto/crypto.h @@ -36,9 +36,12 @@ #include #include #include +#include #include #include "common/pod-class.h" +#include "common/util.h" +#include "common/memwipe.h" #include "generic-ops.h" #include "hex.h" #include "span.h" @@ -65,9 +68,7 @@ namespace crypto { friend class crypto_ops; }; - POD_CLASS secret_key: ec_scalar { - friend class crypto_ops; - }; + using secret_key = tools::scrubbed; POD_CLASS public_keyV { std::vector keys; -- cgit v1.2.3