21 if(!
count || !key || !iv)
27 di.
Write((
const unsigned char*)strKeyData.data(), strKeyData.size());
28 di.
Write(chSalt.data(), chSalt.size());
31 for(
int i = 0; i !=
count - 1; i++)
46 if (nDerivationMethod == 0)
65 memcpy(
vchKey.data(), chNewKey.data(), chNewKey.size());
66 memcpy(
vchIV.data(), chNewIV.data(), chNewIV.size());
82 size_t nLen = enc.
Encrypt(vchPlaintext.data(), vchPlaintext.size(), vchCiphertext.data());
83 if(nLen < vchPlaintext.size())
85 vchCiphertext.resize(nLen);
96 int nLen = vchCiphertext.size();
98 vchPlaintext.resize(nLen);
101 nLen = dec.
Decrypt(vchCiphertext.data(), vchCiphertext.size(), vchPlaintext.data());
104 vchPlaintext.resize(nLen);
113 if(!cKeyCrypter.
SetKey(vMasterKey, chIV))
115 return cKeyCrypter.
Encrypt(vchPlaintext, vchCiphertext);
123 if(!cKeyCrypter.
SetKey(vMasterKey, chIV))
125 return cKeyCrypter.
Decrypt(vchCiphertext, vchPlaintext);
134 if (vchSecret.size() != 32)
static const int AES_BLOCKSIZE
int Decrypt(const unsigned char *data, int size, unsigned char *out) const
int Encrypt(const unsigned char *data, int size, unsigned char *out) const
An encapsulated private key.
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
bool VerifyPubKey(const CPubKey &vchPubKey) const
Verify thoroughly whether a private key and a public key match.
An encapsulated public key.
bool IsCompressed() const
Check whether this is a compressed public key.
uint256 GetHash() const
Get the 256-bit hash of this public key.
A hasher class for SHA-512.
static constexpr size_t OUTPUT_SIZE
void Finalize(unsigned char hash[OUTPUT_SIZE])
CSHA512 & Write(const unsigned char *data, size_t len)
Encryption/decryption context with key information.
bool Decrypt(const std::vector< unsigned char > &vchCiphertext, CKeyingMaterial &vchPlaintext) const
std::vector< unsigned char, secure_allocator< unsigned char > > vchKey
bool Encrypt(const CKeyingMaterial &vchPlaintext, std::vector< unsigned char > &vchCiphertext) const
std::vector< unsigned char, secure_allocator< unsigned char > > vchIV
bool SetKeyFromPassphrase(const SecureString &strKeyData, const std::vector< unsigned char > &chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod)
bool SetKey(const CKeyingMaterial &chNewKey, const std::vector< unsigned char > &chNewIV)
int BytesToKeySHA512AES(const std::vector< unsigned char > &chSalt, const SecureString &strKeyData, int count, unsigned char *key, unsigned char *iv) const
void memory_cleanse(void *ptr, size_t len)
Secure overwrite a buffer (possibly containing secret data) with zero-bytes.
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
bool DecryptSecret(const CKeyingMaterial &vMasterKey, const std::vector< unsigned char > &vchCiphertext, const uint256 &nIV, CKeyingMaterial &vchPlaintext)
bool DecryptKey(const CKeyingMaterial &vMasterKey, const std::vector< unsigned char > &vchCryptedSecret, const CPubKey &vchPubKey, CKey &key)
const unsigned int WALLET_CRYPTO_KEY_SIZE
const unsigned int WALLET_CRYPTO_IV_SIZE
const unsigned int WALLET_CRYPTO_SALT_SIZE
bool EncryptSecret(const CKeyingMaterial &vMasterKey, const CKeyingMaterial &vchPlaintext, const uint256 &nIV, std::vector< unsigned char > &vchCiphertext)
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString