MCPcopy Create free account
hub / github.com/LUX-Core/lux / SetKeyFromPassphrase

Method SetKeyFromPassphrase

src/crypter.cpp:18–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#include <vector>
17
18bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::vector<unsigned char>& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod)
19{
20 if (nRounds < 1 || chSalt.size() != WALLET_CRYPTO_SALT_SIZE)
21 return false;
22
23 int i = 0;
24 if (nDerivationMethod == 0)
25 i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha512(), &chSalt[0],
26 (unsigned char*)&strKeyData[0], strKeyData.size(), nRounds, chKey, chIV);
27
28 if (i != (int)WALLET_CRYPTO_KEY_SIZE) {
29 memory_cleanse(chKey, sizeof(chKey));
30 memory_cleanse(chIV, sizeof(chIV));
31 return false;
32 }
33
34 fKeySet = true;
35 return true;
36}
37
38bool CCrypter::SetKey(const CKeyingMaterial& chNewKey, const std::vector<unsigned char>& chNewIV)
39{

Callers 3

UnlockMethod · 0.80
EncryptWalletMethod · 0.80

Calls 2

memory_cleanseFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected