diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-10-26 10:21:06 +0100 |
---|---|---|
committer | Jonathan Roelofs <jonathan@codesourcery.com> | 2017-12-16 15:40:33 -0700 |
commit | 7193b89fe567327bb78f4c61c887b2e2fad2ed51 (patch) | |
tree | c3064389fdc8d4a07b78882bc77cf475cb4e8d9d /src/crypto/crypto.h | |
parent | Merge pull request #2881 (diff) | |
download | monero-7193b89fe567327bb78f4c61c887b2e2fad2ed51.tar.xz |
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.
Diffstat (limited to 'src/crypto/crypto.h')
-rw-r--r-- | src/crypto/crypto.h | 7 |
1 files changed, 4 insertions, 3 deletions
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 <boost/thread/lock_guard.hpp> #include <boost/utility/value_init.hpp> #include <boost/optional.hpp> +#include <type_traits> #include <vector> #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<ec_scalar>; POD_CLASS public_keyV { std::vector<public_key> keys; |