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

Method SetKeyFromPassphrase

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

Source from the content-addressed store, hash-verified

15#include <openssl/evp.h>
16
17bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::vector<unsigned char>& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod)
18{
19 if (nRounds < 1 || chSalt.size() != WALLET_CRYPTO_SALT_SIZE)
20 return false;
21
22 int i = 0;
23 if (nDerivationMethod == 0)
24 i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha512(), &chSalt[0],
25 (unsigned char *)&strKeyData[0], strKeyData.size(), nRounds, chKey, chIV);
26
27 if (i != (int)WALLET_CRYPTO_KEY_SIZE)
28 {
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 2

BOOST_FOREACHFunction · 0.80
EncryptWalletMethod · 0.80

Calls 2

memory_cleanseFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected