Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion depends/packages/bdb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ define $(package)_set_vars
$(package)_config_opts=--disable-shared --enable-cxx --disable-replication
$(package)_config_opts_mingw32=--enable-mingw
$(package)_config_opts_linux=--with-pic

$(package)_cxxflags=-std=c++11
$(package)_cxxflags_darwin=$(shell command -v xcrun >/dev/null 2>&1 && echo "-isysroot$$(xcrun --show-sdk-path)")
$(package)_cflags_darwin=$(shell command -v xcrun >/dev/null 2>&1 && echo "-isysroot$$(xcrun --show-sdk-path)")
Expand Down
2 changes: 2 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-experimentalfeatures", _("Enable use of experimental features"));
strUsage += HelpMessageOpt("-help-debug", _("Show all debugging options (usage: --help -help-debug)"));
strUsage += HelpMessageOpt("-logips", strprintf(_("Include IP addresses in debug output (default: %u)"), 0));
strUsage += HelpMessageOpt("-debuglogfile", _("Write debug output to debug.log file (default: 0, disabled for privacy)"));
strUsage += HelpMessageOpt("-logtimestamps", strprintf(_("Prepend debug output with timestamp (default: %u)"), 1));
if (showDebug)
{
Expand Down Expand Up @@ -14486,6 +14487,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// Set this early so that parameter interactions go to console
fPrintToConsole = GetBoolArg("-printtoconsole", false);
fLogTimestamps = GetBoolArg("-logtimestamps", true);
fPrintToDebugLog = GetBoolArg("-debuglogfile", false);
fLogIPs = GetBoolArg("-logips", false);

LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
Expand Down
35 changes: 35 additions & 0 deletions src/keystore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,38 @@ bool CBasicKeyStore::GetSaplingExtendedSpendingKey(const libzcash::SaplingPaymen
GetSaplingFullViewingKey(ivk, fvk) &&
GetSaplingSpendingKey(fvk, extskOut);
}

void CBasicKeyStore::CleanupKeys()
{
LOCK2(cs_KeyStore, cs_SpendingKeyStore);

// Clear HD seed securely
hdSeed = HDSeed();

// Clear all keys - CKey destructor will securely wipe key material
mapKeys.clear();

// Clear scripts
mapScripts.clear();

// Clear watch-only set
setWatchOnly.clear();

// Clear Sprout spending keys
mapSproutSpendingKeys.clear();

// Clear Sprout viewing keys
mapSproutViewingKeys.clear();

// Clear note decryptors
mapNoteDecryptors.clear();

// Clear Sapling spending keys
mapSaplingSpendingKeys.clear();

// Clear Sapling full viewing keys
mapSaplingFullViewingKeys.clear();

// Clear Sapling incoming viewing keys
mapSaplingIncomingViewingKeys.clear();
}
6 changes: 6 additions & 0 deletions src/keystore.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class CKeyStore
virtual bool GetSproutViewingKey(
const libzcash::SproutPaymentAddress &address,
libzcash::SproutViewingKey& vkOut) const =0;

//! Securely wipe all keys from memory
virtual void CleanupKeys() =0;
};

typedef std::map<CKeyID, CKey> KeyMap;
Expand Down Expand Up @@ -304,6 +307,9 @@ class CBasicKeyStore : public CKeyStore
virtual bool GetSproutViewingKey(
const libzcash::SproutPaymentAddress &address,
libzcash::SproutViewingKey& vkOut) const;

//! Securely wipe all keys from memory
void CleanupKeys();
};

typedef std::vector<unsigned char, secure_allocator<unsigned char> > CKeyingMaterial;
Expand Down
2 changes: 1 addition & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ map<string, string> mapArgs;
map<string, vector<string> > mapMultiArgs;
bool fDebug = false;
bool fPrintToConsole = false;
bool fPrintToDebugLog = true;
bool fPrintToDebugLog = false;
bool fDaemon = false;
bool fServer = false;
string strMiscWarning;
Expand Down
51 changes: 51 additions & 0 deletions src/wallet/crypter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "script/script.h"
#include "script/standard.h"
#include "streams.h"
#include "support/cleanse.h"
#include "util.h"

#include <string>
Expand Down Expand Up @@ -548,6 +549,56 @@ bool CCryptoKeyStore::GetSaplingSpendingKey(const libzcash::SaplingFullViewingKe
return false;
}

void CCryptoKeyStore::CleanupKeys()
{
{
LOCK2(cs_KeyStore, cs_SpendingKeyStore);

// Securely wipe the master key
if (!vMasterKey.empty()) {
memory_cleanse(vMasterKey.data(), vMasterKey.size());
vMasterKey.clear();
}

// Clear crypted HD seed
if (!cryptedHDSeed.second.empty()) {
memory_cleanse(cryptedHDSeed.second.data(), cryptedHDSeed.second.size());
cryptedHDSeed.second.clear();
}
cryptedHDSeed.first.SetNull();

// Clear crypted keys (securely wipe and explicitly clear)
for (auto& entry : mapCryptedKeys) {
if (!entry.second.second.empty()) {
memory_cleanse(entry.second.second.data(), entry.second.second.size());
entry.second.second.clear();
}
}
mapCryptedKeys.clear();

// Clear crypted Sprout spending keys
for (auto& entry : mapCryptedSproutSpendingKeys) {
if (!entry.second.empty()) {
memory_cleanse(entry.second.data(), entry.second.size());
entry.second.clear();
}
}
mapCryptedSproutSpendingKeys.clear();

// Clear crypted Sapling spending keys
for (auto& entry : mapCryptedSaplingSpendingKeys) {
if (!entry.second.empty()) {
memory_cleanse(entry.second.data(), entry.second.size());
entry.second.clear();
}
}
mapCryptedSaplingSpendingKeys.clear();
}

// Call base class cleanup
CBasicKeyStore::CleanupKeys();
}

bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
{
{
Expand Down
3 changes: 3 additions & 0 deletions src/wallet/crypter.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ class CCryptoKeyStore : public CBasicKeyStore
}
bool GetSaplingSpendingKey(const libzcash::SaplingFullViewingKey &fvk, libzcash::SaplingExtendedSpendingKey &skOut) const;

//! Securely wipe all keys from memory (override base class)
void CleanupKeys();


/**
* Wallet status (encrypted, locked) changed.
Expand Down
Loading
Loading