MCPcopy Create free account
hub / github.com/ElementsProject/elements / SetKeyFromPassphrase

Method SetKeyFromPassphrase

src/wallet/crypter.cpp:40–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::vector<unsigned char>& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod)
41{
42 if (nRounds < 1 || chSalt.size() != WALLET_CRYPTO_SALT_SIZE)
43 return false;
44
45 int i = 0;
46 if (nDerivationMethod == 0)
47 i = BytesToKeySHA512AES(chSalt, strKeyData, nRounds, vchKey.data(), vchIV.data());
48
49 if (i != (int)WALLET_CRYPTO_KEY_SIZE)
50 {
51 memory_cleanse(vchKey.data(), vchKey.size());
52 memory_cleanse(vchIV.data(), vchIV.size());
53 return false;
54 }
55
56 fKeySet = true;
57 return true;
58}
59
60bool CCrypter::SetKey(const CKeyingMaterial& chNewKey, const std::vector<unsigned char>& chNewIV)
61{

Callers 5

UnlockMethod · 0.80
EncryptWalletMethod · 0.80
TestPassphraseSingleMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 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