MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / SetKeyFromPassphrase

Method SetKeyFromPassphrase

src/wallet/crypter.cpp:41–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41bool CCrypter::SetKeyFromPassphrase(const SecureString& key_data, const std::span<const unsigned char> salt, const unsigned int rounds, const unsigned int derivation_method)
42{
43 if (rounds < 1 || salt.size() != WALLET_CRYPTO_SALT_SIZE) {
44 return false;
45 }
46
47 int i = 0;
48 if (derivation_method == 0) {
49 i = BytesToKeySHA512AES(salt, key_data, rounds, vchKey.data(), vchIV.data());
50 }
51
52 if (i != (int)WALLET_CRYPTO_KEY_SIZE)
53 {
54 memory_cleanse(vchKey.data(), vchKey.size());
55 memory_cleanse(vchIV.data(), vchIV.size());
56 return false;
57 }
58
59 fKeySet = true;
60 return true;
61}
62
63bool CCrypter::SetKey(const CKeyingMaterial& new_key, const std::span<const unsigned char> new_iv)
64{

Callers 5

EncryptMasterKeyFunction · 0.80
DecryptMasterKeyFunction · 0.80
TestPassphraseSingleMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
crypter.cppFile · 0.80

Calls 3

memory_cleanseFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45

Tested by 2

TestPassphraseSingleMethod · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64