5 #ifndef BITCOIN_WALLET_CRYPTER_H 6 #define BITCOIN_WALLET_CRYPTER_H 49 template <
typename Stream,
typename Operation>
68 typedef std::vector<unsigned char, secure_allocator<unsigned char> >
CKeyingMaterial;
80 std::vector<unsigned char, secure_allocator<unsigned char>>
vchKey;
81 std::vector<unsigned char, secure_allocator<unsigned char>>
vchIV;
84 int BytesToKeySHA512AES(
const std::vector<unsigned char>& chSalt,
const SecureString& strKeyData,
int count,
unsigned char *key,
unsigned char *iv)
const;
87 bool SetKeyFromPassphrase(
const SecureString &strKeyData,
const std::vector<unsigned char>& chSalt,
const unsigned int nRounds,
const unsigned int nDerivationMethod);
129 using CryptedKeyMap = std::map<CKeyID, std::pair<CPubKey, std::vector<unsigned char>>>;
148 virtual bool AddCryptedKey(
const CPubKey &vchPubKey,
const std::vector<unsigned char> &vchCryptedSecret);
153 std::set<CKeyID>
GetKeys()
const override;
162 #endif // BITCOIN_WALLET_CRYPTER_H
bool SetKeyFromPassphrase(const SecureString &strKeyData, const std::vector< unsigned char > &chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod)
unsigned int nDerivationMethod
0 = EVP_sha512() 1 = scrypt()
bool HaveKey(const CKeyID &address) const override
Check whether a key corresponding to a given address is present in the store.
const unsigned int WALLET_CRYPTO_KEY_SIZE
bool Encrypt(const CKeyingMaterial &vchPlaintext, std::vector< unsigned char > &vchCiphertext) const
bool SetKey(const CKeyingMaterial &chNewKey, const std::vector< unsigned char > &chNewIV)
Encryption/decryption context with key information.
std::vector< unsigned char > vchCryptedKey
CCriticalSection cs_KeyStore
Private key encryption is done based on a CMasterKey, which holds a salt and random encryption key...
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
std::vector< unsigned char > vchOtherDerivationParameters
Use this for more parameters to key derivation, such as the various parameters to scrypt...
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
bool EncryptKeys(CKeyingMaterial &vMasterKeyIn)
will encrypt previously unencrypted keys
int BytesToKeySHA512AES(const std::vector< unsigned char > &chSalt, const SecureString &strKeyData, int count, unsigned char *key, unsigned char *iv) const
std::atomic< bool > fUseCrypto
if fUseCrypto is true, mapKeys must be empty if fUseCrypto is false, vMasterKey must be empty ...
bool Decrypt(const std::vector< unsigned char > &vchCiphertext, CKeyingMaterial &vchPlaintext) const
const unsigned int WALLET_CRYPTO_IV_SIZE
virtual bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret)
friend class wallet_crypto_tests::TestCrypter
Keystore which keeps the private keys encrypted.
CKeyingMaterial vMasterKey GUARDED_BY(cs_KeyStore)
std::map< CKeyID, std::pair< CPubKey, std::vector< unsigned char > >> CryptedKeyMap
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override
Add a key to the store.
boost::signals2::signal< void(CCryptoKeyStore *wallet)> NotifyStatusChanged
Wallet status (encrypted, locked) changed.
void memory_cleanse(void *ptr, size_t len)
std::vector< unsigned char, secure_allocator< unsigned char > > vchKey
std::vector< unsigned char, secure_allocator< unsigned char > > vchIV
An encapsulated public key.
bool Unlock(const CKeyingMaterial &vMasterKeyIn)
bool GetKey(const CKeyID &address, CKey &keyOut) const override
const unsigned int WALLET_CRYPTO_SALT_SIZE
void SerializationOp(Stream &s, Operation ser_action)
A reference to a CKey: the Hash360 of its serialized public key.
std::vector< unsigned char > vchSalt
An encapsulated private key.
unsigned int nDeriveIterations
std::set< CKeyID > GetKeys() const override
bool fDecryptionThoroughlyChecked
keeps track of whether Unlock has run a thorough check before
Basic key store, that keeps keys in an address->secret map.