15 uint8_t *key, uint8_t *iv)
const {
20 if (!
count || !key || !iv) {
27 di.
Write((
const uint8_t *)strKeyData.data(), strKeyData.size());
28 di.
Write(chSalt.data(), chSalt.size());
31 for (
int i = 0; i !=
count - 1; i++) {
42 const std::vector<uint8_t> &chSalt,
43 const unsigned int nRounds,
44 const unsigned int nDerivationMethod) {
50 if (nDerivationMethod == 0) {
66 const std::vector<uint8_t> &chNewIV) {
72 memcpy(
vchKey.data(), chNewKey.data(), chNewKey.size());
73 memcpy(
vchIV.data(), chNewIV.data(), chNewIV.size());
80 std::vector<uint8_t> &vchCiphertext)
const {
90 size_t nLen = enc.
Encrypt(vchPlaintext.data(), vchPlaintext.size(),
91 vchCiphertext.data());
92 if (nLen < vchPlaintext.size()) {
95 vchCiphertext.resize(nLen);
107 int nLen = vchCiphertext.size();
109 vchPlaintext.resize(nLen);
112 nLen = dec.
Decrypt(vchCiphertext.data(), vchCiphertext.size(),
113 vchPlaintext.data());
117 vchPlaintext.resize(nLen);
123 std::vector<uint8_t> &vchCiphertext) {
127 if (!cKeyCrypter.
SetKey(vMasterKey, chIV)) {
135 const std::vector<uint8_t> &vchCiphertext,
140 if (!cKeyCrypter.
SetKey(vMasterKey, chIV)) {
143 return cKeyCrypter.
Decrypt(vchCiphertext, vchPlaintext);
147 const std::vector<uint8_t> &vchCryptedSecret,
155 if (vchSecret.size() != 32) {
static const int AES_BLOCKSIZE
int Decrypt(const uint8_t *data, int size, uint8_t *out) const
int Encrypt(const uint8_t *data, int size, uint8_t *out) const
Encryption/decryption context with key information.
std::vector< uint8_t, secure_allocator< uint8_t > > vchKey
bool Encrypt(const CKeyingMaterial &vchPlaintext, std::vector< uint8_t > &vchCiphertext) const
bool SetKeyFromPassphrase(const SecureString &strKeyData, const std::vector< uint8_t > &chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod)
int BytesToKeySHA512AES(const std::vector< uint8_t > &chSalt, const SecureString &strKeyData, int count, uint8_t *key, uint8_t *iv) const
std::vector< uint8_t, secure_allocator< uint8_t > > vchIV
bool Decrypt(const std::vector< uint8_t > &vchCiphertext, CKeyingMaterial &vchPlaintext) const
bool SetKey(const CKeyingMaterial &chNewKey, const std::vector< uint8_t > &chNewIV)
An encapsulated secp256k1 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.
CSHA512 & Write(const uint8_t *data, size_t len)
static constexpr size_t OUTPUT_SIZE
void Finalize(uint8_t hash[OUTPUT_SIZE])
void memory_cleanse(void *ptr, size_t len)
Secure overwrite a buffer (possibly containing secret data) with zero-bytes.
bool DecryptKey(const CKeyingMaterial &vMasterKey, const std::vector< uint8_t > &vchCryptedSecret, const CPubKey &vchPubKey, CKey &key)
bool EncryptSecret(const CKeyingMaterial &vMasterKey, const CKeyingMaterial &vchPlaintext, const uint256 &nIV, std::vector< uint8_t > &vchCiphertext)
bool DecryptSecret(const CKeyingMaterial &vMasterKey, const std::vector< uint8_t > &vchCiphertext, const uint256 &nIV, CKeyingMaterial &vchPlaintext)
const unsigned int WALLET_CRYPTO_IV_SIZE
const unsigned int WALLET_CRYPTO_SALT_SIZE
std::vector< uint8_t, secure_allocator< uint8_t > > CKeyingMaterial
const unsigned int WALLET_CRYPTO_KEY_SIZE
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString