Merge pull request #2860

3dffe71b new wipeable_string class to replace std::string passphrases (moneromooo-monero)
7a2a5741 utils: initialize easylogging++ in on_startup (moneromooo-monero)
54950829 use memwipe in a few relevant places (moneromooo-monero)
000666ff add a memwipe function (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2017-12-16 23:19:27 +02:00
commit 6c0953b15a
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
22 changed files with 528 additions and 69 deletions

View file

@ -32,6 +32,7 @@
using namespace epee;
#include <atomic>
#include "wipeable_string.h"
#include "cryptonote_format_utils.h"
#include "cryptonote_config.h"
#include "crypto/crypto.h"
@ -994,7 +995,7 @@ namespace cryptonote
block_hashes_cached = block_hashes_cached_count;
}
//---------------------------------------------------------------
crypto::secret_key encrypt_key(crypto::secret_key key, const std::string &passphrase)
crypto::secret_key encrypt_key(crypto::secret_key key, const epee::wipeable_string &passphrase)
{
crypto::hash hash;
crypto::cn_slow_hash(passphrase.data(), passphrase.size(), hash);
@ -1002,7 +1003,7 @@ namespace cryptonote
return key;
}
//---------------------------------------------------------------
crypto::secret_key decrypt_key(crypto::secret_key key, const std::string &passphrase)
crypto::secret_key decrypt_key(crypto::secret_key key, const epee::wipeable_string &passphrase)
{
crypto::hash hash;
crypto::cn_slow_hash(passphrase.data(), passphrase.size(), hash);

View file

@ -38,6 +38,11 @@
#include "crypto/hash.h"
#include <unordered_map>
namespace epee
{
class wipeable_string;
}
namespace cryptonote
{
//---------------------------------------------------------------
@ -226,8 +231,8 @@ namespace cryptonote
bool is_valid_decomposed_amount(uint64_t amount);
void get_hash_stats(uint64_t &tx_hashes_calculated, uint64_t &tx_hashes_cached, uint64_t &block_hashes_calculated, uint64_t & block_hashes_cached);
crypto::secret_key encrypt_key(crypto::secret_key key, const std::string &passphrase);
crypto::secret_key decrypt_key(crypto::secret_key key, const std::string &passphrase);
crypto::secret_key encrypt_key(crypto::secret_key key, const epee::wipeable_string &passphrase);
crypto::secret_key decrypt_key(crypto::secret_key key, const epee::wipeable_string &passphrase);
#define CHECKED_GET_SPECIFIC_VARIANT(variant_var, specific_type, variable_name, fail_return_val) \
CHECK_AND_ASSERT_MES(variant_var.type() == typeid(specific_type), fail_return_val, "wrong variant type: " << variant_var.type().name() << ", expected " << typeid(specific_type).name()); \
specific_type& variable_name = boost::get<specific_type>(variant_var);