5 #ifndef BITCOIN_WALLET_CRYPTER_H 6 #define BITCOIN_WALLET_CRYPTER_H 45 template <
typename Stream,
typename Operation>
57 nDeriveIterations = 25000;
58 nDerivationMethod = 0;
59 vchOtherDerivationParameters = std::vector<uint8_t>(0);
72 friend class wallet_crypto_tests::TestCrypter;
75 std::vector<uint8_t, secure_allocator<uint8_t>>
vchKey;
76 std::vector<uint8_t, secure_allocator<uint8_t>>
vchIV;
79 int BytesToKeySHA512AES(
const std::vector<uint8_t> &chSalt,
81 uint8_t *key, uint8_t *iv)
const;
84 bool SetKeyFromPassphrase(
const SecureString &strKeyData,
85 const std::vector<uint8_t> &chSalt,
86 const unsigned int nRounds,
89 std::vector<uint8_t> &vchCiphertext)
const;
90 bool Decrypt(
const std::vector<uint8_t> &vchCiphertext,
93 const std::vector<uint8_t> &chNewIV);
112 std::vector<uint8_t> &vchCiphertext);
114 const std::vector<uint8_t> &vchCiphertext,
117 const std::vector<uint8_t> &vchCryptedSecret,
120 #endif // BITCOIN_WALLET_CRYPTER_H unsigned int nDerivationMethod
0 = EVP_sha512() 1 = scrypt()
const unsigned int WALLET_CRYPTO_KEY_SIZE
Encryption/decryption context with key information.
std::vector< uint8_t, secure_allocator< uint8_t > > CKeyingMaterial
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
const unsigned int WALLET_CRYPTO_IV_SIZE
void memory_cleanse(void *ptr, size_t len)
Secure overwrite a buffer (possibly containing secret data) with zero-bytes.
std::vector< uint8_t > vchOtherDerivationParameters
Use this for more parameters to key derivation, such as the various parameters to scrypt...
An encapsulated public key.
std::vector< uint8_t > vchCryptedKey
bool DecryptSecret(const CKeyingMaterial &vMasterKey, const std::vector< uint8_t > &vchCiphertext, const uint256 &nIV, CKeyingMaterial &vchPlaintext)
const unsigned int WALLET_CRYPTO_SALT_SIZE
void SerializationOp(Stream &s, Operation ser_action)
bool EncryptSecret(const CKeyingMaterial &vMasterKey, const CKeyingMaterial &vchPlaintext, const uint256 &nIV, std::vector< uint8_t > &vchCiphertext)
std::vector< uint8_t > vchSalt
std::vector< uint8_t, secure_allocator< uint8_t > > vchKey
An encapsulated secp256k1 private key.
unsigned int nDeriveIterations
bool DecryptKey(const CKeyingMaterial &vMasterKey, const std::vector< uint8_t > &vchCryptedSecret, const CPubKey &vchPubKey, CKey &key)
std::vector< uint8_t, secure_allocator< uint8_t > > vchIV