5 #ifndef BITCOIN_WALLET_CRYPTER_H 6 #define BITCOIN_WALLET_CRYPTER_H 48 READWRITE(obj.vchCryptedKey, obj.vchSalt, obj.nDerivationMethod, obj.nDeriveIterations, obj.vchOtherDerivationParameters);
55 nDeriveIterations = 25000;
56 nDerivationMethod = 0;
57 vchOtherDerivationParameters = std::vector<unsigned char>(0);
61 typedef std::vector<unsigned char, secure_allocator<unsigned char> >
CKeyingMaterial;
71 friend class wallet_crypto_tests::TestCrypter;
73 std::vector<unsigned char, secure_allocator<unsigned char>>
vchKey;
74 std::vector<unsigned char, secure_allocator<unsigned char>>
vchIV;
77 int BytesToKeySHA512AES(
const std::vector<unsigned char>& chSalt,
const SecureString& strKeyData,
int count,
unsigned char *key,
unsigned char *iv)
const;
80 bool SetKeyFromPassphrase(
const SecureString &strKeyData,
const std::vector<unsigned char>& chSalt,
const unsigned int nRounds,
const unsigned int nDerivationMethod);
81 bool Encrypt(
const CKeyingMaterial& vchPlaintext, std::vector<unsigned char> &vchCiphertext)
const;
82 bool Decrypt(
const std::vector<unsigned char>& vchCiphertext,
CKeyingMaterial& vchPlaintext)
const;
83 bool SetKey(
const CKeyingMaterial& chNewKey,
const std::vector<unsigned char>& chNewIV);
109 #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< unsigned char > vchCryptedKey
Private key encryption is done based on a CMasterKey, which holds a salt and random encryption key...
SERIALIZE_METHODS(CMasterKey, obj)
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 DecryptSecret(const CKeyingMaterial &vMasterKey, const std::vector< unsigned char > &vchCiphertext, const uint256 &nIV, CKeyingMaterial &vchPlaintext)
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< 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
std::vector< unsigned char > vchSalt
bool EncryptSecret(const CKeyingMaterial &vMasterKey, const CKeyingMaterial &vchPlaintext, const uint256 &nIV, std::vector< unsigned char > &vchCiphertext)
An encapsulated private key.
bool DecryptKey(const CKeyingMaterial &vMasterKey, const std::vector< unsigned char > &vchCryptedSecret, const CPubKey &vchPubKey, CKey &key)
unsigned int nDeriveIterations