MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / Encrypt

Method Encrypt

src/wallet/crypter.cpp:76–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76bool CCrypter::Encrypt(const CKeyingMaterial& vchPlaintext, std::vector<unsigned char> &vchCiphertext) const
77{
78 if (!fKeySet)
79 return false;
80
81 // max ciphertext len for a n bytes of plaintext is
82 // n + AES_BLOCKSIZE bytes
83 vchCiphertext.resize(vchPlaintext.size() + AES_BLOCKSIZE);
84
85 AES256CBCEncrypt enc(vchKey.data(), vchIV.data(), true);
86 size_t nLen = enc.Encrypt(vchPlaintext.data(), vchPlaintext.size(), vchCiphertext.data());
87 if(nLen < vchPlaintext.size())
88 return false;
89 vchCiphertext.resize(nLen);
90
91 return true;
92}
93
94bool CCrypter::Decrypt(const std::span<const unsigned char> ciphertext, CKeyingMaterial& plaintext) const
95{

Callers 5

EncryptSecretFunction · 0.45
EncryptMasterKeyFunction · 0.45
EncryptWalletMethod · 0.45
TestEncryptSingleMethod · 0.45
crypter.cppFile · 0.45

Calls 3

resizeMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by 1

TestEncryptSingleMethod · 0.36