6 #ifndef RAVEN_WALLET_CRYPTER_H 7 #define RAVEN_WALLET_CRYPTER_H 50 template <
typename Stream,
typename Operation>
63 nDeriveIterations = 25000;
64 nDerivationMethod = 0;
65 vchOtherDerivationParameters = std::vector<unsigned char>(0);
69 typedef std::vector<unsigned char, secure_allocator<unsigned char> >
CKeyingMaterial;
79 friend class wallet_crypto::TestCrypter;
81 std::vector<unsigned char, secure_allocator<unsigned char>>
vchKey;
82 std::vector<unsigned char, secure_allocator<unsigned char>>
vchIV;
85 int BytesToKeySHA512AES(
const std::vector<unsigned char>& chSalt,
const SecureString& strKeyData,
int count,
unsigned char *key,
unsigned char *iv)
const;
88 bool SetKeyFromPassphrase(
const SecureString &strKeyData,
const std::vector<unsigned char>& chSalt,
const unsigned int nRounds,
const unsigned int nDerivationMethod);
89 bool Encrypt(
const CKeyingMaterial& vchPlaintext, std::vector<unsigned char> &vchCiphertext)
const;
90 bool Decrypt(
const std::vector<unsigned char>& vchCiphertext,
CKeyingMaterial& vchPlaintext)
const;
91 bool SetKey(
const CKeyingMaterial& chNewKey,
const std::vector<unsigned char>& chNewIV);
155 result = vMasterKey.empty();
162 virtual bool AddCryptedKey(
const CPubKey &vchPubKey,
const std::vector<unsigned char> &vchCryptedSecret);
163 bool AddKeyPubKey(
const CKey& key,
const CPubKey &pubkey)
override;
171 return mapCryptedKeys.count(address) > 0;
175 bool GetKey(
const CKeyID &address,
CKey& keyOut)
const override;
176 bool GetPubKey(
const CKeyID &address,
CPubKey& vchPubKeyOut)
const override;
183 std::set<CKeyID> set_address;
184 for (
const auto& mi : mapCryptedKeys) {
185 set_address.insert(mi.first);
197 #endif // RAVEN_WALLET_CRYPTER_H
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
Encryption/decryption context with key information.
std::vector< unsigned char > vchCryptedKey
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, secure_allocator< unsigned char > > CKeyingMaterial
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
std::map< CKeyID, std::pair< CPubKey, std::vector< unsigned char > > > CryptedKeyMap
std::set< CKeyID > GetKeys() const override
std::atomic< bool > fUseCrypto
if fUseCrypto is true, mapKeys must be empty if fUseCrypto is false, vMasterKey must be empty ...
CKeyingMaterial vMasterKey
const unsigned int WALLET_CRYPTO_IV_SIZE
Keystore which keeps the private keys encrypted.
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.
const unsigned int WALLET_CRYPTO_SALT_SIZE
CryptedKeyMap mapCryptedKeys
void SerializationOp(Stream &s, Operation ser_action)
A reference to a CKey: the Hash160 of its serialized public key.
std::vector< unsigned char > vchSalt
An encapsulated private key.
unsigned int nDeriveIterations
bool HaveKey(const CKeyID &address) const override
Check whether a key corresponding to a given address is present in the store.
bool fDecryptionThoroughlyChecked
keeps track of whether Unlock has run a thorough check before
std::set< CKeyID > GetKeys() const override
Basic key store, that keeps keys in an address->secret map.